I'm not quite sure what to pass into `iam.Role.get...
# general
n
I'm not quite sure what to pass into
iam.Role.get()
in order to actually get the role from a different policy. I have the ARN/URN/Name/Id all easily available, it's just a matter of what to do with those. Anyone know the right way to make that work?
b
generally those class.get() methods take a provider ID
so in azure you'd pass the full azure resource id e.g. /subscription/{blah}/resourceGroup/blah/type/name
assumably there's a similar id for aws
q
Have you tried
StackReference
?
n
@quiet-wolf-18467 yeah, that just gets me the outputs, though... which are strings (like ARN/URN/Etc). Trying to map that back into an actual
IAM.Role
Unless I can output a whole resource object.... I assumed I could not
b
i've not used it, but as i understand it you can and it will know how to do it
q
All you should need is the URN, right? To consume it in another resource?
w
aws.iam.Role.get
takes two parameters. The first is the logical name you want to use to track this resource in their stack. The second is the cloud provider
id
which is just the “friendly name” of the Role in AWS. https://www.pulumi.com/docs/reference/pkg/nodejs/pulumi/aws/iam/#Role You are right that if you need a true instance of
Role
in your other stack, you should export the id from one stack, use StackReference to retrieve it in another and
get
to populate a full Role instance from it.
n
@white-balloon-205 that got it working, thank you. Followup question, do you know if there's any way to speed up StackReferences when doing
preview
or
up
? It seems to take a long time to grab the IAM Role (I assume it is making API calls to AWS/Pulumi)