https://pulumi.com logo
#typescript
Title
# typescript
g

gorgeous-animal-95046

04/28/2020, 8:31 PM
Hi, with the v2 release, i’m having trouble constructing aws policy documents based on a dynamic account id.
aws.getCallerIdentity
now returns a promise. the problem i’m having is i can’t pass the account id returned from that into a
aws.iam.getPolicyDocument
because it’s inputs are all
string
. Specifically this is for a principal identifier on an assume role policy. My old code used to be `identifiers: [
arn:aws:iam::${accountNumber}:role/terraform-eks-k8s-node
]`
f

faint-table-42725

04/28/2020, 8:53 PM
You should be able to use
pulumi.interpolate
for this use case
g

gorgeous-animal-95046

04/28/2020, 8:55 PM
that still returns a
pulumi.Output<string>
the type signature for the field is
string[]
f

freezing-flag-53289

04/28/2020, 9:10 PM
This is what I ended up doing during the upgrade to v2.
Copy code
const accountId = pulumi.output(aws.getCallerIdentity()).accountId;

accountId.apply(id => {
  do your stuff
}
g

gorgeous-animal-95046

04/28/2020, 9:20 PM
that could work, but i’m using this in a function that returns values and i’d really rather not make it all async like that
actually it might. let me chew on that for a while
yeah it doesn’t work, because i need to return a list of
aws.iam.Role
objects 😕
f

faint-table-42725

04/28/2020, 9:36 PM
Ah, I missed the other part where you are going to pass that further into another
get
I think the easiest way is to promisify all the way through
One thing that can help here is modify your entrypoint to be async at the top level like shown here: https://www.pulumi.com/docs/intro/languages/javascript/#entrypoint
Then you can write async/await throughout the rest of your code
g

gorgeous-animal-95046

04/28/2020, 9:40 PM
yeah i might have to do that i guess
thank you