0
0
Terraformcloud~10 mins

What is Infrastructure as Code in Terraform - Interactive Quiz & 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 resource.

Terraform
resource "aws_s3_bucket" "my_bucket" {
  bucket = [1]
}
Drag options to blanks, or click blank then click option'
Abucket_name
Bmy_bucket
C"my-unique-bucket-name"
D"bucket"
Attempts:
3 left
💡 Hint
Common Mistakes
Not using quotes around the bucket name.
Using an undefined variable name.
2fill in blank
medium

Complete the code to specify the AWS provider version.

Terraform
terraform {
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = [1]
    }
  }
}
Drag options to blanks, or click blank then click option'
A"~> 2.0"
B"= 4.0"
C"^ 3.0"
D"latest"
Attempts:
3 left
💡 Hint
Common Mistakes
Using an invalid version format.
Using "latest" which is not recommended.
3fill in blank
hard

Fix the error in the resource block by completing the missing argument.

Terraform
resource "aws_instance" "example" {
  ami           = "ami-12345678"
  instance_type = [1]
}
Drag options to blanks, or click blank then click option'
A"micro.t2"
B"t2.micro"
Ct2.micro
Dmicro
Attempts:
3 left
💡 Hint
Common Mistakes
Omitting quotes around the instance type.
Using incorrect instance type names.
4fill in blank
hard

Fill both blanks to create a security group with an ingress rule allowing HTTP traffic.

Terraform
resource "aws_security_group" "web_sg" {
  name        = "web_sg"
  description = "Allow HTTP inbound"

  ingress {
    from_port   = [1]
    to_port     = [2]
    protocol    = "tcp"
    cidr_blocks = ["0.0.0.0/0"]
  }
}
Drag options to blanks, or click blank then click option'
A80
B22
C443
D8080
Attempts:
3 left
💡 Hint
Common Mistakes
Using SSH port 22 instead of HTTP port 80.
Using different ports for from_port and to_port.
5fill in blank
hard

Fill all three blanks to define an output that shows the public IP of an AWS instance.

Terraform
output "instance_ip" {
  value = [1].[2].[3]
}
Drag options to blanks, or click blank then click option'
Aaws_instance
Bexample
Cpublic_ip
Dprivate_ip
Attempts:
3 left
💡 Hint
Common Mistakes
Using private_ip instead of public_ip.
Mixing resource names or types incorrectly.