lemon-monkey-228
10/01/2021, 2:38 PMbillowy-army-68599
10/01/2021, 3:46 PMsteep-toddler-94095
10/01/2021, 5:27 PMPulumi.stackname.yaml
files and instead have all configurations as typed TS objects. The only things I put in the yaml files are secrets, default providers, and a variable that allows the TS code to determine which config object to choose (usually a var called environment
).
Since you're allowed to use the full power of your language for configs, questions like "is there a way to share config between each of the pulumi project's stacks" have a trivial solution.lemon-monkey-228
10/01/2021, 7:38 PMtypes.ts
config.ts
index.ts
Where config.ts just creates a statically typed config object that I use in the rest of my app (and I pull from pulumi config here where required)kubernetes:namespace
busy-magazine-6225
11/01/2021, 12:27 AMsteep-toddler-94095
11/01/2021, 7:08 PMprojectname:environment: <dev|staging|production>
config value
2. Have a config.ts
file that is basically a ternary
import {devConfig} from "./devConfig"
import {stagingConfig} from "./stagingConfig"
import {productionConfig} from "./productionConfig"
import * as pulumi from "@pulumi/pulumi"
const pulumiConfig = new pulumi.Config()
const config: Config = pulumiConfig.require("environment") == "dev" ?
devConfig
: pulumiConfig.require("environment") == "staging" ?
stagingConfig
: pulumiConfig.require("environment") == "production" ?
productionConfig
: {} as Config // Not the most "elegant" solution but it's simple and it works well enough
3. Then in those 3 config files I just have my separate configs. If your situation requires DRYing up a lot of configs, it's not difficult to extends this pattern to do that.busy-magazine-6225
11/02/2021, 5:32 AM