cfn-language-discussion
cfn-language-discussion copied to clipboard
Transform AWS::LanguageExtensions failed with: Condition layout is incorrect. Rollback requested by user
Community Note
- Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
- Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
- If you are interested in working on this issue or have submitted a pull request, please leave a comment
Tell us about the bug
What goes wrong? Please describe the issue in as much detail as possible. The following code
AWSTemplateFormatVersion: 2010-09-09
Conditions:
CreateProdAlarm: !Equals #this is true when Environment (which is a parameter) is equal to prod
- !Ref Environment
- prod
Transform: 'AWS::LanguageExtensions'
Parameters:
pRepoARNs1:
Description: ARN of SSO instance
Type: CommaDelimitedList
prepoARNs2:
Description: ARN of SSO instance
Type: CommaDelimitedList
Environment:
Description: Environment type.
Type: String
AllowedValues:
- prod
- test
Resources:
'Fn::ForEach::Topics':
- TopicName2
- !If
- CreateProdAlarm #if the condition evaluates to true, then use pRepoARNs1, if false use prepoARNs2
- !Ref pRepoARNs1
- !Ref prepoARNs2
- 'SnsTopic${TopicName2}':
Condition: CreateProdAlarm
Type: 'AWS::SNS::Topic'
Properties:
TopicName:
'Fn::Join':
- '.'
- - !Ref TopicName2
- fifo
FifoTopic: true
if deployed in cloudformation will give error:
Transform AWS::LanguageExtensions failed with: Condition layout is incorrect. Rollback requested by user.
While the virtually same template down below will work with no issues.
AWSTemplateFormatVersion: 2010-09-09
Conditions:
CreateProdAlarm: !Equals #this is true when Environment (which is a parameter) is equal to prod
- !Ref Environment
- prod
Transform: 'AWS::LanguageExtensions'
Parameters:
pRepoARNs1:
Description: ARN of SSO instance
Type: CommaDelimitedList
prepoARNs2:
Description: ARN of SSO instance
Type: CommaDelimitedList
Environment:
Description: Environment type.
Type: String
AllowedValues:
- prod
- test
Resources:
'Fn::ForEach::Topics':
- TopicName2
- !If
- CreateProdAlarm #if the condition evaluates to true, then use pRepoARNs1, if false use prepoARNs2
- !Ref pRepoARNs1
- !Ref prepoARNs2
- 'SnsTopic${TopicName2}':
Type: 'AWS::SNS::Topic'
Condition: CreateProdAlarm
Properties:
TopicName:
'Fn::Join':
- '.'
- - !Ref TopicName2
- fifo
FifoTopic: true
The difference? The line order. In the second template notice that Type: 'AWS::SNS::Topic' goes at the end. After the Condition statement of the resource.
Expected behavior
I expected the first template to work with no issues.
Observed behavior
The first template failed with error
Transform AWS::LanguageExtensions failed with: Condition layout is incorrect. Rollback requested by user.
The second template worked with no issues.
Test cases
Parameters: Use prod for Environment Use string comma delimited values for pRepoARNs1 and prepoARNs2.
Additional context
Discovered this same bug recently. You can trigger it by adding DependsOn
inside a Container Definition within a Task Definition, since it has a condition.
Seems to be a bug that's merely triggered on the word Condition
?
The problematic block that triggered the bug was:
...
ContainerDefinitions:
- Name: caddy
DependsOn:
- Condition: HEALTHY
ContainerName: app
...
Removing the DependsOn
section meant I no longer got the Transform AWS::LanguageExtensions failed with: Condition layout is incorrect. Rollback requested by user.
error.
Seeing the same issue on my side. Been working on a feature for a few weeks and this has been a blocker for me.
Using AWS::LanguageExtensions
causes errors to be obscured:
Transform: AWS::LanguageExtensions
Parameters:
Environment:
Description: Environment
Type: String
Mappings:
Environment:
production:
Something: true
Resources:
WebACL:
Type: AWS::WAFv2::WebACL
Properties:
Rules:
- Key: !If
- !FindInMap [Environment, !Ref Environment, Something] # <-- This is wrong
- A
- B
This is the obscure error message 👎
Failed to create the changeset: Waiter ChangeSetCreateComplete failed: Waiter encountered a terminal failure state: For expression "Status" we matched expected path: "FAILED" Status: FAILED. Reason: Transform AWS::LanguageExtensions failed with: Fn::If layout is incorrect
But when just removing the extension
- Transform: AWS::LanguageExtensions
The error message become much more clear 👍
An error occurred (ValidationError) when calling the CreateChangeSet operation: Template error: Fn::If requires a list argument with the first element being a condition