An engineer needs to manage resources in two different AWS regions from a single configuration. They define one default aws provider for eu-west-1 and a second aws provider with an alias for us-east-1. How should a resource be told to use the us-east-1 configuration?
provider "aws" {
region = "eu-west-1"
}
provider "aws" {
alias = "us"
region = "us-east-1"
}- ASet region = "us-east-1" directly inside the resource block so it overrides the default provider.
- BAdd a provider = aws.us meta-argument to the resource block to point it at the aliased provider. Correct
- CAdd a depends_on = [aws.us] entry so the resource is associated with the second provider.
- DRename the resource type to aws_us_instance so the alias is matched by the type prefix.
Why A is wrong: Region is a provider argument, not a resource argument, and setting it on the resource is rejected; this confuses where regional configuration lives.
Why B is correct: The provider meta-argument with the local name and alias, written as aws.us, is exactly how a resource selects a non-default aliased provider configuration.
Why C is wrong: depends_on expresses ordering between resources or modules, not provider selection, so it cannot bind a resource to an aliased provider.
Why D is wrong: Resource type names are fixed by the provider schema and cannot encode an alias; inventing a type prefix would simply produce an unknown resource type error.