https://pulumi.com logo
Title
h

happy-window-22449

05/19/2021, 3:01 PM
I have a multiple region project in AWS - but Pulumi seems to only take one region via config. Does this mean I need a different stack for each region? So dev.us-east-1, dev.us-west-1, prod.us-east-1, etc etc ?
b

billowy-army-68599

05/19/2021, 3:07 PM
you can either set it on the stack:
pulumi config set aws:region us-west-2
or you can create providers which you pass to resources: https://www.pulumi.com/docs/reference/pkg/aws/provider/#region_python
different stacks for each region is common
h

happy-window-22449

05/19/2021, 3:10 PM
OK, thanks! i couldn’t find any examples that dealt with this so I didn’t know
b

billowy-army-68599

05/19/2021, 3:14 PM
h

happy-window-22449

05/19/2021, 3:36 PM
ah perfect, i’m using Python but I should be able to do the same there
b

best-nest-62071

05/21/2021, 8:23 PM
Here's a very basic python example.
import pulumi
import pulumi_aws as aws

regs = aws.get_regions()

for i in regs.names:
    new_provider = aws.Provider(f'provider-{i}',
        region=i
    )

    vpc = aws.ec2.DefaultVpc(f'default-vpc-{i}',
        opts=pulumi.ResourceOptions(provider=new_provider)
    )