
Coding Best Practices
- Use the AWS Well-Architected Framework
- Infrastructure and Runtime Code should be in the same repo / same place
Construct Best Practices
- You model with constructs, deploy with stacks not the console
- Configure with properties and methods, they should be all defined at the top layer of the CDK
- You should avoid changing the logical IDs, this will replace the old service
Application
- Make all decisions at synthesis, aka don’t try and use for loops and if statements, if you can. BUT DEFO NOT LOOPS
- Define removal policies, and log retention (saves money), by default stuff will not be deleted
- Use multiple stacks, a good example is putting any multiple services in another stack
- Commit cdk.context.json it stores how stuff was put together, this is needed!
- Make all the production stages in code
- Measure everything you can