https://pulumi.com logo
#general
Title
# general
w

worried-church-46455

08/17/2021, 1:40 AM
Config File Format 👋 , I think it’d be nice to have a configuration format looks like this: to me it’s a bit easier to see the differences among the resources in different stacks, since the config file can get pretty big.
Copy code
config:
  aws:rds:Instance:
    engine: "mysql"
    instance_type:
      dev: "db.t2.micro"
      prod: "db.t2.xlarge"
I can do some codegen myself to regroup my new configuration format and separate it into .dev.yml & .prod.yml. Do you guys see any obvious cons with this step up? Is it possible to customize this behavior with in pulumi?
l

little-cartoon-10569

08/17/2021, 1:52 AM
You want all stacks to be configured via a single file?
That won't work well in per-user stack setup. Teams where everyone has their own stack.
w

worried-church-46455

08/17/2021, 2:16 AM
That won’t work well in per-user stack setup. Teams where everyone has their own stack.
Ah good point! That sounds like a pretty common use case.
You want all stacks to be configured via a single file?
Yes. For my use case though, there will only be 3 stacks at most: dev, staging, and prod. With 3 .yml files, it’s a bit hard to see what are the differences among those envs.
l

little-cartoon-10569

08/17/2021, 2:20 AM
Maybe you could put it all in a new .yaml, and write a script that creates your Pulumi.yaml and all stack files from it? Then you could remove Pulumi.yaml and Pulumi.<stack>.yaml from source control and replace them with your multistack.yaml file...?
w

worried-church-46455

08/17/2021, 2:52 AM
Maybe you could put it all in a new .yaml, and write a script that creates your Pulumi.yaml and all stack files from it?
Yep! I think I might do that. It should worth the effort. Do you see any potentials for pulumi to: 1. pulumi itself supports different config formats 2. it accepts some plugin or some-sort to allow user customize their configurations?
l

little-cartoon-10569

08/17/2021, 3:15 AM
Not me personally. But everyone has their specific needs and it might suit others.
👍 1
b

brave-planet-10645

08/17/2021, 7:38 AM
Don't forget that you're using a programming language, so technically your config can look like whatever you want. For example, if you're using typescript you could have something like:
Copy code
export const config = {
    rdsInstance: {
        engine: "mysql",
        instanceType: {
            dev: "db.t2.micro",
            prod: "db.t2.xlarge"
        }
    }
};
You can also include some stack config in there too, so you can include secrets in it:
Copy code
import * as pulumi from "@pulumi/pulumi";

const pulumiconfig = new pulumi.Config();

export const config = {
    rdsInstance: {
        engine: "mysql",
        instanceType: {
            dev: "db.t2.micro",
            prod: "db.t2.xlarge"
        },
        username: "root",
        password: pulumiconfig.getSecret("mysqlpassword")
    }
};
w

worried-church-46455

08/18/2021, 12:25 AM
Thank you! Defining it directly in the source code is a very interesting direction! Thanks for pointing that out 🙂
👍 1