terraform {
  required_version = ">= 1.5.0"

  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "~> 5.0"
    }
  }

  backend "s3" {
    bucket = "terraform-state-prod"
    key    = "infrastructure/terraform.tfstate"
    region = "us-east-1"
  }
}

provider "aws" {
  region = "us-east-1"
}

resource "aws_instance" "web" {
  ami           = "ami-0c55b159cbfafe1f0"
  instance_type = "m5.2xlarge"

  tags = {
    Name        = "web-server"
    Environment = "production"
    critical    = "false"
  }
}

resource "aws_instance" "api" {
  ami           = "ami-0c55b159cbfafe1f0"
  instance_type = "m5.xlarge"

  tags = {
    Name        = "api-server"
    Environment = "production"
    critical    = "true"
  }
}

resource "aws_s3_bucket" "logs" {
  bucket = "prod-logs-bucket"

  tags = {
    Name        = "log-storage"
    Environment = "production"
    critical    = "false"
  }
}
