Using CloudFormation language extensions
CloudFormation templates are in YAML or JSON format, but the template itself is a DSL – domain-specific language. While we can use YAML features such as anchors and aliases, CloudFormation supercharges generic indented text with variable references with Fn::Ref
, class attribute getters with Fn::GetAtt
, and CIDR range generation with Fn::Cidr
and else.
One of the unpleasant limitations is when we have to create multiple similar resources or when we need to write JSON strings in the resource properties.
While repeatability is solved with other tools such as Cloud Development Kit and Serverless Application Model, AWS keeps improving CloudFormation, and with it has recently released Language Extensions (https://aws.amazon.com/about-aws/whats-new/2022/09/aws-cloudformation-new-language-extensions-transform/).
One example usage we have already seen is the deletion policy, where we decide to retain or delete the database depending on...