AWS SAM CLI introduces support for AWS CloudFormation Language Extensions

AWS SAM CLI now supports AWS CloudFormation Language Extensions, enhancing local serverless development by reducing template duplication and enabling faster iteration without cloud deployment.

The AWS SAM CLI has been enhanced to support AWS CloudFormation Language Extensions, providing developers with the ability to reduce redundancy in their infrastructure as code (IaC) templates while maintaining a robust local development workflow. This new feature enables faster serverless development by allowing resources to be defined once and iterated locally without the need for immediate cloud deployments.

Previously, developers often faced challenges when defining multiple similar resources, such as Lambda functions, DynamoDB tables, or SNS topics, from a single template. Although the SAM CLI was widely used for building, testing, and deploying serverless applications, it did not support templates utilizing CloudFormation Language Extensions. This limitation forced developers to choose between minimizing template duplication and leveraging SAM CLI for local development.

With the new update, SAM CLI can now process Language Extensions in memory during local operations, while the original templates remain intact for CloudFormation deployment. This advancement allows developers to define resources once and conduct local testing across all SAM CLI commands, identifying errors such as invalid syntax or missing dependencies before deploying to the cloud. Consequently, this shortens iteration cycles and reduces the time spent troubleshooting failed cloud deployments.

To take advantage of these new capabilities, developers should download or update to the latest version of SAM CLI. By adding the AWS::LanguageExtensions transform to a SAM template and utilizing Fn::ForEach, developers can generate multiple resources from a single definition. SAM CLI commands, including sam build, sam local invoke, sam sync, sam local start-api, and sam validate, will automatically expand loops and process each generated resource. Expanded functions can be invoked by name, such as sam local invoke AlphaFunction.

Additionally, SAM CLI now supports Fn::Length, Fn::ToJsonString, Fn::FindInMap with DefaultValue, and conditional DeletionPolicy and UpdateReplacePolicy attributes. For more detailed information, developers can refer to the SAM CLI developer guide and the related launch blog post.