terraform {
  required_version = ">= 0.15.0"
  required_providers {
    aws = {
      "configuration_aliases" = [aws.files]
      "source"                = "hashicorp/aws"
      "version"               = ">= 4.0.0"
    }
  }
}

provider "aws" {
  alias  = "files"
  region = "ap-northeast-2"
}

output "vpc_prod_datasaker_id" {
  value = aws_vpc.vpc-prod-datasaker.id
}

output "vpc_prod_datasaker_cidr_block" {
  value = aws_vpc.vpc-prod-datasaker.cidr_block
}



resource "aws_vpc" "vpc-prod-datasaker" {
  assign_generated_ipv6_cidr_block = true
  cidr_block                       = "172.24.0.0/19"
  enable_dns_hostnames             = true
  enable_dns_support               = true
  tags = {
    "Name" = "vpc-prod-datasaker"
  }
}

resource "aws_vpc_dhcp_options" "vpc-dhcp-prod-datasaker" {
  domain_name         = "ap-northeast-2.compute.internal"
  domain_name_servers = ["AmazonProvidedDNS"]
  tags = {
    "Name" = "vpc-dhcp-prod-datasaker"
  }
}

resource "aws_vpc_dhcp_options_association" "vpc-dhcp-asso-prod-datasaker" {
  dhcp_options_id = aws_vpc_dhcp_options.vpc-dhcp-prod-datasaker.id
  vpc_id          = aws_vpc.vpc-prod-datasaker.id
}

resource "aws_internet_gateway" "igw-prod-datasaker" {
  tags = {
    "Name" = "igw-prod-datasaker"
  }
  vpc_id = aws_vpc.vpc-prod-datasaker.id
}
