Cloudformation Lessons learned:

  • Can’t update a stack that’s in ROLLBACK_COMPLETE. must delete it first.

  • URL for resource types: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-template-resource-type-ref.html

  • Deleted stacks stay in ‘delete_complete’ state for 90 days.

  • Potential way to avoid having to mess w/ami names: https://xebia.com/blog/keeping-your-amis-up-to-date-in-aws-cloudformation/

  • To use ‘latest image’ in CF templates: * Create a SSM parameter store * Use the /aws public parameters to find latest. * Should use /aws/service/ami-amazon-linux-latest/amzn-ami-hvm-x86_64-ebs * In parameters section, add something for imageid:

    ImageId:
      Type: AWS::SSM::Parameter::Value<AWS::EC2::Image::Id>
      Default: /aws/service/ami-amazon-linux-latest/al2023-ami-kernel-6.1-x86_64
    
  • Region is defined as a cli parameter, not an attribute for resources:

    aws cloudformation deploy --region us-east-2 --template-file ...
    
  • To deploy, use template-file, to update, use template-body. Consistency is a wonderful thing:

    aws cloudformation deploy --region us-east-2 --template-file ...
    VS
    aws cloudformation update-stack --template-body file://...
    
  • Can’t use external scripts to identify parameters such as myip like we can in terraform.