Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
super(scope, 'scale-your-cloudformation');
const domainName = 'scaleyourcloudformation.com';
const cert = new Certificate(this, 'cert', {
domainName,
validationMethod: ValidationMethod.DNS,
});
const websiteBucket = new Bucket(this, 'WebsiteBucket', {
domainName,
removalPolicy: RemovalPolicy.DESTROY,
websiteIndexDocument: 'index.html',
websiteErrorDocument: 'error.html',
});
const originId = new CfnCloudFrontOriginAccessIdentity(
this,
'OriginAccessIdentity',
{
cloudFrontOriginAccessIdentityConfig: {
comment: `CloudFront OriginAccessIdentity for ${websiteBucket.bucketName}`,
},
},
);
websiteBucket.grantRead(
new CanonicalUserPrincipal(originId.attrS3CanonicalUserId),
);
let s3OriginConfig = {
originAccessIdentityId: originId.ref,
s3BucketSource: websiteBucket,
bucketName,
removalPolicy = RemovalPolicy.RETAIN,
disableUpload = false,
source,
websiteIndexDocument,
websiteErrorDocument,
} = props;
const bucket = new Bucket(this, 'WebsiteBucket', {
bucketName,
removalPolicy,
websiteIndexDocument: websiteIndexDocument || 'index.html',
websiteErrorDocument: websiteErrorDocument || 'error.html',
});
const originId = new CfnCloudFrontOriginAccessIdentity(
this,
'OriginAccessIdentity',
{
cloudFrontOriginAccessIdentityConfig: {
comment: `CloudFront OriginAccessIdentity for ${bucket.bucketName}`,
},
},
);
bucket.grantRead(
new CanonicalUserPrincipal(originId.attrS3CanonicalUserId),
);
if (!disableUpload) {
const placeHolderSource = path.join(__dirname, '..', 'website');