Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Recall & Review
beginner
What is the purpose of the GCP provider in Terraform?
The GCP provider allows Terraform to interact with Google Cloud Platform services by managing resources like compute instances, storage buckets, and networks.
Click to reveal answer
beginner
Which Terraform block is used to configure the GCP provider?
The provider "google" block is used to configure the GCP provider with credentials, project ID, and region.
Click to reveal answer
beginner
How do you specify the GCP project and region in Terraform provider configuration?
You specify them using the project and region arguments inside the provider "google" block.
Click to reveal answer
intermediate
What is the recommended way to provide credentials for the GCP provider in Terraform?
Use a service account key file and set the credentials argument to the file path, or set the GOOGLE_APPLICATION_CREDENTIALS environment variable.
Click to reveal answer
intermediate
Why is it important to pin the provider version in Terraform configuration?
Pinning the provider version ensures consistent behavior and avoids unexpected changes when new provider versions are released.
Click to reveal answer
Which block do you use to configure the GCP provider in Terraform?
Aprovider "google"
Bresource "google"
Cmodule "google"
Dvariable "google"
✗ Incorrect
The provider "google" block configures the GCP provider.
How do you specify the GCP project in Terraform provider configuration?
Believing credentials must be environment variables only
5. You want to configure Terraform to manage resources in two different GCP projects within the same configuration. How should you set up the provider blocks?
hard
A. Set project dynamically inside resource blocks without provider aliases
B. Use a single provider block with a list of projects
C. Create two separate Terraform configurations for each project
D. Define two provider blocks with different aliases and specify project for each
Solution
Step 1: Understand multi-project management in Terraform
Terraform supports multiple provider configurations using aliases to distinguish them.
Step 2: Configure providers with aliases and project
Define two provider "google" blocks with different alias names and set project for each.
Step 3: Reference providers in resources
Use provider = google.alias_name in resource blocks to specify which project to use.
Final Answer:
Define two provider blocks with different aliases and specify project for each -> Option D