margareta.dev

AWS

April 07, 2022

Code best practice

A construct is a logical unit of the app.

  • Not recommended to have multiple cdk apps in the same repository.
  • Combine the code for the infra and runtime app into a single construct.
  • Represent each logical unit as a construct, while each deployment unit as a stack.
  • Do env variable lookup at the top level of an cdk app and pass them as props down.
  • Avoid network lookups during synthesis
  • Model production stages in code
  • Write unit tests

Application best practice

Working with stacks and constructs

  • better to keep as many resources in the same stack as possible
  • stateful resources should be in a separate stack than stateless (termination protection on the stateful stack)
  • be careful with renaming constructs with stateful resources since they will be replaced

AWS Well-Architected Tool

  • free
  • used to evaluate workloads, identify high-risk issues and record improvements