@studion/infra-code-blocks 0.6.8 → 0.6.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -11,6 +11,10 @@ export type StaticSiteArgs = {
|
|
|
11
11
|
* The ID of the hosted zone.
|
|
12
12
|
*/
|
|
13
13
|
hostedZoneId?: pulumi.Input<string>;
|
|
14
|
+
/**
|
|
15
|
+
* ARN of the CloudFront viewer-request function.
|
|
16
|
+
*/
|
|
17
|
+
viewerRequestFunctionArn?: pulumi.Input<string>;
|
|
14
18
|
/**
|
|
15
19
|
* A map of tags to assign to the resource.
|
|
16
20
|
*/
|
|
@@ -9,7 +9,7 @@ class StaticSite extends pulumi.ComponentResource {
|
|
|
9
9
|
constructor(name, args, opts = {}) {
|
|
10
10
|
super('studion:StaticSite', name, {}, opts);
|
|
11
11
|
this.name = name;
|
|
12
|
-
const { domain, hostedZoneId, tags } = args;
|
|
12
|
+
const { domain, hostedZoneId, viewerRequestFunctionArn, tags } = args;
|
|
13
13
|
const hasCustomDomain = domain && hostedZoneId;
|
|
14
14
|
if (domain && !hostedZoneId) {
|
|
15
15
|
throw new Error('StaticSite:hostedZoneId must be provided when the domain is specified');
|
|
@@ -18,7 +18,11 @@ class StaticSite extends pulumi.ComponentResource {
|
|
|
18
18
|
this.certificate = this.createTlsCertificate({ domain, hostedZoneId });
|
|
19
19
|
}
|
|
20
20
|
this.bucket = this.createPublicBucket({ tags });
|
|
21
|
-
this.cloudfront = this.createCloudfrontDistribution({
|
|
21
|
+
this.cloudfront = this.createCloudfrontDistribution({
|
|
22
|
+
domain,
|
|
23
|
+
viewerRequestFunctionArn,
|
|
24
|
+
tags,
|
|
25
|
+
});
|
|
22
26
|
if (hasCustomDomain) {
|
|
23
27
|
this.createDnsRecord({ domain, hostedZoneId });
|
|
24
28
|
}
|
|
@@ -66,7 +70,15 @@ class StaticSite extends pulumi.ComponentResource {
|
|
|
66
70
|
}
|
|
67
71
|
return bucket;
|
|
68
72
|
}
|
|
69
|
-
createCloudfrontDistribution({ domain, tags, }) {
|
|
73
|
+
createCloudfrontDistribution({ domain, viewerRequestFunctionArn, tags, }) {
|
|
74
|
+
const functionAssociations = viewerRequestFunctionArn
|
|
75
|
+
? [
|
|
76
|
+
{
|
|
77
|
+
eventType: 'viewer-request',
|
|
78
|
+
functionArn: viewerRequestFunctionArn,
|
|
79
|
+
},
|
|
80
|
+
]
|
|
81
|
+
: [];
|
|
70
82
|
const cloudfront = new aws.cloudfront.Distribution(`${this.name}-cloudfront`, Object.assign(Object.assign({ enabled: true, defaultRootObject: 'index.html' }, (domain && { aliases: [domain] })), { isIpv6Enabled: true, waitForDeployment: true, httpVersion: 'http2and3', viewerCertificate: Object.assign({}, (this.certificate
|
|
71
83
|
? {
|
|
72
84
|
acmCertificateArn: this.certificate.certificate.arn,
|
|
@@ -101,6 +113,7 @@ class StaticSite extends pulumi.ComponentResource {
|
|
|
101
113
|
cookies: { forward: 'none' },
|
|
102
114
|
queryString: false,
|
|
103
115
|
},
|
|
116
|
+
functionAssociations,
|
|
104
117
|
}, priceClass: 'PriceClass_100', restrictions: {
|
|
105
118
|
geoRestriction: { restrictionType: 'none' },
|
|
106
119
|
}, tags: Object.assign(Object.assign({}, constants_1.commonTags), tags) }), { parent: this });
|