npm i -D @alma-cdk/domain
Simplifies creation of subdomain with a TLS certificate and configuration with services like AWS CloudFront.
🚧 Project Stability
This construct is still versioned with v0
major version and breaking changes might be introduced if necessary (without a major version bump), though we aim to keep the API as stable as possible (even within v0
development). We aim to publish v1.0.0
soon and after that breaking changes will be introduced via major version bumps.
Getting Started
import { Domain } from '@alma-cdk/domain';
import * as cloudfront from 'aws-cdk-lib/aws-cloudfront';
const domain = new Domain(this, 'Domain', {
zone: 'example.com',
subdomain: 'foobar',
});
const distribution = new cloudfront.Distribution(this, 'Distribution', {
certificate: domain.certificate,
domainNames: [domain.fqdn],
enableIpv6: domain.enableIpv6,
})
domain.addTarget(new targets.CloudFrontTarget(distribution))
CloudFront helper
Instead of assigning certificate
, domainNames
and enableIpv6
properties individually, you may choose to use the one-liner helper utility method configureCloudFront()
to set all three values at once – don't forget to use ...
object spread syntax:
const distribution = new cloudfront.Distribution(this, 'Distribution', {
...domain.configureCloudFront(),
})
domain.addTarget(new targets.CloudFrontTarget(distribution))
Note: The returned domain names configuration is domainNames: [domain.fqdn]
, meaning this only works in scenarios where your CloudFront distribution has only single domain name.