Sha256: ab7ce6e875e8252d2e8ea888e2cfb26b26ebc19c3b0b838512764f37c96a2240

Contents?: true

Size: 1.55 KB

Versions: 37

Compression:

Stored size: 1.55 KB

Contents

# Create a VPC
resource "aws_vpc" "vpc" {
  cidr_block = local.cidr_block
  tags = {
    Name = "${var.aws_recon_base_name}-${random_id.aws_recon.hex}"
  }
}

# Create subnet
resource "aws_subnet" "subnet" {
  vpc_id            = aws_vpc.vpc.id
  cidr_block        = local.subnet_cidr_block
  availability_zone = data.aws_availability_zones.available.names[0]

  tags = {
    Name = "${var.aws_recon_base_name}-${random_id.aws_recon.hex}-public"
  }
}

resource "aws_security_group" "sg" {
  name        = "${var.aws_recon_base_name}-${random_id.aws_recon.hex}"
  description = "Allow AWS Recon collection egress"
  vpc_id      = aws_vpc.vpc.id

  egress {
    from_port   = 0
    to_port     = 0
    protocol    = "-1"
    cidr_blocks = ["0.0.0.0/0"]
  }

  tags = {
    Name = "${var.aws_recon_base_name}-${random_id.aws_recon.hex}"
  }
}

resource "aws_internet_gateway" "igw" {
  vpc_id = aws_vpc.vpc.id

  tags = {
    Name = "${var.aws_recon_base_name}-${random_id.aws_recon.hex}"
  }
}

resource "aws_route_table" "rt" {
  vpc_id = aws_vpc.vpc.id

  route {
    cidr_block = "0.0.0.0/0"
    gateway_id = aws_internet_gateway.igw.id
  }

  tags = {
    Name = "${var.aws_recon_base_name}-${random_id.aws_recon.hex}"
  }
}

resource "aws_route_table_association" "rt_association" {
  subnet_id      = aws_subnet.subnet.id
  route_table_id = aws_route_table.rt.id
}

locals {
  cidr_block        = var.base_subnet_cidr
  subnet_cidr_block = cidrsubnet(local.cidr_block, 8, 0)
}

data "aws_region" "current" {}

data "aws_availability_zones" "available" {
  state = "available"
}

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
aws_recon-0.5.33 utils/terraform/vpc.tf
aws_recon-0.5.32 utils/terraform/vpc.tf
aws_recon-0.5.31 utils/terraform/vpc.tf
aws_recon-0.5.30 utils/terraform/vpc.tf
aws_recon-0.5.29 utils/terraform/vpc.tf
aws_recon-0.5.28 utils/terraform/vpc.tf
aws_recon-0.5.27 utils/terraform/vpc.tf
aws_recon-0.5.26 utils/terraform/vpc.tf
aws_recon-0.5.25 utils/terraform/vpc.tf
aws_recon-0.5.24 utils/terraform/vpc.tf
aws_recon-0.5.23 utils/terraform/vpc.tf
aws_recon-0.5.22 utils/terraform/vpc.tf
aws_recon-0.5.21 utils/terraform/vpc.tf
aws_recon-0.5.20 utils/terraform/vpc.tf
aws_recon-0.5.19 utils/terraform/vpc.tf
aws_recon-0.5.18 utils/terraform/vpc.tf
aws_recon-0.5.17 utils/terraform/vpc.tf
aws_recon-0.5.16 utils/terraform/vpc.tf
aws_recon-0.5.15 utils/terraform/vpc.tf
aws_recon-0.5.14 utils/terraform/vpc.tf