AWS SAM CLI introduces support for AWS CloudFormation Language Extensions

AWS SAM CLI now supports AWS CloudFormation Language Extensions, enabling developers to reduce duplication in IaC templates while maintaining a full local development workflow. This update accelerates serverless development by allowing resources to be defined once and iterated locally without cloud deployments.

The AWS SAM CLI has been updated to include support for AWS CloudFormation Language Extensions, a feature designed to streamline the process of developing serverless applications by reducing redundancy in infrastructure as code (IaC) templates. This enhancement allows developers to define resources just once and perform local iterations without the need for cloud deployments, thus accelerating the serverless development process.

In the past, developers often faced the challenge of having to define multiple similar resources, such as Lambda functions, DynamoDB tables, or SNS topics, from a single template. With the previous limitations of SAM CLI, developers had to choose between minimizing template duplication and utilizing SAM CLI for local development. The latest update addresses this issue, as SAM CLI can now process templates with CloudFormation Language Extensions in memory for local operations, while keeping the original template intact for CloudFormation deployments.

This new capability allows developers to define resources once and test them locally across all SAM CLI commands, such as sam build, sam local invoke, sam sync, sam local start-api, and sam validate. These commands will automatically expand loops and process each generated resource, enabling developers to catch errors like invalid syntax or missing dependencies before deploying to the cloud. This results in shorter iteration cycles and less time spent troubleshooting failed cloud deployments.

To utilize this new feature, developers should download or update SAM CLI to the latest version. By adding the AWS::LanguageExtensions transform to the SAM template and using Fn::ForEach, multiple resources can be generated from a single definition. Additionally, SAM CLI supports functions such as Fn::Length, Fn::ToJsonString, Fn::FindInMap with DefaultValue, and conditional DeletionPolicy and UpdateReplacePolicy attributes. For further details, developers can consult the SAM CLI developer guide and the launch blog post.