Hashicorp Certified Terraform Associate 003 · Free Practice Question Medium
Question 17
Scenario: You are deploying a new application and want to deploy it to multiple AWS regions within the same configuration file. Which of the following features will allow you to configure this?
-
A
one provider block that defines multiple regions
-
B
using the default provider along with a single defined provider
-
C
multiple provider blocks using an alias
-
D
a provider with multiple versions defined
Reveal correct answer
Correct answer: C
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.
A. Having one provider block that defines multiple regions is not a valid approach in Terraform. The provider block is used to configure a single provider instance, so defining multiple regions within a single provider block would not allow you to deploy the application to multiple AWS regions within the same configuration.
B. Using the default provider along with a single defined provider does not provide a mechanism to deploy the application to multiple AWS regions within the same configuration file. The default provider is used when no provider is explicitly specified, and a single defined provider would limit the deployment to a single region.
C. Using multiple provider blocks with aliases allows you to define multiple AWS providers in the same configuration file, each with a unique alias. This way, you can specify different regions for each provider, enabling you to deploy your application to multiple AWS regions within the same configuration.
D. Defining a provider with multiple versions does not relate to configuring deployment to multiple AWS regions within the same configuration file. The provider version is used to specify the version of the provider plugin to use, and it does not provide the functionality to deploy the application to multiple regions.
Discussion
Think the marked answer is wrong, or have a better explanation? Share it below — comments appear after review.
