Skip to content

Instantly share code, notes, and snippets.

@mrpackethead
Created January 20, 2024 23:23
Show Gist options
  • Save mrpackethead/cebde69aab107e4e692ff1ba25bfc8e7 to your computer and use it in GitHub Desktop.
Save mrpackethead/cebde69aab107e4e692ff1ba25bfc8e7 to your computer and use it in GitHub Desktop.
First CDK application
import {
App,
Stack,
StackProps,
aws_s3 as s3,
}
from 'aws-cdk-lib';
import * as core from 'aws-cdk-lib'
import { Construct } from 'constructs';
export class MyStack extends Stack {
constructor(scope: Construct, id: string, props: StackProps = {}) {
super(scope, id, props);
// Content bucket
new s3.Bucket(this, 'SiteBucket', {
publicReadAccess: false,
blockPublicAccess: s3.BlockPublicAccess.BLOCK_ALL,
/**
* The default removal policy is RETAIN, which means that cdk destroy will not attempt to delete
* the new bucket, and it will remain in your account until manually deleted. By setting the policy to
* DESTROY, cdk destroy will attempt to delete the bucket, but will error if the bucket is not empty.
*/
removalPolicy: core.RemovalPolicy.DESTROY, // NOT recommended for production code
/**
* For sample purposes only, if you create an S3 bucket then populate it, stack destruction fails. This
* setting will enable full cleanup of the demo.
*/
autoDeleteObjects: true, // NOT recommended for production code
});
}
}
// Use the account number of your sandbox
const sandbox = {
account: '366197773329',
region: 'us-east-1'
};
const app = new App();
new MyStack(app, 'orca-website', { env: sandbox });
app.synth();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment