limited-rainbow-51650
11/09/2021, 7:30 PMconfig:
<your-project-name>:<key>: <value>
Providers often look up their config with another "project-name", e.g.:
config:
aws:region: eu-west-1
<your-project-name>:<key>: <value>
If I create an abstraction in a reusable library, I could for example use a separate project key to store all the config for my component.
config:
aws:region: eu-west-1
<your-project-name>:<key>: <value>
<my-component-name>:<key1>: <value1>
<my-component-name>:<key2>: <value2>
Do other Pulumi developers use this ability for such use cases? Would this be a good pattern to use, or rather an anti-pattern?little-cartoon-10569
11/09/2021, 7:53 PMlimited-rainbow-51650
11/09/2021, 8:05 PMgetComponentConfig()
which in its implementation would e.g. call pulumi.getConfig('my-component-name').require(...)
(or requireObject
)little-cartoon-10569
11/09/2021, 8:09 PMpulumi.getConfig()
at all, because you're not in a Pulumi runtime.limited-rainbow-51650
11/09/2021, 8:11 PMpulumi.getConfig()
wouldn't be inside my component implementation, this would be in the getComponentConfig
function which is next to my component class.little-cartoon-10569
11/09/2021, 8:11 PMgetComponentConfig()
to inject values?limited-rainbow-51650
11/09/2021, 8:14 PMconfig = {
key: value
}
component = new package.ComponentResource('name', config)
What I am hinting at is this:
config = package.getComponentConfig() // <- only this reads from stack config with a separate key
component = new package.ComponentResource('name', config)
So you see that package
exposes two items: the config helper function and my component resource, which still is decoupled from how config is passed. Actually, it exposes 3 items: I missed the args
interface type, e.g. ComponentArgs
aws
top level keylittle-cartoon-10569
11/09/2021, 8:22 PMgetComponentConfig()
, and the program needs the same value for itself (independent of the component), then you really need the same value to be defined twice in your config...limited-rainbow-51650
11/09/2021, 8:26 PMlittle-cartoon-10569
11/09/2021, 8:33 PMworried-city-86458
11/09/2021, 10:44 PM