Using env vars or depending on the pulumi config isn’t viable because a user may be using an explicitly created provider in their code
c
colossal-plastic-46140
02/26/2020, 11:52 PM
yep, understood I know I asked a similar question earlier this week and wanted to save you from searching if it were to help
🙏 1
w
white-balloon-205
02/27/2020, 12:06 AM
You can use
aws.getCallerIdentity
to get the Account ID and the ARN and user id. That may be enough to infer these things. It's the ultimate identity that is actually being used, but doesn't have all the details of how that identity was determined.
Alternatively,
aws.config.profile
should give you the profile that was configured as input.
b
busy-umbrella-36067
02/27/2020, 12:24 AM
@white-balloon-205 I’m looking for the configured value, we need it to create an ouput that includes the AWS profile name as an arg for a cli utility.
Unfortunately
aws.config
doesn’t work in the below example, profile comes up as undefined.
Copy code
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
class Test extends pulumi.ComponentResource {
readonly bucket: aws.s3.Bucket
constructor(opts?: pulumi.ComponentResourceOptions) {
super('test', 'test', opts)
console.log(aws.config.profile)
this.bucket = new aws.s3.Bucket('test')
}
}
// Create an AWS resource (S3 Bucket)
const provider = new aws.Provider('test', { profile: 'stage'})
const bucket = new Test({provider: provider})
w
white-balloon-205
02/27/2020, 1:10 AM
Ahh - yes - I believe
pulumi.config
only works for the default provider configuration - there is not currently a way to get the equivalent for a
new aws.Provider
instance. Pretty sure there is an issue tracking adding the ability to retrieve this.
No matter how you like to participate in developer communities, Pulumi wants to meet you there. If you want to meet other Pulumi users to share use-cases and best practices, contribute code or documentation, see us at an event, or just tell a story about something cool you did with Pulumi, you are part of our community.