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

Support nested !Select #415

Open
gmarciani opened this issue Feb 7, 2025 · 3 comments · May be fixed by #428
Open

Support nested !Select #415

gmarciani opened this issue Feb 7, 2025 · 3 comments · May be fixed by #428
Assignees

Comments

@gmarciani
Copy link

Hello,

this project is great, but I'm facing a blocker, which I need help for.

I'm using cloud-radar pointing to this commit 648bc29 (it contains a fix I needed).

The following template:

Resources:
  DummyNestedStack:
    Type: AWS::CloudFormation::Stack
    Properties:
      TemplateURL: "https://myendpoint/mytemplate.yaml"

  DummyParameter:
    Type: AWS::SSM::Parameter
    Properties:
      Type: String
      Value: !Select [2, !Split ['/', !Select [0, !Split ['.', !GetAtt [ DummyNestedStack, Outputs.DummyOutput ]]]]]

returns the following error when template.create_stack() is called:

        try:
            return items[index]
        except IndexError:
>           raise IndexError(
                "Fn::Select - List size is smaller than the Index given."
            ) from None
E           IndexError: Fn::Select - List size is smaller than the Index given.

Notice that a slightly different template succeeds the creation:

Resources:
  DummyNestedStack:
    Type: AWS::CloudFormation::Stack
    Properties:
      TemplateURL: "https://myendpoint/mytemplate.yaml"

  DummyParameter:
    Type: AWS::SSM::Parameter
    Properties:
      Type: String
      Value: !Select [ 0, !Split [ '.', !GetAtt [ DummyNestedStack, Outputs.DummyOutput ] ] ]

so I guess the problem is around nesting !Select

May you please support this use case?

Thank you,
Giacomo

@dhutchison
Copy link
Collaborator

Hi Giacomo,

I think this might be similar to what I have just commented on in #414 (comment) . You should be able to use the meta data change from #399 (which is not in a released version yet) to set for tests what you expect Outputs.DummyOutput to be like

@gmarciani
Copy link
Author

Thank you for the workaround, David. Unfortunately, changing the input template is not an option for us. I proposed a different approach here to unblock this type of scenarios. Let me know what you think about it.

@dhutchison dhutchison linked a pull request Feb 19, 2025 that will close this issue
@dhutchison
Copy link
Collaborator

Hey @gmarciani, could you take a look at #428 and see if that works with your use cases (looking at the new example test case)?

Thanks

@dhutchison dhutchison self-assigned this Feb 19, 2025
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.

2 participants