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 !Select when the array of elements is a !Split on !Ref #414

Open
gmarciani opened this issue Feb 7, 2025 · 2 comments
Open

Support !Select when the array of elements is a !Split on !Ref #414

gmarciani opened this issue Feb 7, 2025 · 2 comments

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:
  DummyEcrImage:
    Type: AWS::ImageBuilder::Image
    Properties:
      ContainerRecipeArn: "ContainerRecipeArn"
      EnhancedImageMetadataEnabled: true
      InfrastructureConfigurationArn: "InfrastructureConfigurationArn"
      ImageTestsConfiguration:
        ImageTestsEnabled: false

  DummyParameter1:
    Type: AWS::SSM::Parameter
    Properties:
      Type: String
      Value: !Select [2, !Split ['/', !Ref DummyEcrImage]]

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.

May you please support this use case?

Thank you,
Giacomo

@dhutchison
Copy link
Collaborator

Hi Giacomo,

Yep I'll take a look at this soon. In the interim (since you are already running off a commit that hasn't been released into a version yet), if you take the latest develop branch you will be able to take advantage of the fix in #399. This will require a change to your template however.

Instead of using !Ref DummyEcrImage, use !GetAtt DummyEcrImage.Arn. These are equivalent based on the resource type documentation, but then you can use the attribute-values metadata from that linked PR.

I'll aim to add some equivalent override functionality for Ref.

@gmarciani
Copy link
Author

Hi David,

thank you for suggesting the workaround. Unfortunately it does not work for us as we cannot modify the template.
However, injecting custom replacement of attributes and tokens is a good idea to quickly unblock.

What about adding the possibility to inject those in the create_stack call w/o changing the input template?

Example for this specific case:

stack = template.create_stack(replacements={"!Ref DummyEcrImage": "arn:aws:ecr:region:012345678910:repository-namespace/repository-name"})

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

2 participants