https://pulumi.com logo
Title
o

orange-kite-80991

11/28/2021, 9:09 PM
What's the correct syntactic sugar for accessing Config variables that are not prefixed with <stackname>? I have the following config file contents:
config:
  mystackname:SCHEMA:
    secure: qqqqq
  mystackname:SCHEMA_CONFIG: https://
  azure-native:location: westus2
  azure-native:subscriptionId: aaaaaa
  azure-native:tenantId: bbbbbb
  fluid:password:
    secure: ccccccc
  fluid:username: abc*<http://xyz.com|xyz.com>
A simple require() or get() can access the mystackname: prefixed values. What's the syntax for accessing the other variables?
const config = new pulumi.Config()
const schema = config.require( 'SCHEMA' )

// the following don't work
const location = config.require( 'location' )
const location = config.require( 'azure-native:location' )
const location = config.require( 'azure-native.location' )
l

little-cartoon-10569

11/28/2021, 9:11 PM
You create a config instance per prefix.
const location = new pulumi.Config('azure-native").require("location");
o

orange-kite-80991

11/28/2021, 9:28 PM
thx!
A sample like that could be added to the Pulumi Config wiki page.
l

little-cartoon-10569

11/28/2021, 9:57 PM
Yes, it's only in there as a few sentences, and in a specific context that does not seem to apply (but actually does):
If you are writing code that will be imported into a broader project, such as your own library of components, you should pass your library’s name to the constructor. This string is used as a namespace for all configuration keys. Similarly, if you want to access the config of another library, such as the config for a standard library like aws, you should also pass the library’s name to the constructor.
o

orange-kite-80991

11/28/2021, 11:18 PM
Ah. It's a Typescript-ism. Unfortunately I'm a Python programmer coming into a Typescript+Pulumi project. Never sure which patterns might be standards from one or the other language.
I know what namespacing looks like in Python but not so much in TS.
l

little-cartoon-10569

11/28/2021, 11:33 PM
This isn't TS namespacing, it's specific to pulumi.Config's implementation.
Which is why I say that this is a specific context (a library has a namespace). But in fact there's no need for it to be a library: if you want configuration for your firewall and for your ACLs in the same config file, you can add a call to
new pulumi.Config('acl')
and
new pulumi.Config('firewall')
, and it'll get values from those namespaces. Nothing to do with libraries...
The docs are unnecessarily-specific.
o

orange-kite-80991

11/28/2021, 11:43 PM
Thanks. And I recognize the challenge of maintaining language generic documentation while also trying to support language & context specific queries from newbies like me. Always appreciate your help.
👍 1