0
0
Terraformcloud~10 mins

State disaster recovery 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 specify the backend type for Terraform state storage.

Terraform
terraform {
  backend "[1]" {}
}
Drag options to blanks, or click blank then click option'
As3
Blocal
Chttp
Dgcs
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'local' backend which stores state on the local machine, not suitable for disaster recovery.
Choosing 'http' which is less common and requires additional setup.
2fill in blank
medium

Complete the code to enable versioning on the S3 bucket for state recovery.

Terraform
resource "aws_s3_bucket" "terraform_state" {
  bucket = "my-terraform-state"
  versioning {
    status = "[1]"
  }
}
Drag options to blanks, or click blank then click option'
ADisabled
BEnabled
CSuspended
DActive
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'Disabled' or 'Suspended' which do not enable versioning.
Using 'Active' which is not a valid status value.
3fill in blank
hard

Fix the error in the backend configuration to enable encryption of the state file.

Terraform
terraform {
  backend "s3" {
    bucket         = "my-terraform-state"
    key            = "state.tfstate"
    region         = "us-east-1"
    encrypt        = [1]
  }
}
Drag options to blanks, or click blank then click option'
Atrue
B"yes"
C"true"
DTrue
Attempts:
3 left
💡 Hint
Common Mistakes
Using quoted strings like "true" or "yes" which are invalid for boolean attributes.
Using capitalized True which is not valid in Terraform.
4fill in blank
hard

Fill both blanks to configure DynamoDB for state locking and specify the bucket name.

Terraform
terraform {
  backend "s3" {
    bucket         = "[1]"
    key            = "terraform.tfstate"
    region         = "us-west-2"
    dynamodb_table = "[2]"
    encrypt        = true
  }
}
Drag options to blanks, or click blank then click option'
Amy-terraform-state
Bterraform-lock-table
Cstate-lock
Dterraform-state-bucket
Attempts:
3 left
💡 Hint
Common Mistakes
Confusing the bucket name with the DynamoDB table name.
Using incorrect or missing names causing backend initialization errors.
5fill in blank
hard

Fill all three blanks to create an S3 bucket with versioning and a DynamoDB table for locking.

Terraform
resource "aws_s3_bucket" "terraform_state" {
  bucket = "[1]"
  versioning {
    status = "[2]"
  }
}

resource "aws_dynamodb_table" "terraform_lock" {
  name         = "[3]"
  billing_mode = "PAY_PER_REQUEST"
  hash_key     = "LockID"
  attribute {
    name = "LockID"
    type = "S"
  }
}
Drag options to blanks, or click blank then click option'
Amy-terraform-state
BEnabled
Cterraform-lock-table
DDisabled
Attempts:
3 left
💡 Hint
Common Mistakes
Setting versioning status to 'Disabled' which disables versioning.
Using inconsistent names between resources and backend configuration.