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

Implement sensible default values for placeholders in Template #384

Open
dhutchison opened this issue Nov 21, 2024 · 0 comments · May be fixed by #397
Open

Implement sensible default values for placeholders in Template #384

dhutchison opened this issue Nov 21, 2024 · 0 comments · May be fixed by #397

Comments

@dhutchison
Copy link
Collaborator

I got caught out today with the error IndexError: Fn::Select - List size is smaller than the Index given.

This was because my template was trying to add a "uniqifier" to some resource names based on the StackId (part of a Service Catalog product) using this:

  rBastionSSMIAMRole: 
    Type: AWS::IAM::Role
    Properties: 
      RoleName: !Sub 
          - '${pAccountShortName}-ssm-bastion-${uniqifier}-role'
          - # AWS::StackId has this format
            # arn:aws:cloudformation:us-west-2:123456789012:stack/teststack/51af3dc0-da77-11e4-872e-1234567db123
            # Trying to capture the last piece after the '-'
            # As stack name could contain "-"s, split on the "/"s first
            uniqifier: !Select [ 4, !Split [ "-",  !Select [ 2, !Split [ "/", !Ref AWS::StackId ] ] ] ]

By default StackId should have a non-blank value.

Workaround is to set this manually in test case

# Set a non-blank value for the StackId
Template.StackId = "arn:aws:cloudformation:us-west-2:123456789012:stack/teststack/51af3dc0-da77-11e4-872e-1234567db123"
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

Successfully merging a pull request may close this issue.

1 participant