|
| 1 | +provider "aws" { |
| 2 | + region = local.region |
| 3 | +} |
| 4 | + |
| 5 | +data "aws_availability_zones" "available" {} |
| 6 | + |
| 7 | +locals { |
| 8 | + name = "ex-${basename(path.cwd)}" |
| 9 | + region = "eu-west-1" |
| 10 | + |
| 11 | + vpc_cidr = "10.0.0.0/16" |
| 12 | + azs = slice(data.aws_availability_zones.available.names, 0, 3) |
| 13 | + |
| 14 | + tags = { |
| 15 | + Example = local.name |
| 16 | + GithubRepo = "terraform-aws-vpc" |
| 17 | + GithubOrg = "terraform-aws-modules" |
| 18 | + } |
| 19 | +} |
| 20 | + |
| 21 | +################################################################################ |
| 22 | +# VPC Module |
| 23 | +################################################################################ |
| 24 | + |
| 25 | +module "vpc" { |
| 26 | + source = "../../" |
| 27 | + |
| 28 | + name = local.name |
| 29 | + cidr = local.vpc_cidr |
| 30 | + |
| 31 | + azs = local.azs |
| 32 | + private_subnets = [for k, v in local.azs : cidrsubnet(local.vpc_cidr, 4, k)] |
| 33 | + |
| 34 | + ### VPC Block Public Access Options |
| 35 | + # internet_gateway_block_enabled = true |
| 36 | + # internet_gateway_block_mode = "block-bidirectional" |
| 37 | + |
| 38 | + ### VPC Block Public Access Exclusion at the VPC level |
| 39 | + # vpc_block_public_access_exclusions = { |
| 40 | + # exclude_vpc = { |
| 41 | + # exclude_vpc = true |
| 42 | + # internet_gateway_exclusion_mode = "allow-bidirectional" |
| 43 | + # } |
| 44 | + # } |
| 45 | + |
| 46 | + ### VPC Block Public Access Exclusion at the subnet level |
| 47 | + vpc_block_public_access_exclusions = { |
| 48 | + exclude_subnet_private1 = { |
| 49 | + exclude_subnet = true |
| 50 | + subnet_type = "private" |
| 51 | + subnet_index = 1 |
| 52 | + internet_gateway_exclusion_mode = "allow-egress" |
| 53 | + } |
| 54 | + exclude_subnet_private2 = { |
| 55 | + exclude_subnet = true |
| 56 | + subnet_type = "private" |
| 57 | + subnet_index = 2 |
| 58 | + internet_gateway_exclusion_mode = "allow-egress" |
| 59 | + } |
| 60 | + } |
| 61 | + |
| 62 | + tags = local.tags |
| 63 | +} |
0 commit comments