Skip to content

Instantly share code, notes, and snippets.

@leegilmorecode
Created March 24, 2023 17:41
Show Gist options
  • Save leegilmorecode/2c98de971479c436840bf0cf9491c95e to your computer and use it in GitHub Desktop.
Save leegilmorecode/2c98de971479c436840bf0cf9491c95e to your computer and use it in GitHub Desktop.
Runtime configuration created for a ReactJS frontend and hosted in S3
// Setup Bucket Deployment to automatically deploy new assets and invalidate cache
new s3deploy.BucketDeployment(this, 'ClientBucketDeployment', {
sources: [
s3deploy.Source.asset(path.join(__dirname, '../../../../client/build')),
s3deploy.Source.jsonData('config.json', {
stage,
domainName: props.domainName,
subDomain,
api: `https://api-${stage}.${props.domainName}`,
}), // runtime config for client
],
destinationBucket: this.bucket,
metadata: {
stageName: stage,
},
distribution: cloudFrontDistribution,
distributionPaths: ['/*'],
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment