Add expression to read environment variables
Opened this issue ยท 5 comments
Hello!
- Vote on this issue by adding a ๐ reaction
- If you want to implement this feature, comment to let us know (we'll work with you on design, scheduling, etc.)
Issue details
Ability to access environment variables would be very handy. Would remove the need to have a wrapper script such as this
#!/bin/bash
pulumi stack select MYSTACK
pulumi config set myvar ${ENV_MYVAR:?}
...
Thanks!
Affected area/feature
Pulumi yaml
Interesting idea. Thanks for the suggestion!
We've also considered adding envvar support to project defaults, see pulumi/pulumi#11547.
If we added that it might be enough not not require support in the YAML language directly.
We've also considered adding envvar support to project defaults, see pulumi/pulumi#11547.
If we added that it might be enough not not require support in the YAML language directly.
For my understanding, does 'envvar support' mean reading from a .env file? Would this mean we'd need to do things like adding a step to inject secrets from environment into local files in the CI/CD job? If yes, I feel it's cleaner to directly access variables in the yaml.
@jamest-pin I'm curious about your use case for injecting unique environment variables on subsequent executions. Is this something better served, perhaps, by automation API, deploying large numbers of similar stacks, or something else entirely?
For my understanding, does 'envvar support' mean reading from a .env file?
No. It means setting up something like:
config:
address:
env: TARGET_ADDRESS
The engine would fill in the "address" config value based on the value of the "TARGET_ADDRESS" envvar. So you'd need to set these config values in the Pulumi.yaml but you don't need extra .env files.