How to use provider in python. Like I am trying to...
# general
g
How to use provider in python. Like I am trying to assume a role and then get the details of that role in getCallerIdentity.
Copy code
provider = aws.Provider{"privileged:,
assume_role={'role_arn': role_to_assume_arn,
'session_name': 'Test',
},region=aws_config.require('region))

Now I want to use this in my getCallerIdentity

assumedRole = aws.getCallerIdentity(provider=provider).arn. How to do this.
b
@glamorous-afternoon-59004 you’re gonna have a lot easier time if you use something with intellisense and use the python typings. I threw this together real quick, it’s untested:
Copy code
"""An AWS Python Pulumi program"""

import pulumi
import pulumi_aws as aws


provider = aws.Provider(
    "assume_role",
    aws.ProviderArgs(
        assume_role=aws.ProviderAssumeRoleArgs(
            role_arn="role.arn", session_name="something"
        ),
        region="us-west-2",
    ),
)

identity = aws.get_caller_identity(pulumi.InvokeOptions(provider=provider))
arn = identity.arn
🙌 1