0
0
Terraformcloud~10 mins

Resource types and names 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 declare an AWS S3 bucket resource.

Terraform
resource "aws_s3_bucket" "[1]" {
  bucket = "my-example-bucket"
  acl    = "private"
}
Drag options to blanks, or click blank then click option'
As3bucket
Bbucket_name
Cmy_bucket
Dexample
Attempts:
3 left
💡 Hint
Common Mistakes
Using the bucket name as the resource name (they are different).
Including spaces or special characters in the resource name.
2fill in blank
medium

Complete the code to declare an AWS EC2 instance resource with the name 'web_server'.

Terraform
resource "aws_instance" "[1]" {
  ami           = "ami-0c55b159cbfafe1f0"
  instance_type = "t2.micro"
}
Drag options to blanks, or click blank then click option'
Aserver1
Binstance
Cec2_instance
Dweb_server
Attempts:
3 left
💡 Hint
Common Mistakes
Using a generic name instead of the specified one.
Confusing resource type with resource name.
3fill in blank
hard

Fix the error in the resource declaration by completing the resource name correctly.

Terraform
resource "aws_vpc" "[1]" {
  cidr_block = "10.0.0.0/16"
}
Drag options to blanks, or click blank then click option'
Amain_vpc
Bvpc-1
C10.0.0.0/16
Dvpc main
Attempts:
3 left
💡 Hint
Common Mistakes
Using invalid characters like dashes or spaces in the resource name.
Using the CIDR block as the resource name.
4fill in blank
hard

Fill both blanks to declare an AWS security group resource named 'web_sg' with description 'Allow HTTP traffic'.

Terraform
resource "aws_security_group" "[1]" {
  name        = "[2]"
  description = "Allow HTTP traffic"
  vpc_id      = "vpc-123456"
}
Drag options to blanks, or click blank then click option'
Aweb_sg
Bweb-security-group
Dhttp_sg
Attempts:
3 left
💡 Hint
Common Mistakes
Using dashes in the resource name (invalid).
Confusing resource name with the name attribute.
5fill in blank
hard

Fill all three blanks to declare an AWS Lambda function resource named 'process_data' with runtime 'python3.8' and handler 'lambda_function.lambda_handler'.

Terraform
resource "aws_lambda_function" "[1]" {
  function_name = "[2]"
  runtime       = "[3]"
  handler       = "lambda_function.lambda_handler"
  role          = "arn:aws:iam::123456789012:role/lambda_exec_role"
  filename      = "function.zip"
}
Drag options to blanks, or click blank then click option'
Aprocess_data
Cpython3.8
Dpython3.9
Attempts:
3 left
💡 Hint
Common Mistakes
Using different names for resource and function_name.
Using wrong runtime version.