How does this aws-production env work in a typescr...
# esc
b
How does this aws-production env work in a typescript stack?

https://www.pulumi.com/docs/esc/img/pulumi_esc.png

more specifically how do you reference that provider when creating resources?
g
You’ve got a couple options in the environment definition. You can either set the
environmentVariables
to configure the default provider values, or you can set config values with
pulumiConfig
, and then use them as usual with Pulumi. https://www.pulumi.com/docs/esc/environments/#using-environments-with-pulumi-iac has a good example.
b
I would like to have multiple named providers to jump across a few accounts in the same stack. Is that possible?
g
Yeah, you’d want to set them in the
pulumiConfig
section, and then load them in your program with
pulumi.Config()
. You can pass the loaded values to your named providers.
b
ok, thanks. I’ll give that a go
must be missing something on how to get the config
Copy code
new aws.Provider(
        "named-provider", 
        new pulumi.Config("blah") as aws.ProviderArgs
    );
Copy code
pulumiConfig:
    blah:
      region: us-east-1
      accessKey: ${aws.login.accessKeyId}
      secretKey: ${aws.login.secretAccessKey}
      token: ${aws.login.sessionToken}
g
Looks like you’re not loading the config correctly. Check https://www.pulumi.com/docs/concepts/config/#code for a more detailed example of that. For this specific case it would be something like:
Copy code
const config = new pulumi.Config("blah");
const region = config.get("region");
//...
new aws.Provider("named-provider", {region, ...}
b
I’ve tried it several different ways, that way you said as well.
i’ll check out this doc to make sure i am following it as well
I finally got it by setting up the env like so
Copy code
pulumiConfig:
    blah:region: us-east-1
    blah:accessKey: ${aws.login.accessKeyId}
    blah:secretKey: ${aws.login.secretAccessKey}
    blah:token: ${aws.login.sessionToken}