provider "aws" {
  region = var.region
}

terraform {
  backend "s3" {
    bucket  = "orcd-terraform-state"
    key     = "qa/royalties-compute-capacity-reservation/terraform.tfstate"
    region  = "us-east-1"
    encrypt = "true"
  }
}

# When you create a Capacity Reservation, we reserve the specified capacity for your use. The reserved capacity is charged at the selected instance type’s On-Demand rate whether an instance is running in it or not
resource "aws_ec2_capacity_reservation" "capacity_reservation" {
  availability_zone       = "us-east-1f" #make sure it matches the royalties spark emr cluster zone
  instance_count          = 2
  instance_platform       = "Linux/UNIX"
  instance_type           = "m5.24xlarge"
  tenancy                 = "default"
  instance_match_criteria = "open"
  end_date_type           = "limited"
  end_date                = "2022-11-08T21:59:59Z" #UTC

  tags = {
    terraformed        = true
    service_name       = var.service_name
    application_family = var.application_family
  }
}
