Complete the code to define a resource block in Terraform.
resource "aws_instance" "example" { ami = "ami-123456" instance_type = [1] }
The instance_type must be a valid AWS instance type string like t2.micro.
Complete the code to reference the resource's attribute.
output "instance_ip" { value = aws_instance.example.[1] }
The public_ip attribute gives the public IP address of the instance.
Fix the error in the resource block by completing the missing argument.
resource "aws_s3_bucket" "my_bucket" { bucket = [1] acl = "private" }
The bucket name must be a valid DNS-compliant string without spaces or special characters.
Fill both blanks to create a resource with tags.
resource "aws_instance" "web" { ami = "ami-abc123" instance_type = [1] tags = { Name = [2] } }
The instance type should be a valid AWS type like t2.micro, and tags require quoted strings.
Fill all three blanks to define a resource with lifecycle rules.
resource "aws_s3_bucket" "archive" { bucket = [1] acl = "private" lifecycle { prevent_destroy = [2] ignore_changes = [[3]] } }
The bucket name must be a valid string, prevent_destroy is a boolean, and ignore_changes expects a list of attribute names as strings.