wiki:adding_config_keys_pulumi
Table of Contents
Adding config keys in Pulumi
If you want to use a config from different imported environments in a different project, you need to create a key called exactly “pulumiConfig” in your stack.
Example in project A you have a Pulumi.staging.yaml file with some configs:
environment: - default/staging - web/staging - web/en_ca config: website:service: app website:port: '3000' website:minReplicas: '1' website:maxReplicas: '5' website:memoryRequest: '512Mi' website:cpuRequest: '250m' website:wafConfig: seo: enabled: true gtMetrixEnabled: true ...
In your Pulumi infra code file (let's say index.ts
if you are using typescript), you want to reference a variable called myvar1
that you want to store in a web/staging Pulumi environment, you need to set it like this:
pulumi env set icg/web/staging pulumiConfig.myvar1 "myvalueblabla" --secret
Otherwise you will get an error similar to
error: Missing required configuration variable 'website:myvar1' please set a value using the command `pulumi config set --secret website:myvar1 <value>`
because its actually loooking for it in above local file under website key instead of in one of the environments.
Example index.ts
:
... const config = new pulumi.Config(); ... const var1 = config.requireSecret("myvar1") ...
Tested on
- Pulumi v3.154.0 (03.2025.)
See also
References
wiki/adding_config_keys_pulumi.txt · Last modified: 2025/03/21 14:15 by antisa