AWS::LanguageExtensions transform - AWS CloudFormation

AWS::LanguageExtensions transform

This topic describes how to use the AWS::LanguageExtensions transform to enable additional functions and capabilities that are not available by default.

The AWS::LanguageExtensions is a CloudFormation macro that, when referenced in your stack template, updates any intrinsic function defined by the transform to its resolved value within the template when you create or update a stack using a change set.

By including this transform in your CloudFormation template, you can access additional features, such as Fn::ForEach, which allows for more advanced operations like iteration. You can also use intrinsic functions in places where they're typically not allowed, such as in Ref and Fn::GetAtt functions.

Usage

To use the AWS::LanguageExtensions transform, you must declare it at the top level of your CloudFormation template. You can't use AWS::LanguageExtensions as a transform embedded in any other template section.

The declaration must use the literal string AWS::LanguageExtensions as its value. You can't use a parameter or function to specify a transform value.

Syntax

To declare this transform in your CloudFormation template, use the following syntax:

JSON

{ "Transform":"AWS::LanguageExtensions", "Resources":{ ... } }

YAML

Transform: AWS::LanguageExtensions Resources: ...

The AWS::LanguageExtensions transform is a standalone declaration with no additional parameters.

Support for additional functions

The AWS::LanguageExtensions transform supports the following additional functions:

Considerations

When using the AWS::LanguageExtensions transform, keep the following considerations in mind:

  • When you update a stack using a different parameter value, don't use the Use existing template option in the CloudFormation console, or the equivalent command line option --use-previous-template, if the original template contains a transform. Instead, use the original, untransformed template when you update the stack. This will ensure the stack updates correctly with the new parameter values.

  • Short-form YAML syntax isn't supported within a template for intrinsic functions that are only available in the AWS::LanguageExtensions transform. Use explicit references to these functions. For example, use Fn::Length instead of !Length.

  • The AWS SAM CLI currently doesn't support the Fn::ForEach intrinsic function of the AWS::LanguageExtensions transform.

  • If you're using multiple transforms, use a list format. If you're using custom macros, place AWS-provided transforms after your custom macros. If you're using both the AWS::LanguageExtensions and AWS::Serverless transforms, the AWS::LanguageExtensions transform must come before the AWS::Serverless transform in the list.

  • Functions and attributes provided by the AWS::LanguageExtensions transform are only supported in the Resources, Conditions, and Outputs sections of your template.

Examples

The following examples show how to use the AWS::LanguageExtensions transform to use the Fn::Length intrinsic function, defined by the transform.

JSON

{ "AWSTemplateFormatVersion": "2010-09-09", "Transform": "AWS::LanguageExtensions", "Parameters": { "QueueList": { "Type": "CommaDelimitedList" }, "QueueNameParam": { "Description": "Name for your SQS queue", "Type": "String" } }, "Resources": { "Queue": { "Type": "AWS::SQS::Queue", "Properties": { "QueueName": { "Ref": "QueueNameParam" }, "DelaySeconds": { "Fn::Length": { "Ref": "QueueList" } } } } } }

YAML

AWSTemplateFormatVersion: 2010-09-09 Transform: 'AWS::LanguageExtensions' Parameters: QueueList: Type: CommaDelimitedList QueueNameParam: Description: Name for your SQS queue Type: String Resources: Queue: Type: AWS::SQS::Queue Properties: QueueName: !Ref QueueNameParam DelaySeconds: 'Fn::Length': !Ref QueueList

For more examples, see the following topics.

For general information about using macros, see Perform custom processing on CloudFormation templates with template macros in the AWS CloudFormation User Guide.