Using Multiple AWS Regions with Pulumi and S3 Backend
For a while now, I’ve been using Direnv to manage environment variables when I enter or leave certain directories. Since I have to work with more than one AWS account, one of the use cases for me has been populating AWS-specific environment variables, like AWS_REGION or AWS_PROFILE. This generally works really well for me, but recently I ran into a bit of a corner case involving multiple AWS regions, Pulumi, and using S3 as the Pulumi backend. In this post, I’ll share the workaround that allows this configuration to work as expected.
I describe this as a “bit of a corner case” because it only affects specific configurations (which included my configuration):
- You must be setting the
AWS_REGIONenvironment variable and not setting theaws:regionconfiguration value used by the Pulumi AWS provider. - You must be using S3 as the backend for Pulumi, and using an S3 URL of
s3://bucket-name. - You want to deploy resources into an AWS region that is different than the AWS region where the backend state bucket resides.
In my specific situation, my backend state bucket resides in the AWS us-west-2 (Oregon) region, as this offers the lowest latencies from my home office in Colorado. Continue reading