cdkcloudfrontassociatealias

package module
v1.0.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 7, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

README

cdk-cloudfront-associate-alias

A simple construct to handle automated Cloudfront DNS alias migration with zero downtime.

NPM Package

View on Construct Hub

Usage

Usage of this construct is fairly straightforward. Simply pass in the Cloudfront distribution, the Route53 hosted zone, and the alias you want to associate with the distribution.

const customDomain = "example.com";
const hostedZone = route53.HostedZone.fromLookup(this, "HostedZone", {
    domainName: DOMAIN_NAME,
});
const targetDistribution =
    cloudfront.Distribution.fromDistributionAttributes(
        this,
        "Distribution",
        {
            distributionId,
            domainName: distributionDomainName,
        },
    );

new CloudfrontAliasAssociator(
    this,
    "AliasAssociator",
    {
        alias: customDomain,
        hostedZone,
        targetDistribution,
    },
);

What this does

This construct will create:

  1. A TXT record, this is specific to the API call used, and ensures you have ownership of the domain.
  2. A Custom Resource that makes an AssociateAlias API call to Cloudfront. This API specifically is for zero downtime alias migration in Cloudfront. This will work even if the domain isn't pre-associated.
  3. An A and AAAA alias record that points to the (new) Cloudfront distribution.

Use Cases

Notably, this construct can be used to provide Blue/Green style deployments for Cloudfront distributions. This means you can create a new distribution, associate the alias with it and this will result in zero downtime for your users.

You can also use this construct in reverse to rollback your alias to the previous deployment (or any other deployment).

For this use case, I recommend pairing this construct with the cdk-versioned-stack-manager to manage your versioned stacks.

Documentation

Overview

A simple construct to handle automated Cloudfront DNS alias migration with zero downtime

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloudfrontAliasAssociator_IsConstruct

func CloudfrontAliasAssociator_IsConstruct(x interface{}) *bool

Checks if `x` is a construct.

Returns: true if `x` is an object created from a class which extends `Construct`. Deprecated: use `x instanceof Construct` instead.

func NewCloudfrontAliasAssociator_Override

func NewCloudfrontAliasAssociator_Override(c CloudfrontAliasAssociator, scope constructs.Construct, id *string, props ICloudfrontAliasAssociatorProps)

Types

type CloudfrontAliasAssociator

type CloudfrontAliasAssociator interface {
	constructs.Construct
	// The tree node.
	Node() constructs.Node
	// Returns a string representation of this construct.
	ToString() *string
}

A simple construct to handle automated Cloudfront DNS alias migration with zero downtime.

This creates: - A TXT record with the name `_${alias}` that points to the targetDistributionDomainName. - A Cloudfront custom resource "Custom::CloudfrontAssociateAlias" that associates the alias with the targetDistributionId.

  • Because we use the SDK here, this construct can be used as part of a versioned deployment, and can be used for both standard and rollback scenarios.

- A Route53 A and AAAA record that alias to the targetDistribution.

func NewCloudfrontAliasAssociator

func NewCloudfrontAliasAssociator(scope constructs.Construct, id *string, props ICloudfrontAliasAssociatorProps) CloudfrontAliasAssociator

type ICloudfrontAliasAssociatorProps

type ICloudfrontAliasAssociatorProps interface {
	Alias() *string
	// The Route53 hosted zone that houses the customDomain.
	HostedZone() awsroute53.IHostedZone
	// The Cloudfront Distribution we want to move the alias to.
	TargetDistribution() awscloudfront.IDistribution
}

Directories

Path Synopsis
Package jsii contains the functionaility needed for jsii packages to initialize their dependencies and themselves.
Package jsii contains the functionaility needed for jsii packages to initialize their dependencies and themselves.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL