Which of the following Terraform resource blocks correctly creates an AWS S3 bucket named my-unique-bucket-123?
Look for the correct attribute name to specify the bucket's name and proper string syntax.
In Terraform, the AWS S3 bucket resource requires the attribute bucket to specify the bucket name as a string. Option C uses the correct attribute and syntax. Option C uses name which is invalid. Option C uses bucket_name which is not recognized. Option C misses quotes around the bucket name, causing a syntax error.
Given the variable bucket_name defined as "example-bucket-456", which resource block correctly uses this variable to create an AWS S3 bucket?
variable "bucket_name" { type = string default = "example-bucket-456" }
Terraform variables are referenced without quotes and without interpolation syntax in modern versions.
Option A correctly references the variable var.bucket_name without quotes or interpolation. Option A treats it as a string literal. Option A uses deprecated interpolation syntax which is valid but deprecated in Terraform 0.12+. Option A uses shell-style variable syntax which is invalid.
You want to create a virtual machine in AWS using Terraform. Which resource type should you use to create an EC2 instance?
Look for the official Terraform AWS provider resource name for EC2 instances.
The correct resource type to create an EC2 instance in Terraform is aws_instance. The other options are invalid resource types and will cause errors.
Which Terraform resource block correctly creates an AWS S3 bucket with public access blocked?
Public access block settings are configured inside a nested block named public_access_block.
Option B correctly uses the nested public_access_block block with all required settings to block public access. Option B tries to set these as top-level attributes which is invalid. Options B and D use incorrect attribute names causing errors.
You have a Terraform configuration that creates an AWS S3 bucket named my-bucket. You change the bucket name in the configuration to my-new-bucket and run terraform apply. What will happen?
resource "aws_s3_bucket" "bucket" { bucket = "my-new-bucket" acl = "private" }
Consider how Terraform handles changes to resource identifiers that are immutable in the cloud provider.
Bucket names in AWS S3 are immutable. Changing the bucket name in Terraform causes Terraform to destroy the old bucket and create a new one. It cannot rename buckets in place. Therefore, option A is correct. Options A and C are incorrect because renaming is not supported. Option A is incorrect because Terraform does not throw an error but performs delete and create.