0
0
Terraformcloud~10 mins

Resource arguments and attributes 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 an AWS S3 bucket with a name.

Terraform
resource "aws_s3_bucket" "my_bucket" {
  bucket = "[1]"
}
Drag options to blanks, or click blank then click option'
Amy-unique-bucket-123
Baws_bucket
Cbucket_name
Ds3_bucket
Attempts:
3 left
💡 Hint
Common Mistakes
Using variable names instead of actual bucket names.
Leaving the bucket name empty.
2fill in blank
medium

Complete the code to reference the ARN attribute of the AWS S3 bucket resource.

Terraform
output "bucket_arn" {
  value = aws_s3_bucket.my_bucket.[1]
}
Drag options to blanks, or click blank then click option'
Aurl
Bid
Cname
Darn
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'id' instead of 'arn' for the bucket ARN.
Using 'name' which only gives the bucket name.
3fill in blank
hard

Fix the error in the resource block by completing the missing argument for versioning configuration.

Terraform
resource "aws_s3_bucket" "my_bucket" {
  bucket = "my-versioned-bucket"

  versioning {
    [1] = "Enabled"
  }
}
Drag options to blanks, or click blank then click option'
Astatus
Bactive
Cversioning_enabled
Denabled
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'enabled' instead of 'status'.
Using boolean true instead of string "Enabled".
Using incorrect argument names like 'versioning_enabled'.
4fill in blank
hard

Fill both blanks to create a resource with tags and a lifecycle block to prevent deletion.

Terraform
resource "aws_s3_bucket" "my_bucket" {
  bucket = "my-tagged-bucket"

  tags = {
    [1] = "Production"
  }

  lifecycle {
    [2] = true
  }
}
Drag options to blanks, or click blank then click option'
AEnvironment
Bstatus
Cprevent_destroy
Dtag
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'tag' instead of 'Environment' as tag key.
Using 'status' instead of 'prevent_destroy'.
5fill in blank
hard

Fill all three blanks to output the bucket name, ARN, and region attributes.

Terraform
output "bucket_info" {
  value = {
    name   = aws_s3_bucket.my_bucket.[1],
    arn    = aws_s3_bucket.my_bucket.[2],
    region = aws_s3_bucket.my_bucket.[3]
  }
}
Drag options to blanks, or click blank then click option'
Abucket
Barn
Cregion
Did
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'id' instead of 'bucket' for the name.
Confusing 'region' with other attributes.