CDK Flashcards
How can you use SAM to locally test your CDK apps?
- Run cdk synth to generate a CloudFormation template
- Run sam local invoke – t <CFtemplateName> <functionName></functionName></CFtemplateName>
When and how many times do you need to run CDK Bootstrap
Once per region per Account, in order to set up CDK
What is the correct order of steps to be followed for creating an app using AWS CDK?
- CREATE the app from a template provided by AWS CDK
- ADD CODE to the app to create resources within stacks
- BUILD the app (optional)
- SYNTHESIZE one or more stacks in the app
- DEPLOY stack(s) to your AWS account
What are the necessary prerequisites to deploying any CDK stack in an environment?
You need to Bootstrap the CDK Toolkit by using cdk Bootstrap aws://account/region and it contains:
an S3 Bucket to store files
IAM roles
What if you try to deploy and you didn’t perform the Bootstrap?
You get an error about invalid principal
How do you test your CDK app?
Use the CDK Assertions module
What are the 2 commands to import a template for testing?
- Template.fromStack(MyStack) - for templates built inside CDK
- Template.fromString(MyString) - for templates built outside CDK