TF-Associate-004 - Terraform fundamentals (11% of the exam) - Section 2c

Write Terraform configuration using multiple providers.

Multiple provider configurations are distinguished with alias, and a resource selects a non-default configuration through its provider meta-argument. Candidates should predict which provider configuration a resource uses given aliases, and know when a second configuration is needed (for example two regions).

provider aliasprovider meta-argumentdefault and additional provider configurationsmulti-region configuration

Practice question for this objective

Free sampleTerraform fundamentalseasy

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.
A resource selects a non-default provider configuration through the provider meta-argument referencing the provider local name and its alias. When multiple configurations of the same provider exist, one is default and the others carry an alias; a resource opts in to an aliased configuration by setting the provider meta-argument to localname.alias, here aws.us, rather than by any resource-level region setting.

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.

See more TF-Associate-004 practice questions, answers explained.

Exam traps in Terraform fundamentals

Answers that look right on this material and are not. Each one is a distractor from a different question in the TF-Associate-004 bank for this domain.

  • Set provider = "aws.sydney" as a quoted string inside the resource block so the alias resolves.

    Why it is wrong: The provider meta-argument takes a bare reference expression, not a quoted string, so wrapping it in quotes is a syntax error even though the alias name is right.

  • Add for_each to the existing aws provider block so a single block yields one configuration per region in a map.

    Why it is wrong: Provider blocks do not accept for_each to fan out into per-region configurations; multiple regions are expressed as separate aliased blocks, so this is not valid provider syntax.

  • Aliases rename the provider so that Terraform downloads a separate plugin binary for each region and isolates their state.

    Why it is wrong: Tempting because aliases feel like separate providers, but all aliased configurations share one plugin and one state; aliasing does not fetch extra binaries.

More in this domain

Back to all Terraform fundamentals objectives, or the TF-Associate-004 cert hub.

Examworthy is not affiliated with or endorsed by HashiCorp. Original, blueprint-aligned practice material only.