AWS Classroomnotes 02/Jan/2022

CloudFormation Template Best Practices

  • Avoid Hardcoding as much as possible
  • Refer Here for the changes done to avoid hardcoding
  • Image id => This is tricky as it changes for every region. So in this case we would like to use ubuntu20 ami. The cli query to get the ami id of ubunutu 20.04 in any region
aws ec2 describe-images --filters "Name=name,Values=ubuntu/images/hvm-ssd/ubuntu-focal-20.04-amd64-server-20211129" --region <region-code>  --query "Images[0].ImageId"
  • To accomodate region wise settings we can use Mappings Refer Here
  • To use the map value in resources Refer Here
  • Refer Here for the changes with mappings
  • Now lets add required outputs for the template Refer Here for the documentation of outputs
  • To get attributes use Fn::GetAtt Refer Here
  • After adding some outputs to the template and updating the stack. Refer Here for the changes done
  • Note Stacksets can be used to create stacks in multiple regions.
Published
Categorized as Uncategorized Tagged

By continuous learner

devops & cloud enthusiastic learner

Leave a ReplyCancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Please turn AdBlock off
Animated Social Media Icons by Acurax Responsive Web Designing Company

Discover more from Direct DevOps from Quality Thought

Subscribe now to keep reading and get access to the full archive.

Continue reading

Exit mobile version
%%footer%%