0
0
Terraformcloud~10 mins

Code review for infrastructure changes 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 resource block for an AWS S3 bucket.

Terraform
resource "aws_s3_bucket" "my_bucket" {
  bucket = [1]
  acl    = "private"
}
Drag options to blanks, or click blank then click option'
Abucket_name
Bmy_bucket
C"public-read"
D"my-unique-bucket-name"
Attempts:
3 left
💡 Hint
Common Mistakes
Using a variable name without quotes
Using an ACL value instead of bucket name
Omitting quotes around the bucket name
2fill in blank
medium

Complete the code to specify the AWS region in the provider block.

Terraform
provider "aws" {
  region = [1]
}
Drag options to blanks, or click blank then click option'
Aregion
B"us-west-2"
Cus-west-2
Daws_region
Attempts:
3 left
💡 Hint
Common Mistakes
Omitting quotes around the region name
Using variable names without defining them
3fill in blank
hard

Fix the error in the resource block by completing the lifecycle rule to prevent bucket deletion.

Terraform
resource "aws_s3_bucket" "my_bucket" {
  bucket = "my-unique-bucket-name"

  lifecycle {
    [1] = true
  }
}
Drag options to blanks, or click blank then click option'
Ablock_deletion
Bprevent_delete
Cprevent_destroy
Ddisable_destroy
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect lifecycle attribute names
Confusing lifecycle rules with resource attributes
4fill in blank
hard

Fill both blanks to create an output that shows the bucket ARN.

Terraform
output "bucket_arn" {
  value = aws_s3_bucket.my_bucket[1][2]
}
Drag options to blanks, or click blank then click option'
A.
B[
Carn
D]
Attempts:
3 left
💡 Hint
Common Mistakes
Using brackets instead of dot notation
Using incorrect attribute names
5fill in blank
hard

Fill all three blanks to define a variable with a default value and description.

Terraform
variable "bucket_name" {
  type        = [1]
  default     = [2]
  description = [3]
}
Drag options to blanks, or click blank then click option'
A"string"
B"my-default-bucket"
C"The name of the S3 bucket"
Dstring
Attempts:
3 left
💡 Hint
Common Mistakes
Quoting the type value
Omitting quotes around default or description
Using incorrect variable syntax