hey all. I'm relatively new to pulumi, and I've ju...
# general
a
hey all. I'm relatively new to pulumi, and I've just run into the issues around regions in AWS and using custom providers. I'm wondering if there's an easy way to get a custom provider to use all the configs defined for a default provider, like
aws:profile
or whatnot. Mostly what I'm doing is just instantiating custom providers to do multi-region work, and I want all the rest of the config the same, but when I do a
pulumi.Provider("aws", region="regionname")
in python, the custom provider seems to be missing all that config.
I was hoping I could just do a
pulumi.get(<namespace>)
and get a dict back of all the namespace'd config for the provider, then merge that with my custom fields into the provider args, but that doesn't work the way I'd hoped. I don't really see another function that'd do the same thing.
I imagine I'm missing something obvious that'll just do "provider for a different region but otherwise all the same config", so I'm hoping one of y'all will point that out to me. 😉
l
Yes, you can get the contents of the aws config namespace and use that if you want. You can merge it with hardcoded values, or values from other namespaces (aws-us-west-2. maybe?). You may want to set this if that is what you want:
Copy code
pulumi:disable-default-providers:
  - aws
What isn't working the way you'd hoped?
a
well I guess I'm just confused. I'm unsure how to get all the values from the
aws
namespace and pass them to
aws.Provider()
other than doing them one at a time. what's the function to return all config values under that namespace?
l
Nothing wrong with getting them one at a time and putting them into an object to pass around. There's only a few. Alternatively you could drop the aws namespace and define your own namespace with the same values, in an object. You can load objects from config.
a
well there's over 30 config vars that can be potentially modified according to the docs, and they could be added or changed with provider updates. I don't want my codebase to have to track all potential upstream config vars as they change and evolve. defining my own namespace doesn't help me avoid that problem either.
from your suggestions, it sounds like there isn't actually an easy way to just apply the default provider configs to a custom provider, which is pretty unfortunate.
l
Do you really want to allow your stacks to provide all those values? I wouldn't.
But yes, you can't "intercept" the default constructor.
a
what I want is for my stacks to be able to set anything in the documented configs for the provider and have them work as expected. it's not really that crazy. 🤷‍♀️
l
It is to me 🙂 AWS allows a lot of config that I prohibit in my org. A lot of it does not follow our required practices.
a
ok, so that's an unusual problem specific to you I guess. most languages and libraries understand the idea of default config values that get overridden, it seems very odd that pulumi providers don't have an easy way to do that, since it's been pretty standard since I started working in software in the 90s.
l
I'm not providing a language. I'm providing a way to create infrastructure in my accounts. I want to control that. I don't want the root account to be allowed to do that. I don't want long-life creds used. I prohibit these things.
So I don't need to support those config options.
a
sure. that's your use case. but can you see that many, perhaps even most, folks need a use case where they can just define some defaults and have them stay active even when using a custom provider to work cross-region? it's not exactly an uncommon scenario.
l
You're the first to request it 🙂
a
wild. I've done this with tons of different IAC tools across a bunch of different orgs, and it was rarely me who implemented it. Salt made this kind of thing super trivial, and had a whole hierarchy of config priority and stuff that worked really well.
in any case, what you're saying is that I have no choice but to track the upstream provider variables as they evolve and change and get updated. I guess I'll work that out as much as we need for now, but that's pretty rough.
l
Yea, I think so? However it probably won't be too much work. I don't think the provider has changed much since OIDC was added. That's about 20 months ago, maybe?
It changes very slowly.
a
that's a bonus for sure. appreciate you confirming I wasn't missing something obvious, any way.
hmmmm. seems like there's already a ticket for this kind of functionality, so I'm not the only one who wants it. I'll vote on that and hopefully it'll get some traction so I can remove all this boilerplate later. 😉 https://github.com/pulumi/pulumi/issues/12176