# Define a variable
variable "region" {
  description = "AWS region"
  default     = "us-west-2"
}

# AWS provider
provider "aws" {
  region = var.region
}

# Create an EC2 instance
resource "aws_instance" "web" {
  ami           = "ami-0c55b159cbfafe1f0"
  instance_type = "t2.micro"

  tags = {
    Name = "web-server"
  }
}

# Output public IP
output "public_ip" {
  value = aws_instance.web.public_ip
}   
