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

AWS::LanguageExtensions transform seems to break conditions with Fn::Select #159

Open
RhubarbSin opened this issue Jul 12, 2024 · 3 comments

Comments

@RhubarbSin
Copy link

RhubarbSin commented Jul 12, 2024

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

When trying to create a resource only when the value of a string parameter is not an empty string (using a condition that evaluates to False), CloudFormation appears to try to evaluate the use of Fn::Select in the specification of one of the properties of the declared resource, which would not be created because of the use of the condition in the resource declaration.

Expected behavior

The resource that is declared with the condition associated with it is not created.

Observed behavior

The attempt to create a CloudFormation change set reports status FAILED with the following status reason:

Transform AWS::LanguageExtensions failed with: Fn::Select cannot select nonexistent value at index 1

Test cases

---
AWSTemplateFormatVersion: 2010-09-09

Transform: AWS::LanguageExtensions

Parameters:

  DomainName:
    Type: String
    Default: example.xyz

  Fqdn:
    Type: String
    Default: ''

Conditions:

  CreateRecordSet: !Not [!Equals [!Ref Fqdn, '']]

Resources:

  HostedZone:
    Type: AWS::Route53::HostedZone
    Properties:
      Name: !Ref DomainName

  RecordSet:
    Type: AWS::Route53::RecordSet
    Condition: CreateRecordSet
    Properties:
      Type: CNAME
      TTL: 60
      HostedZoneId: !Ref HostedZone
      Name: !Ref Fqdn
      ResourceRecords:
        - !Sub
          - ${SubDomain}.${TopLevelDomain}.
          - SubDomain: !Select [1, !Split ['.', !Ref Fqdn]]
            TopLevelDomain: !Select [2, !Split ['.', !Ref Fqdn]]

Additional context

  • Creation of the change set succeeds if the declaration of the AWS::LanguageExtensions transform is removed from the template.

  • The behavior seems to be very similar to that reported in issue #120.

  • A work-around can be implemented by re-using the condition with Fn::If and substituting unused place-holder values for the property of the resource that is not created as desired because of the use of the condition associated with the resource declaration.

@tgolly
Copy link

tgolly commented Jul 30, 2024

I'm getting this as well, I'm trying to refactor some code to use the awesome new ForEach intrinsic function, however enabling the AWS::LanguageExtensions transform seems to break previously working code with no other changes.

It looks like the transform runs some sort of pre-processor that ignores Condition: statements, so it evaluates resources that previously were ignored by the Condition evaluating to False.

And any Select functions in those statements are now being evaluated, when they shouldn't be.

@daghaian
Copy link

I'd like to comment that after spending a full day with trying to debug our first use of the Transform LanguageExtension, it also broke our existing stack. I was originally thinking it was the foreach we added but it looks like something else being triggered by just having the reference to the extension.

@wheel5up
Copy link

wheel5up commented Nov 17, 2024

Same behavior. I've reduced my template down to a minimum. I can create several object including AWS::IAM::Role, AWS::Logs::LogGroup, and AWS::ApiGateway::Method WITH the extension enabled. As soon as I add the simplest AWS::StepFunctions::StateMachine I receive the error

Fragment returned by transform AWS::LanguageExtensions is null

I can not create a valid template with AWS::LanguageExtensions and AWS::StepFunctions::StateMachine

Simple yaml fragment to reproduce

AWSTemplateFormatVersion: "2010-09-09"
Transform: 'AWS::LanguageExtensions'

Resources:

mystepfunction:
Type: 'AWS::StepFunctions::StateMachine'
Properties:
RoleArn: !GetAtt createJiraConnectionStepFunctionRole.Arn
StateMachineName: mystepfunction
StateMachineType: 'EXPRESS'
DefinitionString: |-
{
"Comment": "A description of my state machine",
"StartAt": "Pass",
"States": {
"Pass": {
"Type": "Pass",
"End": true
}
}
}

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