Creating an SNS topic for an SES not in the default provider

ankursheel profile image Ankur Sheel Originally published at ankursheel.com on ・1 min read

Let's assume that most of our infrastructure is in ap-southeast-2 (Sydney). But, our SES is setup in us-west-2(Oregon). We also want to create SNS topics and SQS queues so that we can handle bounce notifications. Now since SES is in a different region, our SNS topics also need to be in that region. So how do we tell terraform to create the topics in the ses region?


Step 1

Create providers.

provider "aws" {
  region = "ap-southeast-2"

provider "aws" {
  region = "us-west-2"
  alias = "ses_aws"}
  • ap-southeast-2 : The default provider configuration.
  • us-west-2 : This is the additional provider configuration. Setting the Alias allows us to create more than 1 provider.

Step 2

For the resources, we want to use the us-west-2 region we specify the provider parameter and set it to be equal to the alias. If a provider parameter is not specified, it will fall back to using the provider that doesn’t have an alias.

resource "aws_sqs_queue" "example-queue" {
  name = "example_queue"

resource "aws_sns_topic" "example-topic" {
  name = "example_topic"
  provider = aws.ses_aws

In the above snippet, example-queue will be created in ap-southeast-2 but, example-topic will be created in_us-west-2_.


By creating additional providers and specifying the provider parameter in a resource, we can change its region.


markdown guide