C. An AWS S3 bucket named mybucket with private access
D. A local file named mybucket with private permissions
Solution
Step 1: Identify block type and labels
The block is a resource of type aws_s3_bucket with name mybucket.
Step 2: Understand block arguments
Arguments set bucket name and access control list (acl) to private.
Final Answer:
An AWS S3 bucket named mybucket with private access -> Option C
Quick Check:
resource block creates AWS S3 bucket [OK]
Hint: resource blocks define cloud resources with settings [OK]
Common Mistakes:
Confusing resource with variable
Thinking acl is file permission
Assuming provider config instead of resource
4. Which of the following Terraform blocks has a syntax error?
medium
A. resource "aws_instance" "web"
ami = "ami-123456"
instance_type = "t2.micro"
}
B. provider "aws" {
region = "us-east-1"
}
C. variable "region" {
default = "us-west-2"
}
D. output "instance_ip" {
value = aws_instance.web.public_ip
}
Solution
Step 1: Check block opening and braces
resource "aws_instance" "web"
ami = "ami-123456"
instance_type = "t2.micro"
} misses the opening brace '{' after the block header.
Step 2: Confirm other blocks are correct
Options B, C, and D have proper braces and syntax.
Final Answer:
Missing opening brace in resource block -> Option A
Quick Check:
Blocks need opening and closing braces [OK]
Hint: Always check for matching braces after block header [OK]
Common Mistakes:
Forgetting opening or closing braces
Misplacing block labels without quotes
Incorrect indentation causing confusion
5. You want to create a Terraform configuration that defines a resource block for an AWS EC2 instance named app_server and inside it, add a nested tags block with key-value pairs. Which is the correct way to structure this?
hard
A. resource "aws_instance" "app_server" {
ami = "ami-abc123"
instance_type = "t3.micro"
tags = {
Name = "AppServer"
Environment = "Production"
}
}
B. resource "aws_instance" "app_server" {
ami = "ami-abc123"
instance_type = "t3.micro"
tags {
Name = "AppServer"
Environment = "Production"
}
}
C. resource "aws_instance" "app_server" {
ami = "ami-abc123"
instance_type = "t3.micro"
tags: {
Name = "AppServer"
Environment = "Production"
}
}
D. resource "aws_instance" "app_server" {
ami = "ami-abc123"
instance_type = "t3.micro"
tags = [
Name = "AppServer",
Environment = "Production"
]
}
Solution
Step 1: Understand tags argument type
In Terraform, tags are a map (key-value pairs) assigned with = and braces { }.