module "default_tags" {
  source             = "git@github.com:theorchard/terraform-default-tags.git//?ref=2.0.0"
  environment        = var.environment
  application_family = var.application_family
  team_name          = var.team_name
}

provider "aws" {
  region = var.aws_region

  default_tags {
    tags = module.default_tags.tags
  }
}

# Terraform backends cannot contain interpolations
terraform {
  backend "s3" {
    bucket  = "orcd-terraform-state"
    key     = "qa/vpc/us-east-1/vpc-endpoints/terraform.tfstate"
    region  = "us-east-1"
    encrypt = "true"
  }
}

#data "aws_vpc" "main" {
#  tags = {
#    Name = "prod"
#  }
#}

#data "aws_subnets" "private" {
#  filter {
#    name   = "tag:Name"
#    values = ["private"]
#  }
#  filter {
#    name   = "vpc-id"
#    values = [data.aws_vpc.main.id]
#  }
#}

#data "aws_ec2_managed_prefix_list" "private_subnets" {
#  name = "qa-orcd-private-subnet-prefix-list"
#}

#resource "aws_security_group" "s3_endpoint" {
#  # checkov:skip=CKV_AWS_382: Egress restricted to VPC CIDR
#  name        = "qa-s3-interface-endpoint"
#  description = "Security group for S3 interface VPC endpoint"
#  vpc_id      = data.aws_vpc.main.id

#  ingress {
#    description     = "Allow HTTPS from private subnets"
#    from_port       = 443
#    to_port         = 443
#    protocol        = "tcp"
#    prefix_list_ids = [data.aws_ec2_managed_prefix_list.private_subnets.id]
#  }

#  egress {
#    description = "Allow HTTPS to VPC"
#    from_port   = 443
#    to_port     = 443
#    protocol    = "tcp"
#    cidr_blocks = [data.aws_vpc.main.cidr_block]
#  }

#  tags = {
#    Name        = "qa-s3-interface-endpoint"
#    environment = "qa"
#    terraformed = "true"
#  }
#}

#resource "aws_vpc_endpoint" "s3_interface" {
#  vpc_id              = data.aws_vpc.main.id
#  service_name        = "com.amazonaws.${var.aws_region}.s3"
#  vpc_endpoint_type   = "Interface"
#  private_dns_enabled = true
#  security_group_ids  = [aws_security_group.s3_endpoint.id]
#  subnet_ids          = data.aws_subnets.private.ids

#  tags = {
#    Name        = "qa-s3-vpc-endpoint"
#    environment = "qa"
#    terraformed = "true"
#  }
#}
