I'm playing around with porting some code from Ans...
# general
w
I'm playing around with porting some code from Ansible to Pulumi. Am I missing something or is Pulumi config flat only? It would be great to have a config hierarchy with top-level defaults but allow for overrides per environment; otherwise I'll have to repeat the default config for every environment.
👍 1
b
Hi @worried-city-86458, I'm not sure what you mean by
config hierarchy
. Personally, I would suggest using different stacks and then having shared StackReferences if you need to share values
e.g. think creating a VPC and then sharing the VPC details via StackReference across Application and Database stacks
is that what you want to see?
c
I think what he’s saying is he wants to set values in
Pulumi.yaml
And in
Pulumi.development.yaml
he can set overrides or per environment values.
b
got it!
w
Yeah, what @cool-egg-852 said.
c
The way we’ve solved this ourselves is to have a
config.ts
for all projects. This is where we put StackReferences, config logic, etc.
We NEVER use
pulumi.getConfig()
outside of this
config.ts
Copy code
import { VisibilityTypes } from '../../libraries/visibilityTypes';
import * as standard from '../../config/standard';

// Standard configs
export * from '../../config/standard';

// Per project configs
export const appDnsHost = `${standard.project}.${standard.shared.domain}`;
export const appVisibility = VisibilityTypes.internal;
export const appLabels = {
  '<http://app.kubernetes.io/name|app.kubernetes.io/name>': standard.project,
  '<http://app.kubernetes.io/component|app.kubernetes.io/component>': 'web'
};
export const docsDnsHost = `${standard.project}.docs.${standard.shared.domain}`;
export const docsLabels = {
  '<http://app.kubernetes.io/name|app.kubernetes.io/name>': standard.project,
  '<http://app.kubernetes.io/component|app.kubernetes.io/component>': 'docs'
};
`standard.ts`:
Copy code
import * as pulumi from '@pulumi/pulumi';
import vaultClient from '../libraries/vault-client';
import getSharedConfig from './index';

export const project = pulumi.getProject();
export const environment = pulumi.getStack();
export const vault = vaultClient(environment, project);
export const shared = getSharedConfig(environment);
export const support = getSharedConfig('support');
export const linio = new pulumi.Config('linio');
export const kubernetes = new pulumi.Config('kubernetes');
export const gcp = new pulumi.Config('gcp');
export const aws = new pulumi.Config('aws');
for example
By moving away from
Pulumi.stack.yaml
as much as possible we’ve removed the limitations we have there. Though we do make use of it for per environment values, including stuff like
linio:appVersion
,
linio:appMaxReplicas
, etc. So our values that are always the same go into
config.ts
. We’re still in the process of cleaning everything up as we learn the best ways to use Pulumi.
w
Thanks for the info. I'm still at first contact so trying to grok. Leaves me with the impression that Pulumi really needs to change in this area.
c
They actually have several open tickets about it. It’s on their roadmap, but it wasn’t a blocker for 1.0.