Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Reference stack_name from stack config #624

Closed
zaro0508 opened this issue Feb 5, 2019 · 3 comments
Closed

Reference stack_name from stack config #624

zaro0508 opened this issue Feb 5, 2019 · 3 comments

Comments

@zaro0508
Copy link
Contributor

zaro0508 commented Feb 5, 2019

I have a jinja template and would like to pass the stack_name to the template. The only way to do this is to pass it in with a sceptre_user_data key. Since it's already defined in each stack config it would be nice to be able to reference the stack_name instead of having to define multiple times. This also applies to passing it to any plugin like hooks and parameters.

This works template/test/noop.yaml:

template_path: mystack.j2
stack_name: noop
sceptre_user_data:
  stackname: noop 
parameters:
  stackname: noop
hooks
  after_create:
    -  !cmd "python noop.py"  

However this would be much better template/test/noop.yaml

template_path: mystack.j2
stack_name: noop
sceptre_user_data:
  stackname: {{ stack_config.stack_name }} 
parameters:
  stackname: {{ stack_config.stack_name }}
hooks
  after_create:
    -  !cmd "python {{ stack_config.stack_name }}.py"  
@zaro0508
Copy link
Contributor Author

zaro0508 commented Feb 6, 2019

related to issue #355

@zaro0508
Copy link
Contributor Author

zaro0508 commented Feb 7, 2019

My workaround for this issue is to create the sceptre-identity-resolver

@zaro0508
Copy link
Contributor Author

I didn't realize an important fact that all sceptre files are read in as jinja templates which means an even better workaround for this is to just use jinja

{% set StackName = "noop" %}
template_path: ec2.yaml
stack_name: {{ StackName }}
parameters:
  StackName: {{ StackName }}
sceptre_user_data:
  StackName: {{ StackName }}
hooks
  after_create:
    -  !cmd "python {{ StackName }}.py" 

@Sceptre Sceptre locked and limited conversation to collaborators Apr 26, 2021

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Projects
None yet
Development

No branches or pull requests

1 participant