AWS SAM CLI adds AWS CloudFormation Language Extensions support to accelerate local serverless development
AWS SAM CLI now supports AWS CloudFormation Language Extensions, enabling you to reduce duplication in your infrastructure as code (IaC) templates while retaining the full local development workflow. This accelerates your serverless development by letting you define resources once and iterate locally without waiting for cloud deployments.
Developers frequently need to define multiple similar resources, such as Lambda functions, DynamoDB tables, or SNS topics, from a single template definition. However, developers who use SAM CLI to build, test, and deploy their serverless applications previously could not process templates that use CloudFormation Language Extensions. This required choosing between reducing template duplication and using SAM CLI for local development. Now, SAM CLI processes Language Extensions in memory for local operations while preserving your original template for CloudFormation deployment. You can define your resources once and test them locally across all SAM CLI commands, catching errors like invalid syntax or missing dependencies before deploying. This shortens your iteration cycles and reduces time spent debugging failed deployments in the cloud.
To get started, download or update SAM CLI to the latest version. Add the AWS::LanguageExtensions transform to your SAM template and use Fn::ForEach to 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 your loops and process each generated resource. You can invoke expanded functions by name, for example sam local invoke AlphaFunction. SAM CLI also supports Fn::Length, Fn::ToJsonString, Fn::FindInMap with DefaultValue, and conditional DeletionPolicy and UpdateReplacePolicy attributes.
To learn more, visit the SAM CLI developer guide and launch blog post.