Complete the code to define an AWS S3 bucket resource.
resource "aws_s3_bucket" "my_bucket" { bucket = [1] }
The bucket name must be a string in quotes to be valid in Terraform.
Complete the code to specify the AWS provider version.
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = [1]
}
}
}The version constraint "~> 2.0" means compatible with 2.x versions.
Fix the error in the resource block by completing the missing argument.
resource "aws_instance" "example" { ami = "ami-12345678" instance_type = [1] }
The instance_type must be a string with quotes, e.g., "t2.micro".
Fill both blanks to create a security group with an ingress rule allowing HTTP traffic.
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"] } }
HTTP traffic uses port 80, so both from_port and to_port should be 80.
Fill all three blanks to define an output that shows the public IP of an AWS instance.
output "instance_ip" { value = [1].[2].[3] }
The output references the resource aws_instance.example.public_ip to show the instance's public IP address.
