You have two AWS providers configured with aliases us_east and us_west. Which resource block correctly uses the us_west provider?
provider "aws" { region = "us-east-1" alias = "us_east" } provider "aws" { region = "us-west-2" alias = "us_west" } resource "aws_s3_bucket" "example" { bucket = "my-bucket" provider = aws.us_west }
Use the exact alias name defined in the provider block.
The provider alias must match exactly. aws.us_west references the provider with alias us_west. Other options either use wrong alias or no alias.
You want to deploy resources in two AWS regions: us-east-1 and eu-west-1. Which provider configuration setup is correct to support this?
Only one provider block can be default (no alias). Others must have aliases.
Terraform allows one default provider without alias. Additional providers must have aliases. Option A correctly sets one default and one aliased provider.
Given two AWS providers configured with aliases, what happens if a resource specifies a provider without alias but multiple providers exist?
provider "aws" { region = "us-east-1" alias = "east" } provider "aws" { region = "us-west-2" alias = "west" } resource "aws_instance" "example" { ami = "ami-123456" instance_type = "t2.micro" provider = aws }
Terraform requires a default provider if no alias is specified in resource.
When all providers have aliases, there is no default provider. Specifying provider = aws without alias causes Terraform to error.
You configure multiple providers with different credentials for different AWS accounts. What is a key security best practice?
Think about how to keep credentials safe and avoid exposure.
Best practice is to avoid hardcoding credentials and use environment variables or secret managers to keep them secure.
You have a root module with two AWS providers configured: one default and one with alias europe. You call a child module that creates an S3 bucket. The child module does not specify a provider. Which provider will the child module use?
provider "aws" { region = "us-east-1" } provider "aws" { region = "eu-west-1" alias = "europe" } module "storage" { source = "./modules/s3" }
Modules inherit the default provider unless explicitly passed an alias.
Child modules use the default provider from the root module if no provider is specified or passed explicitly.