i am trying to run pulumi actions in my github wor...
# aws
f
i am trying to run pulumi actions in my github workflow, and in my pulumi files, i want to access an environment variable that i passed in from github secrets. how can i do so? i can't seem to find any guides or examples on how to do this
s
You want to reference an environment variable in your Pulumi IaC program? If so, you just use whatever the programming language uses, e.g. in Node
process.env.ENV_VAR_NAME
However, if you have a secret that is optional, you should instead use Pulumi Config (again, Node shown here):
Copy code
const config = new pulumi.Config();
const requiredSecretValue = config.requireSecret("nameOfKey");
// or
const optionalSecretValue = config.getSecret("nameOfKey");
You can set the value before running
pulumi up
or whatever via this command:
pulumi config set yourKeyName $GH_SECRET_ENV_VAR_NAME --secret