in chime-sdk-components/frontend-cdk/lib/meetings-frontend-stack.ts [14:82]
constructor(scope: cdk.Construct, id: string, props?: StackProps) {
super(scope, id, props);
const appName = 'meeting';
/**************************************************************************************************************
* Frontend Resources *
**************************************************************************************************************/
// The code that defines your stack goes here
// s3 - website
const chimeReactMeetingsDemoBucket = new S3.Bucket(this, "chimeReactMeetingsDemoBucket", {
websiteIndexDocument: `${appName}.html`,
websiteErrorDocument:`${appName}.html`,
removalPolicy: cdk.RemovalPolicy.RETAIN,
versioned: true,
// serverAccessLogsPrefix: 'logs/',
accessControl: S3.BucketAccessControl.LOG_DELIVERY_WRITE,
});
this.chimeReactMeetingsDemoBucket = new cdk.CfnOutput(this, "chimeReactMeetingsDemoBucketName", { value: chimeReactMeetingsDemoBucket.bucketName })
// Origin Access Identity
const chimeReactMeetingsCloudFrontOAI = new cloudfront.OriginAccessIdentity(
this,
"chimeReactMeetingsCloudFrontOAI"
);
// CloudFront distribution that provides HTTPS
const distribution = new cloudfront.CloudFrontWebDistribution(
this,
"MeetingsWebsitesiteDistribution",
{
originConfigs: [
{
s3OriginSource: {
s3BucketSource: chimeReactMeetingsDemoBucket,
originAccessIdentity: chimeReactMeetingsCloudFrontOAI,
},
behaviors: [{ isDefaultBehavior: true }],
},
],
defaultRootObject: `${appName}.html`,
}
);
chimeReactMeetingsDemoBucket.grantRead(chimeReactMeetingsCloudFrontOAI.grantPrincipal);
this.websiteCloudfrontDistribution = new cdk.CfnOutput(this, "MeetingsWebsiteCloudfrontDistribution", {
value: distribution.distributionDomainName,
})
/* S3 Deployment resource */
new S3Deployment.BucketDeployment(this, "S3WebsiteDeployment", {
sources: [S3Deployment.Source.asset(`../react-meeting-demo/demo/meeting/dist`)],
destinationBucket: chimeReactMeetingsDemoBucket,
distribution:distribution,
distributionPaths: ['/*'], //invalidate the path
});
this.staticWebsiteBucketDomain = new cdk.CfnOutput(this, "BucketDomain", {
value: chimeReactMeetingsDemoBucket.bucketWebsiteDomainName,
});
new ssm.StringParameter(this, "chimeFrontendWebAppUrl", {
description: "The CloudFront distribution for the Chime SDK Meetings backend",
parameterName: "/chime/web/frontendUrl",
stringValue: `https://${distribution.distributionDomainName}`
})
}