Skip to content

Instantly share code, notes, and snippets.

@xbalaji
Last active May 16, 2019 05:59
Show Gist options
  • Save xbalaji/d361a272c75c2f35f43f739945d45fa0 to your computer and use it in GitHub Desktop.
Save xbalaji/d361a272c75c2f35f43f739945d45fa0 to your computer and use it in GitHub Desktop.
aws-cdk-notes
sudo apt -y install nodejs npm
node --version
npm --version
sudo npm i -g aws-cdk
cdk --version
# follow example from: https://docs.aws.amazon.com/cdk/latest/guide/getting_started.html#hello_world_tutorial
mkdir simple-s3 && cd simple-s3
cdk init app --language typescript
npm run build
cdk ls
# now modify the code for simple s3 stack
npm install @aws-cdk/aws-s3
sed -ie "/require('@aws-cdk\/cdk');/a\import s3 = require('@aws-cdk\/aws-s3');" lib/simple-s3-stack.ts
sed -ie "/The code that defines your stack goes here/a\ new s3.Bucket(this, 'MyFirstBucket', {\n versioned: true\n });" lib/simple-s3-stack.ts
npm run build
cdk synth
####
cd ..
mkdir simple-ec2 && cd simple-ec2
cdk init app --language typescript
npm install @aws-cdk/aws-ec2
sed -e "/require('@aws-cdk\/cdk');/a\import ec2 = require('@aws-cdk\/aws-ec2');" -e "/The code that defines your stack goes here/a\ new ec2.CfnInstance(this, 'MyInstance', {});" lib/simple-ec2-stack.ts
npm run build
cdk synth
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment