0
0
Terraformcloud~10 mins

Plan and apply separation in pipelines in Terraform - Interactive Code Practice

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

Complete the code to define a Terraform backend configuration for remote state storage.

Terraform
terraform {
  backend "s3" {
    bucket = "[1]"
  }
}
Drag options to blanks, or click blank then click option'
Alocal-state
Bmy-terraform-state-bucket
Cterraform-backend
Dstate-storage
Attempts:
3 left
💡 Hint
Common Mistakes
Using a local folder name instead of an S3 bucket name.
Using a generic or incorrect bucket name.
2fill in blank
medium

Complete the code to specify the Terraform workspace for environment separation.

Terraform
terraform {
  required_version = ">= 1.0"
}

terraform workspace select [1]
Drag options to blanks, or click blank then click option'
Adev
Bdefault
Cmain
Dproduction
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'default' workspace which is shared and not environment-specific.
Using workspace names that don't match your environment naming.
3fill in blank
hard

Fix the error in the pipeline script to apply Terraform only after planning.

Terraform
steps:
  - name: Terraform Plan
    run: terraform plan -out=plan.tfplan
  - name: Terraform Apply
    run: terraform apply [1]
Drag options to blanks, or click blank then click option'
Aplan
B-auto-approve
Cplan.tfplan
D-plan=plan.tfplan
Attempts:
3 left
💡 Hint
Common Mistakes
Using flags like '-auto-approve' without specifying the plan file.
Using incorrect flags like '-plan=plan.tfplan'.
4fill in blank
hard

Fill both blanks to configure separate backend buckets and workspaces for dev and prod environments.

Terraform
terraform {
  backend "s3" {
    bucket = "[1]"
  }
}

terraform workspace select [2]
Drag options to blanks, or click blank then click option'
Aprod-terraform-state
Bdev-terraform-state
Cproduction
Ddevelopment
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing production bucket with development workspace.
Using generic or mismatched names.
5fill in blank
hard

Fill all three blanks to define a pipeline step that initializes Terraform, selects the correct workspace, and applies the plan.

Terraform
steps:
  - name: Terraform Init
    run: terraform init -backend-config=bucket=[1]
  - name: Select Workspace
    run: terraform workspace select [2]
  - name: Terraform Apply
    run: terraform apply [3]
Drag options to blanks, or click blank then click option'
Aprod-terraform-state
Bproduction
Cplan.tfplan
Ddev-terraform-state
Attempts:
3 left
💡 Hint
Common Mistakes
Using dev bucket with production workspace.
Forgetting to specify the plan file in apply.