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

How to reference single item from a list with the stack_output resolver? #735

Closed
craighurley opened this issue Jun 12, 2019 · 1 comment
Closed

Comments

@craighurley
Copy link
Contributor

Given an output in template.yaml that is a list of resource IDs like this:

Outputs:
  ResourceList:
    Value: !Sub '${ResourceA},${ResourceB},${ResourceC}'
    Export:
      Name: !Sub '${AWS::StackName}-ResourceList'

Is it possible to select a single item from that list in a sceptre stack config when using the stack_output resolver?

parameters:
  ParameterList:
    # How to select the Nth item in this list?
    - !stack_output '{{ template.yaml::ResourceList }}'

I know I could output each resource ID individually, but I'm looking to reduce the number of outputs if possible.

Thanks.

@cornerman
Copy link
Contributor

cornerman commented Jun 12, 2019

Afaik, selecting an element in a list does not work with stack_outputs.

One idea/workaround comes to my mind: Move the element select to the cloudformation template and select the right index in that template.

Example template.yaml:

Parameters:
  ParameterList:
    Type: CommaDelimitedList

  ParameterListIndex:
    Type: Number
    Default: 0

Resources:
  SomeResource:
    SomeProperty: !Select [ !Ref ParameterListIndex, !Ref ParameterList ] 

You could still use it with a single string (defaulting to using the first element in the list) or use it with a list and provide the index to select. It is a bit ugly, because it leaks details of the calling site into the template.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants