AWS_PROFILE environment value should be inherited from profile when executing commands from config hooks.
Quick glance at:
https://github.com/Sceptre/sceptre/blob/master/sceptre/hooks/__init__.py#L22
I'd assume you could pass stack.profile value to an AWS_PROFILE env var set in hook cmd subprocess.
When you create your stack you can assign value to profile. And that should be available as a property on stack. Can you give a code example of what you are trying to do?
Yes, for example if I have a config config/dev/us-west-2/config.yaml populated with:
profile: <profile_name>
region: <aws_region>
I'd expect hook executed in config/dev/us-west-2/<resource>.yaml populated with:
template_path: <template_name>.yaml
hooks:
after_create:
- !cmd "aws <options>"
...to execute the AWS CLI command with AWS_PROFILE and AWS_DEFAULT_REGION sub process environment variables set to config's profile and region values respectively.
hey @tahoward does this work?
template_path: <template_name>.yaml
hooks:
after_create:
- !cmd "aws --profile {{stack_group_config.profile}} <options>"
came across this issue becaus i stumbled upon the same problem as the thread opener. the workaround provided by @zaro0508 definitely works (at least for me)
Most helpful comment
hey @tahoward does this work?