I am using Pulumi's typescript SDK to set up azure infrastructure for my project. I have been trying to get some configuration values in my index.ts
, as shown in the following code:
import * as pulumi from "@pulumi/pulumi";
const config = new pulumi.Config();
export const domain = config.require('azure:location')
Unfortunately, this code triggers the following error:
error: Missing required configuration variable 'my-project:azure:location'
please set a value using the command `pulumi config set my-project:azure:location <value>`
As an additional remark, I am using azure:location
as an example (there are also other pieces of config I need), so the obvious workaround of getting the location from somewhere else is unfortunately insufficient.
It looks like config.require
prefixes the config keys with the name of the project. While the constructor of Config
allows passing an alternative prefix, there seems to be no option to retrieve the key without prepending a prefix. Is there a workaround for this? Am I missing something? Is it a bug?
In case you need more context, here is a minimal version of the pulumi files that I used to trigger this problem:
Pulumi.yaml
:
name: my-project
runtime: nodejs
description: No description
Pulumi.dev.yaml
:
config:
azure:environment: public
azure:location: WestEurope
If you create a config object with new pulumi.Config()
then pulumi will assume you want the configuration of your project (everything that is prefixed with the project name). If you want the azure configuration, then I think you can do this with an additional config object:
const projectConfig = new pulumi.Config();
const azureConfig = new pulumi.Config("azure");
const azureLocation = azureConfig.get("location");