Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions shared/infra/aws/lib/dns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,20 @@ export class Dns extends Construct {
"ImportedCertificate",
certificateArn,
);

} else {
this.certificate = undefined;
this.hostedZone = undefined;
}
}

addCnameFor(distribution: Distribution) {
addCnameFor(distribution: Distribution, env: string) {
// Add a CName if the hosted zone exists.
if (this.hostedZone) {
const cNameRecord = new CnameRecord(this, "CnameRecord", {
zone: this.hostedZone!,
domainName: distribution.domainName,
recordName: this.getPrimaryDomainName("prod")!,
recordName: this.getPrimaryDomainName(env)!,
ttl: Duration.minutes(5),
});
}
Expand Down
2 changes: 1 addition & 1 deletion shared/infra/aws/lib/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ export class Network extends Construct {
comment: `OAI for stickerlandia web frontend ${props.env}`,
});
webFrontendBucket.grantRead(originIdentity);

this.distribution = new Distribution(this, `Stickerlandia-${props.env}`, {
certificate: props.dns.certificate,
domainNames: props.dns.getPrimaryDomainName(props.env)
Expand Down
2 changes: 1 addition & 1 deletion shared/infra/aws/lib/shared-resources-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export class StickerlandiaSharedResourcesStack extends cdk.Stack {
dns: dns,
});

dns.addCnameFor(network.distribution);
dns.addCnameFor(network.distribution, env);

const persistence = new Persistence(this, "Persistence", {
env,
Expand Down
Loading