https://pulumi.com logo
Title
r

ripe-shampoo-80285

07/30/2021, 4:38 PM
I have a need to provision resources in multiple aws accounts. How do we do this in pulumi? Any examples?
b

billowy-army-68599

07/30/2021, 4:56 PM
you can set providers on resources, and inside that provider you can specify the AWS account. I don't think we have an example to hand, but you can see examples of using a provider here: https://github.com/pulumi/examples/search?q=aws.Provider
r

ripe-shampoo-80285

07/30/2021, 5:07 PM
Thanks @billowy-army-68599. Will take a look.
t

tall-beard-99429

07/30/2021, 5:19 PM
@ripe-shampoo-80285 Something like this:
new aws.Provider('CI Provider', {
    region: aws.Region.EUNorth1,
    assumeRole: {
        roleArn: pulumi.interpolate`arn:aws:iam::${stack.getOutput('ci_account').apply(output => output.id)}:role/OrganizationAccountAccessRole`
    }
});
Where the
ci_account
bit is your account ID from AWS
Then you can use that provider line like this:
new aws.ec2.Vpc("Jobilla Network", {
    cidrBlock: "10.0.0.0/16",
    enableDnsSupport: true,
    enableDnsHostnames: true,
}, {
    provider: provider,
});
Where
provider
is the provider above
r

ripe-shampoo-80285

07/30/2021, 5:46 PM
Thanks @tall-beard-99429!
t

tall-beard-99429

07/30/2021, 5:52 PM
no problem, let me know if you need a hand, its something i've done recently