Complete the code to define the main Terraform configuration file.
resource "aws_instance" "example" { ami = "ami-12345678" instance_type = "[1]" }
The instance_type must be a valid AWS instance type like t2.micro.
Complete the code to declare a variable for the AWS region.
variable "region" { type = string default = "[1]" }
The default AWS region is often set to us-east-1 for many examples.
Fix the error in the provider block to specify the AWS region variable.
provider "aws" { region = [1] }
var. prefix.To use a variable in Terraform, prefix it with var.. So var.region accesses the variable named 'region'.
Fill both blanks to create an output that shows the instance's public IP.
output "instance_ip" { value = [1].[2] }
private_ip instead of public_ip.The output value should reference the resource name and the attribute public_ip to show the instance's public IP address.
Fill all three blanks to define a resource with a tag name and a count of 2.
resource "aws_instance" "[1]" { ami = "ami-12345678" instance_type = "t2.micro" count = [2] tags = { Name = "[3]" } }
The resource name is web_server, count is 2 to create two instances, and the tag Name is set to MyServer.