0
0
Terraformcloud~10 mins

Declarative vs imperative IaC in Terraform - Interactive Practice

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

Complete the code to declare an AWS S3 bucket resource in Terraform.

Terraform
resource "aws_s3_bucket" "my_bucket" {
  bucket = [1]
  acl    = "private"
}
Drag options to blanks, or click blank then click option'
Amy_bucket
B"my-unique-bucket-123"
C"aws_s3_bucket"
Dbucket_name
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting quotes around the bucket name.
Using variable names without declaration.
2fill in blank
medium

Complete the code to output the bucket ARN after creation.

Terraform
output "bucket_arn" {
  value = [1].arn
}
Drag options to blanks, or click blank then click option'
Aaws_s3_bucket.my_bucket
Baws_s3_bucket
Cbucket
Dmy_bucket
Attempts:
3 left
💡 Hint
Common Mistakes
Using only the resource name without provider prefix.
Using variable names instead of resource references.
3fill in blank
hard

Fix the error in the imperative script to create an S3 bucket using AWS CLI command.

Terraform
aws s3api create-bucket --bucket [1] --region us-east-1
Drag options to blanks, or click blank then click option'
Abucket_name
Bmy_bucket
C"my-unique-bucket-123"
Dmy-unique-bucket-123
Attempts:
3 left
💡 Hint
Common Mistakes
Adding quotes around bucket name causing errors.
Using variable names instead of actual bucket name.
4fill in blank
hard

Fill both blanks to declare an AWS EC2 instance with a specific AMI and instance type.

Terraform
resource "aws_instance" "example" {
  ami           = [1]
  instance_type = [2]
}
Drag options to blanks, or click blank then click option'
A"ami-0c55b159cbfafe1f0"
B"t2.micro"
C"ami-12345678"
D"m5.large"
Attempts:
3 left
💡 Hint
Common Mistakes
Using unquoted values causing syntax errors.
Mixing AMI and instance type values.
5fill in blank
hard

Fill all three blanks to create a security group with a name, description, and ingress rule allowing HTTP traffic.

Terraform
resource "aws_security_group" "web_sg" {
  name        = [1]
  description = [2]

  ingress {
    from_port   = 80
    to_port     = 80
    protocol    = [3]
    cidr_blocks = ["0.0.0.0/0"]
  }
}
Drag options to blanks, or click blank then click option'
A"web_sg"
B"Allow HTTP inbound traffic"
C"tcp"
D"udp"
Attempts:
3 left
💡 Hint
Common Mistakes
Using unquoted strings for name or description.
Using wrong protocol like "udp" for HTTP.