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

Intrinsic functions for the condition name in Fn::If #137

Open
miguel-aws opened this issue Aug 10, 2023 · 2 comments
Open

Intrinsic functions for the condition name in Fn::If #137

miguel-aws opened this issue Aug 10, 2023 · 2 comments

Comments

@miguel-aws
Copy link

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 your request

Re: Transform AWS::LanguageExtensions failed with: Fn::If layout is incorrect #135

We would like to request support for intrinsic functions for the condition name.

Tell us about the problem you are trying to solve. What are you trying to do, and why is it hard?

Trying to use Fn::If within Fn::ForEach to reference a condition but CloudFormation returns Transform AWS::LanguageExtensions failed with: Fn::If layout is incorrect

Docs state that Fn::If is supported within Fn::ForEach.

Are you currently working around this issue?

Hardcoding condition name.

What is the expected behavior with this new feature

Example template of ideal use case:

AWSTemplateFormatVersion: '2010-09-09'
Transform: 'AWS::LanguageExtensions'
Mappings:
  ServerTypeMapping:
    Backup:
      CreateSecondaryVolume: true
    SQL:
      CreateSecondaryVolume: false
Conditions:
  BackupCreateSecondaryVolume: !Equals [!FindInMap [ServerTypeMapping, Backup, CreateSecondaryVolume], true]
  SQLCreateSecondaryVolume: !Equals [!FindInMap [ServerTypeMapping, SQL, CreateSecondaryVolume], true]
Resources:
  'Fn::ForEach::ServerTypes':
  - ServerType
  - [Backup, SQL]
  - LaunchTemplate${ServerType}:
      Type: AWS::EC2::LaunchTemplate
      Properties:
        LaunchTemplateData:
          BlockDeviceMappings:
            !If
              - !Sub "${ServerType}CreateSecondaryVolume"
              - - DeviceName: xvdf
                  Ebs:
                    DeleteOnTermination: true
                    Encrypted: true
                    VolumeSize: 100
                    VolumeType: gp3
                    Iops: 3000
              - !Ref AWS::NoValue
        LaunchTemplateName:
          Fn::Join: ["-", [!Sub "${AWS::StackName}", !Sub "${ServerType}"]]
@skinsman
Copy link

I've hit this problem too and the AWS Support Engineer has just pointed me here. They are investigating further.
BTW I've tried some variations of syntax including replacing !Sub with !Join, with no luck.

@rshayman
Copy link

I've encountered the same issue. Surprised they have not fixed this over the last 2 months. Seems like an oversight on their part. The fact that the transformation is generating an error means it is looking at the yaml and just doesn't like what it sees. Surely this should be fairly simple to fix.

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

3 participants