https://pulumi.com logo
#general
Title
# general
n

nice-cat-91582

10/31/2019, 11:50 AM
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

better-rainbow-14549

10/31/2019, 11:55 AM
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

quiet-wolf-18467

10/31/2019, 12:34 PM
Have you tried
StackReference
?
n

nice-cat-91582

10/31/2019, 2:27 PM
@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

better-rainbow-14549

10/31/2019, 2:28 PM
i've not used it, but as i understand it you can and it will know how to do it
q

quiet-wolf-18467

10/31/2019, 2:30 PM
All you should need is the URN, right? To consume it in another resource?
w

white-balloon-205

10/31/2019, 2:49 PM
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

nice-cat-91582

11/01/2019, 1:55 PM
@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)