Hi, with the v2 release, i’m having trouble constr...
# typescript
g
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
You should be able to use
pulumi.interpolate
for this use case
g
that still returns a
pulumi.Output<string>
the type signature for the field is
string[]
f
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
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
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
yeah i might have to do that i guess
thank you