nerdexam
HashiCorp

TA-002-P · Question #264

Your team has started using terraform OSS in a big way , and now wants to deploy multi region deployments (DR) in aws using the same terraform files . You want to deploy the same infra (VPC,EC2 ...)…

The correct answer is C. Use provider alias functionality , and add another provider for us-west region . While. You can optionally define multiple configurations for the same provider, and select which one to use on a per-resource or per-module basis. The primary reason for this is to support multiple regions for a cloud platform; other examples include targeting multiple Docker hosts…

Read, generate, and modify configuration

Question

Your team has started using terraform OSS in a big way , and now wants to deploy multi region deployments (DR) in aws using the same terraform files . You want to deploy the same infra (VPC,EC2 ...) in both us-east-1 ,and us-west-2 using the same script , and then peer the VPCs across both the regions to enable DR traffic. But , when you run your script , all resources are getting created in only the default provider region. What should you do? Your provider setting is as below -# The default provider configuration provider "aws" { region = "us-east-1" }

Options

  • ANo way to enable this via a single script . Write 2 different scripts with different default
  • BCreate a list of regions , and then use a for-each to iterate over the regions , and create
  • CUse provider alias functionality , and add another provider for us-west region . While
  • DManually create the DR region , once the Primary has been created , since you are using

How the community answered

(47 responses)
  • A
    4% (2)
  • B
    9% (4)
  • C
    85% (40)
  • D
    2% (1)

Explanation

You can optionally define multiple configurations for the same provider, and select which one to use on a per-resource or per-module basis. The primary reason for this is to support multiple regions for a cloud platform; other examples include targeting multiple Docker hosts, multiple Consul hosts, etc. To include multiple configurations for a given provider, include multiple provider blocks with the same provider name, but set the alias meta-argument to an alias name to use for each additional configuration. For example: # The default provider configuration provider "aws" { region = "us-east-1" # Additional provider configuration for west coast region provider "aws" { region = "us-west-2"

Topics

#Provider configuration#Provider aliases#Multi-region deployment

Community Discussion

No community discussion yet for this question.

Full TA-002-P Practice