Slide 14
Slide 14 text
#jawsugibaraki #jawsug_cdk
L1 constructからL2 constructへ (CloudFront Distributionの例)
const distribution = new cloudfront.CfnDistribution(this, 'CloudFrontDistribution', {
distributionConfig: {
enabled: true,
comment: '??? official website ????',
defaultRootObject: 'index.html',
httpVersion: 'http2',
ipv6Enabled: true,
priceClass: 'PriceClass_All',
webAclId: webAcl.attrArn,
origins: [
{
id: config.originId,
domainName: bucket.attrRegionalDomainName,
originAccessControlId: originAccessControl.attrId,
connectionAttempts: 3,
connectionTimeout: 10,
originCustomHeaders: [],
originPath: '',
originShield: {
enabled: false,
},
s3OriginConfig: {
originAccessIdentity: '',
},
},
],
defaultCacheBehavior: {
targetOriginId: config.originId,
viewerProtocolPolicy: 'redirect-to-https',
cachePolicyId: MANAGED_CACHING_OPTIMIZED,
compress: true,
allowedMethods: ['HEAD', 'GET'],
cachedMethods: ['HEAD', 'GET'],
smoothStreaming: false,
functionAssociations: [],
lambdaFunctionAssociations: [],
trustedSigners: [],
trustedKeyGroups: [],
fieldLevelEncryptionId: '',
},
viewerCertificate: {
cloudFrontDefaultCertificate: true,
minimumProtocolVersion: 'TLSv1',
},
restrictions: {
geoRestriction: {
restrictionType: 'none',
locations: [],
},
},
logging: {
bucket: '',
includeCookies: false,
prefix: '',
},
aliases: [],
cacheBehaviors: [],
customErrorResponses: [],
originGroups: {
quantity: 0,
items: [],
},
staging: false,
continuousDeploymentPolicyId: '',
},
});
const distribution = new cloudfront.Distribution(this, 'CloudFrontDistribution', {
comment: '??? official website ????',
defaultRootObject: 'index.html',
httpVersion: cloudfront.HttpVersion.HTTP2,
enableIpv6: true,
priceClass: cloudfront.PriceClass.PRICE_CLASS_ALL,
webAclId: webAcl.attrArn,
enabled: true,
defaultBehavior: {
origin: s3Origin,
viewerProtocolPolicy: cloudfront.ViewerProtocolPolicy.REDIRECT_TO_HTTPS,
cachePolicy: cloudfront.CachePolicy.CACHING_OPTIMIZED,
compress: true,
allowedMethods: cloudfront.AllowedMethods.ALLOW_GET_HEAD,
cachedMethods: cloudfront.CachedMethods.CACHE_GET_HEAD,
smoothStreaming: false,
},
minimumProtocolVersion: cloudfront.SecurityPolicyProtocol.TLS_V1,
});