@codedazur/cdk-site-distribution
v2.3.1
Published
Keywords
Readme
@codedazur/cdk-site-distribution
Firewall
The distribution can be protected by an AWS WAF web ACL, created with the Firewall construct.
new SiteDistribution(this, "SiteDistribution", {
// ...
firewall: new Firewall(this, "Firewall"),
});A firewall for CloudFront must be created in us-east-1. If your stack is in another region, see the Firewall documentation for how to create it in a separate stack.
To use an existing web ACL instead, import it with Firewall.fromWebAclArn. See Existing Web ACLs.
Certificate
A certificate for CloudFront must be created in us-east-1. If your stack is in another region, create the certificate in a separate us-east-1 stack and pass it to the distribution.
const edge = new Stack(app, "Edge", {
env: { account, region: "us-east-1" },
});
const certificate = new Certificate(edge, "Certificate", {
domainName: "example.com",
validation: CertificateValidation.fromDns(),
});
const site = new Stack(app, "Site", {
env: { account, region: "eu-central-1" },
});
new SiteDistribution(site, "SiteDistribution", {
// ...
domain: "example.com",
certificate,
});The distribution imports the certificate with importAcrossRegions from cdk-essentials, which deploys no Lambda functions in us-east-1, unlike CDK's crossRegionReferences.
Without a hosted zone, CloudFormation waits until the certificate is validated, so the deploy of the us-east-1 stack only completes once you have added the CNAME records from its stack events to your DNS.
Migration Guide
Migrating from v0 to v1
Version 1.0.0 introduces a breaking change to how DNS records are managed. To prevent conflicts with existing records, the ARecord resources now automatically delete records with the same name before creating new ones.
To migrate, you must manually delete any existing ARecords that were created by a v0 version of this construct. After removing the records, you can safely deploy the v1 version.
Failure to remove the old records will result in a deployment failure.
