Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transform AWS::LanguageExtensions failed with: Condition layout is incorrect. Rollback requested by user #147

Open
Luchiap opened this issue Nov 1, 2023 · 3 comments

Comments

@Luchiap
Copy link

Luchiap commented Nov 1, 2023

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

@rupertbg
Copy link

rupertbg commented Mar 19, 2024

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.

@betancourtl
Copy link

Seeing the same issue on my side. Been working on a feature for a few weeks and this has been a blocker for me.

@yvele
Copy link

yvele commented Jun 7, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants