-
Notifications
You must be signed in to change notification settings - Fork 3.8k
/
example.acm-cert-alias.lit.ts
42 lines (37 loc) · 1.34 KB
/
example.acm-cert-alias.lit.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import * as certificatemanager from '@aws-cdk/aws-certificatemanager';
import * as s3 from '@aws-cdk/aws-s3';
import { App, Stack } from '@aws-cdk/core';
import { Construct } from 'constructs';
import * as cloudfront from '../lib';
class AcmCertificateAliasStack extends Stack {
constructor(scope: Construct, id: string) {
super(scope, id);
/// !show
const s3BucketSource = new s3.Bucket(this, 'Bucket');
const certificate = new certificatemanager.Certificate(this, 'Certificate', {
domainName: 'example.com',
subjectAlternativeNames: ['*.example.com'],
});
const distribution = new cloudfront.CloudFrontWebDistribution(this, 'AnAmazingWebsiteProbably', {
originConfigs: [{
s3OriginSource: { s3BucketSource },
behaviors: [{ isDefaultBehavior: true }],
}],
viewerCertificate: cloudfront.ViewerCertificate.fromAcmCertificate(
certificate,
{
aliases: ['example.com', 'www.example.com'],
securityPolicy: cloudfront.SecurityPolicyProtocol.TLS_V1, // default
sslMethod: cloudfront.SSLMethod.SNI, // default
},
),
});
/// !hide
Array.isArray(s3BucketSource);
Array.isArray(certificate);
Array.isArray(distribution);
}
}
const app = new App();
new AcmCertificateAliasStack(app, 'AcmCertificateAliasStack');
app.synth();