0
0
Terraformcloud~10 mins

Terraform in GitLab CI - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to initialize Terraform in the GitLab CI job.

Terraform
terraform init [1]
Drag options to blanks, or click blank then click option'
A-refresh=false
B-auto-approve
C-input=false
D-lock=false
Attempts:
3 left
💡 Hint
Common Mistakes
Using -auto-approve with terraform init (it's for apply)
Omitting flags causing the job to hang waiting for input
2fill in blank
medium

Complete the code to plan Terraform changes in GitLab CI.

Terraform
terraform plan [1]
Drag options to blanks, or click blank then click option'
A-auto-approve
B-out=plan.tfplan
C-refresh=false
D-input=true
Attempts:
3 left
💡 Hint
Common Mistakes
Using -auto-approve with plan (it's for apply)
Not saving the plan file, so apply cannot use it
3fill in blank
hard

Fix the error in the apply command to run non-interactively in GitLab CI.

Terraform
terraform apply [1] plan.tfplan
Drag options to blanks, or click blank then click option'
A-auto-approve
B-input=true
C-refresh=false
D-lock=false
Attempts:
3 left
💡 Hint
Common Mistakes
Using -input=true causes the job to wait for input
Omitting -auto-approve causes the job to hang
4fill in blank
hard

Fill both blanks to configure the GitLab CI job to use Terraform with a backend and environment variables.

Terraform
variables:
  TF_VAR_region: [1]
  TF_VAR_env: [2]
Drag options to blanks, or click blank then click option'
A"us-east-1"
B"production"
C"dev"
D"eu-west-2"
Attempts:
3 left
💡 Hint
Common Mistakes
Using inconsistent environment names
Not quoting string values
5fill in blank
hard

Fill all three blanks to complete the GitLab CI job stages for Terraform init, plan, and apply.

Terraform
stages:
  - [1]
  - [2]
  - [3]
Drag options to blanks, or click blank then click option'
Adeploy
Bplan
Capply
Dinit
Attempts:
3 left
💡 Hint
Common Mistakes
Putting apply before plan
Using unrelated stage names