From cfffd39dd52917150e64b987c0c6c697b7d2127f Mon Sep 17 00:00:00 2001 From: qbart Date: Wed, 29 May 2024 15:37:11 +0200 Subject: [PATCH 1/6] feat: Add vpc with example --- .github/workflows/tflint.yml | 6 +- examples/vpc/.terraform.lock.hcl | 44 ++++++++++++++ examples/vpc/main.tf | 71 ++++++++++++++++++++++ examples/vpc/versions.tf | 15 +++++ modules/vpc-private-subnet/README.md | 5 ++ modules/vpc-private-subnet/main.tf | 66 +++++++++++++++++++++ modules/vpc-private-subnet/outputs.tf | 18 ++++++ modules/vpc-private-subnet/variables.tf | 38 ++++++++++++ modules/vpc-public-subnet/README.md | 5 ++ modules/vpc-public-subnet/main.tf | 78 +++++++++++++++++++++++++ modules/vpc-public-subnet/outputs.tf | 29 +++++++++ modules/vpc-public-subnet/variables.tf | 32 ++++++++++ modules/vpc/README.md | 5 ++ modules/vpc/main.tf | 28 +++++++++ modules/vpc/outputs.tf | 14 +++++ modules/vpc/variables.tf | 23 ++++++++ 16 files changed, 472 insertions(+), 5 deletions(-) create mode 100644 examples/vpc/.terraform.lock.hcl create mode 100644 examples/vpc/main.tf create mode 100644 examples/vpc/versions.tf create mode 100644 modules/vpc-private-subnet/README.md create mode 100644 modules/vpc-private-subnet/main.tf create mode 100644 modules/vpc-private-subnet/outputs.tf create mode 100644 modules/vpc-private-subnet/variables.tf create mode 100644 modules/vpc-public-subnet/README.md create mode 100644 modules/vpc-public-subnet/main.tf create mode 100644 modules/vpc-public-subnet/outputs.tf create mode 100644 modules/vpc-public-subnet/variables.tf create mode 100644 modules/vpc/README.md create mode 100644 modules/vpc/main.tf create mode 100644 modules/vpc/outputs.tf create mode 100644 modules/vpc/variables.tf diff --git a/.github/workflows/tflint.yml b/.github/workflows/tflint.yml index 6a7f751..3686048 100644 --- a/.github/workflows/tflint.yml +++ b/.github/workflows/tflint.yml @@ -32,11 +32,7 @@ jobs: GITHUB_TOKEN: ${{ github.token }} - name: Run TFLint - run: | - tflint -f compact --chdir . - tflint -f compact --chdir modules/cloudfront-app - tflint -f compact --chdir modules/cloudfront-deployment-policy - tflint -f compact --chdir modules/cloudfront-s3-origin-bucket-policy + run: tflint --recursive -f compact - run: echo ${{ steps.tflint.outputs.stdout }} - run: echo ${{ steps.tflint.outputs.stderr }} diff --git a/examples/vpc/.terraform.lock.hcl b/examples/vpc/.terraform.lock.hcl new file mode 100644 index 0000000..6b8a9ac --- /dev/null +++ b/examples/vpc/.terraform.lock.hcl @@ -0,0 +1,44 @@ +# This file is maintained automatically by "terraform init". +# Manual edits may be lost in future updates. + +provider "registry.terraform.io/hashicorp/aws" { + version = "4.67.0" + constraints = "~> 4.0" + hashes = [ + "h1:5Zfo3GfRSWBaXs4TGQNOflr1XaYj6pRnVJLX5VAjFX4=", + "zh:0843017ecc24385f2b45f2c5fce79dc25b258e50d516877b3affee3bef34f060", + "zh:19876066cfa60de91834ec569a6448dab8c2518b8a71b5ca870b2444febddac6", + "zh:24995686b2ad88c1ffaa242e36eee791fc6070e6144f418048c4ce24d0ba5183", + "zh:4a002990b9f4d6d225d82cb2fb8805789ffef791999ee5d9cb1fef579aeff8f1", + "zh:559a2b5ace06b878c6de3ecf19b94fbae3512562f7a51e930674b16c2f606e29", + "zh:6a07da13b86b9753b95d4d8218f6dae874cf34699bca1470d6effbb4dee7f4b7", + "zh:768b3bfd126c3b77dc975c7c0e5db3207e4f9997cf41aa3385c63206242ba043", + "zh:7be5177e698d4b547083cc738b977742d70ed68487ce6f49ecd0c94dbf9d1362", + "zh:8b562a818915fb0d85959257095251a05c76f3467caa3ba95c583ba5fe043f9b", + "zh:9b12af85486a96aedd8d7984b0ff811a4b42e3d88dad1a3fb4c0b580d04fa425", + "zh:9c385d03a958b54e2afd5279cd8c7cbdd2d6ca5c7d6a333e61092331f38af7cf", + "zh:b3ca45f2821a89af417787df8289cb4314b273d29555ad3b2a5ab98bb4816b3b", + "zh:da3c317f1db2469615ab40aa6baba63b5643bae7110ff855277a1fb9d8eb4f2c", + "zh:dc6430622a8dc5cdab359a8704aec81d3825ea1d305bbb3bbd032b1c6adfae0c", + "zh:fac0d2ddeadf9ec53da87922f666e1e73a603a611c57bcbc4b86ac2821619b1d", + ] +} + +provider "registry.terraform.io/hashicorp/random" { + version = "3.6.2" + hashes = [ + "h1:VavG5unYCa3SYISMKF9pzc3718M0bhPlcbUZZGl7wuo=", + "zh:0ef01a4f81147b32c1bea3429974d4d104bbc4be2ba3cfa667031a8183ef88ec", + "zh:1bcd2d8161e89e39886119965ef0f37fcce2da9c1aca34263dd3002ba05fcb53", + "zh:37c75d15e9514556a5f4ed02e1548aaa95c0ecd6ff9af1119ac905144c70c114", + "zh:4210550a767226976bc7e57d988b9ce48f4411fa8a60cd74a6b246baf7589dad", + "zh:562007382520cd4baa7320f35e1370ffe84e46ed4e2071fdc7e4b1a9b1f8ae9b", + "zh:5efb9da90f665e43f22c2e13e0ce48e86cae2d960aaf1abf721b497f32025916", + "zh:6f71257a6b1218d02a573fc9bff0657410404fb2ef23bc66ae8cd968f98d5ff6", + "zh:78d5eefdd9e494defcb3c68d282b8f96630502cac21d1ea161f53cfe9bb483b3", + "zh:9647e18f221380a85f2f0ab387c68fdafd58af6193a932417299cdcae4710150", + "zh:bb6297ce412c3c2fa9fec726114e5e0508dd2638cad6a0cb433194930c97a544", + "zh:f83e925ed73ff8a5ef6e3608ad9225baa5376446349572c2449c0c0b3cf184b7", + "zh:fbef0781cb64de76b1df1ca11078aecba7800d82fd4a956302734999cfd9a4af", + ] +} diff --git a/examples/vpc/main.tf b/examples/vpc/main.tf new file mode 100644 index 0000000..e93de55 --- /dev/null +++ b/examples/vpc/main.tf @@ -0,0 +1,71 @@ +locals { + context = { + namespace = "selleo" + stage = "test" + name = "networking" + } +} + +module "vpc" { + source = "../../modules/vpc" + + name = "test" + cidr = "10.0.0.0/16" + + context = local.context +} + +module "public_subnet" { + source = "../../modules/vpc-public-subnet" + + context = local.context + vpc_id = module.vpc.id + internet_gateway_id = module.vpc.internet_gateway_id + + config = { + "a" = { + az = "eu-central-1a" + cidr = "10.0.1.0/24" + nat = true + } + "b" = { + az = "eu-central-1b" + cidr = "10.0.2.0/24" + nat = false + } + } +} + +module "private_subnet" { + source = "../../modules/vpc-private-subnet" + + context = local.context + vpc_id = module.vpc.id + + config = { + "a" = { + az = "eu-central-1a" + cidr = "10.0.51.0/24" + } + } + + nat_gateway_routing = { + "a" = module.public_subnet.nat_gateways["eu-central-1a"] + } +} + +module "database_subnet" { + source = "../../modules/vpc-private-subnet" + + context = local.context + vpc_id = module.vpc.id + + config = { + "db-a" = { + az = "eu-central-1a" + cidr = "10.0.101.0/24" + } + } + + database_subnet = true +} diff --git a/examples/vpc/versions.tf b/examples/vpc/versions.tf new file mode 100644 index 0000000..51493ec --- /dev/null +++ b/examples/vpc/versions.tf @@ -0,0 +1,15 @@ +terraform { + required_version = "~> 1.0" + + required_providers { + aws = { + source = "hashicorp/aws" + version = "~> 4.0" + } + } +} + +provider "aws" { + region = "eu-central-1" +} + diff --git a/modules/vpc-private-subnet/README.md b/modules/vpc-private-subnet/README.md new file mode 100644 index 0000000..84b9842 --- /dev/null +++ b/modules/vpc-private-subnet/README.md @@ -0,0 +1,5 @@ +# subnet + +## Usage + +## Output diff --git a/modules/vpc-private-subnet/main.tf b/modules/vpc-private-subnet/main.tf new file mode 100644 index 0000000..bdbd8df --- /dev/null +++ b/modules/vpc-private-subnet/main.tf @@ -0,0 +1,66 @@ +locals { + tags = merge({ + "terraform.module" = "Selleo/terraform-aws-vpc" + "terraform.submodule" = "private-subnet" + "context.namespace" = var.context.namespace + "context.stage" = var.context.stage + "context.name" = var.context.name + "resource.group" = "network" + }) +} + +resource "aws_subnet" "this" { + for_each = var.config + + vpc_id = var.vpc_id + availability_zone = each.value.az + cidr_block = each.value.cidr + map_public_ip_on_launch = false + + tags = merge(local.tags, { + Name = "private-${random_id.this.hex}-${each.key}--${each.value.az}" + }) +} + +resource "aws_route_table" "this" { + for_each = var.config + + vpc_id = var.vpc_id + + tags = merge(local.tags, { + Name = "private-${random_id.this.hex}-${each.key}--${each.value.az}" + }) +} + +resource "aws_route_table_association" "this" { + for_each = var.config + + subnet_id = aws_subnet.this[each.key].id + route_table_id = aws_route_table.this[each.key].id +} + +resource "aws_route" "this" { + for_each = var.nat_gateway_routing + + route_table_id = aws_route_table.this[each.key].id + destination_cidr_block = "0.0.0.0/0" + nat_gateway_id = each.value + + timeouts { + create = "5m" + } +} + +resource "aws_db_subnet_group" "this" { + for_each = var.database_subnet ? { "db" : true } : {} + + name = "db-private-${random_id.this.hex}" + description = "Database subnet group for RDS" + subnet_ids = [for key in sort(keys(var.config)) : aws_subnet.this[key].id] + + tags = merge(local.tags, { "resource.group" = "network" }) +} + +resource "random_id" "this" { + byte_length = 2 +} diff --git a/modules/vpc-private-subnet/outputs.tf b/modules/vpc-private-subnet/outputs.tf new file mode 100644 index 0000000..96f5bde --- /dev/null +++ b/modules/vpc-private-subnet/outputs.tf @@ -0,0 +1,18 @@ +output "subnets" { + value = { + for key, config in var.config : + config.az => aws_subnet.this[key].id + } + description = "Subnet IDs by AZ" +} + +output "ids" { + # ensure consistent ordering + value = [for key in sort(keys(var.config)) : aws_subnet.this[key].id] + description = "Subnet IDs sorted by key" +} + +output "database_subnet_group_id" { + value = try(aws_db_subnet_group.this["db"].id, null) + description = "Database subnet group ID" +} diff --git a/modules/vpc-private-subnet/variables.tf b/modules/vpc-private-subnet/variables.tf new file mode 100644 index 0000000..59a5fe6 --- /dev/null +++ b/modules/vpc-private-subnet/variables.tf @@ -0,0 +1,38 @@ +variable "vpc_id" { + type = string + description = "VPC ID" +} + +variable "config" { + type = map(object({ + az = string + cidr = string + })) + description = "Subnet configuration" +} + +variable "nat_gateway_routing" { + type = map(string) + description = "NAT Gateway routing" + default = {} +} + +variable "context" { + type = object({ + namespace = string + stage = string + name = string + }) + description = "Context" + default = { + namespace = "default" + stage = "default" + name = "default" + } +} + +variable "database_subnet" { + type = bool + description = "Database subnet group " + default = false +} diff --git a/modules/vpc-public-subnet/README.md b/modules/vpc-public-subnet/README.md new file mode 100644 index 0000000..84b9842 --- /dev/null +++ b/modules/vpc-public-subnet/README.md @@ -0,0 +1,5 @@ +# subnet + +## Usage + +## Output diff --git a/modules/vpc-public-subnet/main.tf b/modules/vpc-public-subnet/main.tf new file mode 100644 index 0000000..c99d57c --- /dev/null +++ b/modules/vpc-public-subnet/main.tf @@ -0,0 +1,78 @@ +locals { + tags = merge({ + "terraform.module" = "Selleo/terraform-aws-vpc" + "terraform.submodule" = "public-subnet" + "context.namespace" = var.context.namespace + "context.stage" = var.context.stage + "context.name" = var.context.name + "resource.group" = "network" + Name = "public" + }) + + # if nat is enabled, create a NAT gateway in each AZ + nat_enabled_azs = { + for key, config in var.config : + key => config if config.nat + } +} + +resource "aws_route_table" "main" { + vpc_id = var.vpc_id + + tags = merge(local.tags, { + Name = "public-${random_id.this.hex}" + }) +} + +resource "aws_subnet" "this" { + for_each = var.config + + vpc_id = var.vpc_id + availability_zone = each.value.az + cidr_block = each.value.cidr + map_public_ip_on_launch = true + + tags = merge(local.tags, { + Name = "public-${random_id.this.hex}-${each.key}--${each.value.az}" + }) +} + +resource "aws_route_table_association" "this" { + for_each = var.config + + subnet_id = aws_subnet.this[each.key].id + route_table_id = aws_route_table.main.id +} + +resource "aws_route" "public_internet_gateway" { + route_table_id = aws_route_table.main.id + destination_cidr_block = "0.0.0.0/0" + gateway_id = var.internet_gateway_id + + timeouts { + create = "5m" + } +} + +resource "aws_eip" "nat" { + for_each = local.nat_enabled_azs + + tags = merge(local.tags, { + Name = "nat-${random_id.this.hex}-${each.key}--${each.value.az}" + }) +} + +resource "aws_nat_gateway" "nat" { + for_each = local.nat_enabled_azs + + allocation_id = aws_eip.nat[each.key].id + subnet_id = aws_subnet.this[each.key].id + + tags = merge(local.tags, { + Name = "nat-${random_id.this.hex}-${each.key}--${each.value.az}" + }) +} + +resource "random_id" "this" { + byte_length = 2 +} \ No newline at end of file diff --git a/modules/vpc-public-subnet/outputs.tf b/modules/vpc-public-subnet/outputs.tf new file mode 100644 index 0000000..3397425 --- /dev/null +++ b/modules/vpc-public-subnet/outputs.tf @@ -0,0 +1,29 @@ +output "subnets" { + value = { + for key, config in var.config : + config.az => aws_subnet.this[key].id + } + description = "Subnet IDs by AZ" +} + +output "nat_ips" { + value = { + for key, config in local.nat_enabled_azs : + config.az => aws_eip.nat[key].id + } + description = "NAT Elastic IPs by AZ" +} + +output "nat_gateways" { + value = { + for key, config in local.nat_enabled_azs : + config.az => aws_nat_gateway.nat[key].id + } + description = "NAT Gateway IDs by AZ" +} + +output "ids" { + # ensure consistent ordering + value = [for key in sort(keys(var.config)) : aws_subnet.this[key].id] + description = "Subnet IDs sorted by key" +} diff --git a/modules/vpc-public-subnet/variables.tf b/modules/vpc-public-subnet/variables.tf new file mode 100644 index 0000000..67d49e8 --- /dev/null +++ b/modules/vpc-public-subnet/variables.tf @@ -0,0 +1,32 @@ +variable "vpc_id" { + type = string + description = "VPC ID" +} + +variable "config" { + type = map(object({ + az = string + cidr = string + nat = bool + })) + description = "Subnet configuration" +} + +variable "internet_gateway_id" { + type = string + description = "Internet Gateway ID" +} + +variable "context" { + type = object({ + namespace = string + stage = string + name = string + }) + description = "Context" + default = { + namespace = "default" + stage = "default" + name = "default" + } +} \ No newline at end of file diff --git a/modules/vpc/README.md b/modules/vpc/README.md new file mode 100644 index 0000000..17e1c6e --- /dev/null +++ b/modules/vpc/README.md @@ -0,0 +1,5 @@ +# vpc + +## Usage + +## Output diff --git a/modules/vpc/main.tf b/modules/vpc/main.tf new file mode 100644 index 0000000..7fdcfc5 --- /dev/null +++ b/modules/vpc/main.tf @@ -0,0 +1,28 @@ +locals { + tags = merge({ + "terraform.module" = "Selleo/terraform-aws-vpc" + "terraform.submodule" = "vpc" + "context.namespace" = var.context.namespace + "context.stage" = var.context.stage + "context.name" = var.context.name + "resource.group" = "network" + Name = var.name + }) +} + +resource "aws_vpc" "this" { + cidr_block = var.cidr + + instance_tenancy = "default" + enable_dns_hostnames = true + enable_dns_support = true + enable_network_address_usage_metrics = true + + tags = local.tags +} + +resource "aws_internet_gateway" "this" { + vpc_id = aws_vpc.this.id + + tags = local.tags +} \ No newline at end of file diff --git a/modules/vpc/outputs.tf b/modules/vpc/outputs.tf new file mode 100644 index 0000000..2b1a5ea --- /dev/null +++ b/modules/vpc/outputs.tf @@ -0,0 +1,14 @@ +output "id" { + value = aws_vpc.this.id + description = "The ID of the VPC" +} + +output "cidr" { + value = aws_vpc.this.cidr_block + description = "The ID of the VPC" +} + +output "internet_gateway_id" { + value = aws_internet_gateway.this.id + description = "The ID of the Internet Gateway" +} \ No newline at end of file diff --git a/modules/vpc/variables.tf b/modules/vpc/variables.tf new file mode 100644 index 0000000..1da7f18 --- /dev/null +++ b/modules/vpc/variables.tf @@ -0,0 +1,23 @@ +variable "cidr" { + type = string + description = "CIDR Block" +} + +variable "name" { + type = string + description = "VPC name" +} + +variable "context" { + type = object({ + namespace = string + stage = string + name = string + }) + description = "Context" + default = { + namespace = "default" + stage = "default" + name = "default" + } +} \ No newline at end of file From 403eff6a053ff9f54f292a24166642ae5ecea34b Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 29 May 2024 13:37:48 +0000 Subject: [PATCH 2/6] chore: Update terraform docs --- examples/vpc/README.md | 17 ++++++++++++ modules/vpc-private-subnet/README.md | 40 +++++++++++++++++++++++++++ modules/vpc-public-subnet/README.md | 41 ++++++++++++++++++++++++++++ modules/vpc/README.md | 33 ++++++++++++++++++++++ 4 files changed, 131 insertions(+) create mode 100644 examples/vpc/README.md diff --git a/examples/vpc/README.md b/examples/vpc/README.md new file mode 100644 index 0000000..b1a5c98 --- /dev/null +++ b/examples/vpc/README.md @@ -0,0 +1,17 @@ + +## Requirements + +| Name | Version | +|------|---------| +| [terraform](#requirement\_terraform) | ~> 1.0 | +| [aws](#requirement\_aws) | ~> 4.0 | + +## Modules + +| Name | Source | Version | +|------|--------|---------| +| [database\_subnet](#module\_database\_subnet) | ../../modules/vpc-private-subnet | n/a | +| [private\_subnet](#module\_private\_subnet) | ../../modules/vpc-private-subnet | n/a | +| [public\_subnet](#module\_public\_subnet) | ../../modules/vpc-public-subnet | n/a | +| [vpc](#module\_vpc) | ../../modules/vpc | n/a | + \ No newline at end of file diff --git a/modules/vpc-private-subnet/README.md b/modules/vpc-private-subnet/README.md index 84b9842..30c71c1 100644 --- a/modules/vpc-private-subnet/README.md +++ b/modules/vpc-private-subnet/README.md @@ -3,3 +3,43 @@ ## Usage ## Output + + + + +## Providers + +| Name | Version | +|------|---------| +| [aws](#provider\_aws) | n/a | +| [random](#provider\_random) | n/a | + +## Resources + +| Name | Type | +|------|------| +| [aws_db_subnet_group.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/db_subnet_group) | resource | +| [aws_route.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route) | resource | +| [aws_route_table.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route_table) | resource | +| [aws_route_table_association.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route_table_association) | resource | +| [aws_subnet.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/subnet) | resource | +| [random_id.this](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/id) | resource | + +## Inputs + +| Name | Description | Type | Default | Required | +|------|-------------|------|---------|:--------:| +| [config](#input\_config) | Subnet configuration |
map(object({
az = string
cidr = string
}))
| n/a | yes | +| [context](#input\_context) | Context |
object({
namespace = string
stage = string
name = string
})
|
{
"name": "default",
"namespace": "default",
"stage": "default"
}
| no | +| [database\_subnet](#input\_database\_subnet) | Database subnet group | `bool` | `false` | no | +| [nat\_gateway\_routing](#input\_nat\_gateway\_routing) | NAT Gateway routing | `map(string)` | `{}` | no | +| [vpc\_id](#input\_vpc\_id) | VPC ID | `string` | n/a | yes | + +## Outputs + +| Name | Description | +|------|-------------| +| [database\_subnet\_group\_id](#output\_database\_subnet\_group\_id) | Database subnet group ID | +| [ids](#output\_ids) | Subnet IDs sorted by key | +| [subnets](#output\_subnets) | Subnet IDs by AZ | + \ No newline at end of file diff --git a/modules/vpc-public-subnet/README.md b/modules/vpc-public-subnet/README.md index 84b9842..6b970a2 100644 --- a/modules/vpc-public-subnet/README.md +++ b/modules/vpc-public-subnet/README.md @@ -3,3 +3,44 @@ ## Usage ## Output + + + + +## Providers + +| Name | Version | +|------|---------| +| [aws](#provider\_aws) | n/a | +| [random](#provider\_random) | n/a | + +## Resources + +| Name | Type | +|------|------| +| [aws_eip.nat](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/eip) | resource | +| [aws_nat_gateway.nat](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/nat_gateway) | resource | +| [aws_route.public_internet_gateway](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route) | resource | +| [aws_route_table.main](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route_table) | resource | +| [aws_route_table_association.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route_table_association) | resource | +| [aws_subnet.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/subnet) | resource | +| [random_id.this](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/id) | resource | + +## Inputs + +| Name | Description | Type | Default | Required | +|------|-------------|------|---------|:--------:| +| [config](#input\_config) | Subnet configuration |
map(object({
az = string
cidr = string
nat = bool
}))
| n/a | yes | +| [context](#input\_context) | Context |
object({
namespace = string
stage = string
name = string
})
|
{
"name": "default",
"namespace": "default",
"stage": "default"
}
| no | +| [internet\_gateway\_id](#input\_internet\_gateway\_id) | Internet Gateway ID | `string` | n/a | yes | +| [vpc\_id](#input\_vpc\_id) | VPC ID | `string` | n/a | yes | + +## Outputs + +| Name | Description | +|------|-------------| +| [ids](#output\_ids) | Subnet IDs sorted by key | +| [nat\_gateways](#output\_nat\_gateways) | NAT Gateway IDs by AZ | +| [nat\_ips](#output\_nat\_ips) | NAT Elastic IPs by AZ | +| [subnets](#output\_subnets) | Subnet IDs by AZ | + \ No newline at end of file diff --git a/modules/vpc/README.md b/modules/vpc/README.md index 17e1c6e..8041728 100644 --- a/modules/vpc/README.md +++ b/modules/vpc/README.md @@ -3,3 +3,36 @@ ## Usage ## Output + + + + +## Providers + +| Name | Version | +|------|---------| +| [aws](#provider\_aws) | n/a | + +## Resources + +| Name | Type | +|------|------| +| [aws_internet_gateway.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/internet_gateway) | resource | +| [aws_vpc.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/vpc) | resource | + +## Inputs + +| Name | Description | Type | Default | Required | +|------|-------------|------|---------|:--------:| +| [cidr](#input\_cidr) | CIDR Block | `string` | n/a | yes | +| [context](#input\_context) | Context |
object({
namespace = string
stage = string
name = string
})
|
{
"name": "default",
"namespace": "default",
"stage": "default"
}
| no | +| [name](#input\_name) | VPC name | `string` | n/a | yes | + +## Outputs + +| Name | Description | +|------|-------------| +| [cidr](#output\_cidr) | The ID of the VPC | +| [id](#output\_id) | The ID of the VPC | +| [internet\_gateway\_id](#output\_internet\_gateway\_id) | The ID of the Internet Gateway | + \ No newline at end of file From 49aa95c62ec592858465fc46ee2c2c6ef2528d70 Mon Sep 17 00:00:00 2001 From: qbart Date: Wed, 29 May 2024 15:45:21 +0200 Subject: [PATCH 3/6] fix: Lint versions --- modules/vpc-private-subnet/versions.tf | 10 ++++++++++ modules/vpc-public-subnet/versions.tf | 10 ++++++++++ modules/vpc/versions.tf | 10 ++++++++++ 3 files changed, 30 insertions(+) create mode 100644 modules/vpc-private-subnet/versions.tf create mode 100644 modules/vpc-public-subnet/versions.tf create mode 100644 modules/vpc/versions.tf diff --git a/modules/vpc-private-subnet/versions.tf b/modules/vpc-private-subnet/versions.tf new file mode 100644 index 0000000..5b01df2 --- /dev/null +++ b/modules/vpc-private-subnet/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = "~> 1.0" + + required_providers { + aws = { + source = "hashicorp/aws" + version = "~> 4.0" + } + } +} \ No newline at end of file diff --git a/modules/vpc-public-subnet/versions.tf b/modules/vpc-public-subnet/versions.tf new file mode 100644 index 0000000..5b01df2 --- /dev/null +++ b/modules/vpc-public-subnet/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = "~> 1.0" + + required_providers { + aws = { + source = "hashicorp/aws" + version = "~> 4.0" + } + } +} \ No newline at end of file diff --git a/modules/vpc/versions.tf b/modules/vpc/versions.tf new file mode 100644 index 0000000..5b01df2 --- /dev/null +++ b/modules/vpc/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = "~> 1.0" + + required_providers { + aws = { + source = "hashicorp/aws" + version = "~> 4.0" + } + } +} \ No newline at end of file From 443623afe7b12b42331773c16bf4565e4864edff Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 29 May 2024 13:45:41 +0000 Subject: [PATCH 4/6] chore: Update terraform docs --- modules/vpc-private-subnet/README.md | 7 ++++++- modules/vpc-public-subnet/README.md | 7 ++++++- modules/vpc/README.md | 7 ++++++- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/modules/vpc-private-subnet/README.md b/modules/vpc-private-subnet/README.md index 30c71c1..5c137c0 100644 --- a/modules/vpc-private-subnet/README.md +++ b/modules/vpc-private-subnet/README.md @@ -5,13 +5,18 @@ ## Output +## Requirements +| Name | Version | +|------|---------| +| [terraform](#requirement\_terraform) | ~> 1.0 | +| [aws](#requirement\_aws) | ~> 4.0 | ## Providers | Name | Version | |------|---------| -| [aws](#provider\_aws) | n/a | +| [aws](#provider\_aws) | ~> 4.0 | | [random](#provider\_random) | n/a | ## Resources diff --git a/modules/vpc-public-subnet/README.md b/modules/vpc-public-subnet/README.md index 6b970a2..decfd28 100644 --- a/modules/vpc-public-subnet/README.md +++ b/modules/vpc-public-subnet/README.md @@ -5,13 +5,18 @@ ## Output +## Requirements +| Name | Version | +|------|---------| +| [terraform](#requirement\_terraform) | ~> 1.0 | +| [aws](#requirement\_aws) | ~> 4.0 | ## Providers | Name | Version | |------|---------| -| [aws](#provider\_aws) | n/a | +| [aws](#provider\_aws) | ~> 4.0 | | [random](#provider\_random) | n/a | ## Resources diff --git a/modules/vpc/README.md b/modules/vpc/README.md index 8041728..0cfa8d6 100644 --- a/modules/vpc/README.md +++ b/modules/vpc/README.md @@ -5,13 +5,18 @@ ## Output +## Requirements +| Name | Version | +|------|---------| +| [terraform](#requirement\_terraform) | ~> 1.0 | +| [aws](#requirement\_aws) | ~> 4.0 | ## Providers | Name | Version | |------|---------| -| [aws](#provider\_aws) | n/a | +| [aws](#provider\_aws) | ~> 4.0 | ## Resources From 6d8ade099a08b4ffede416df5cdffeb00e96a174 Mon Sep 17 00:00:00 2001 From: qbart Date: Wed, 29 May 2024 15:45:21 +0200 Subject: [PATCH 5/6] fix: Lint versions --- modules/ecs-service/versions.tf | 6 +++--- modules/vpc-private-subnet/versions.tf | 7 ++++++- modules/vpc-public-subnet/versions.tf | 7 ++++++- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/modules/ecs-service/versions.tf b/modules/ecs-service/versions.tf index 0567f49..8a30ed4 100644 --- a/modules/ecs-service/versions.tf +++ b/modules/ecs-service/versions.tf @@ -8,8 +8,8 @@ terraform { } random = { - source = "hashicorp/random" - version = "~> 3.0" + source = "hashicorp/random" + version = "~> 3.0" } } -} \ No newline at end of file +} diff --git a/modules/vpc-private-subnet/versions.tf b/modules/vpc-private-subnet/versions.tf index 5b01df2..8a30ed4 100644 --- a/modules/vpc-private-subnet/versions.tf +++ b/modules/vpc-private-subnet/versions.tf @@ -6,5 +6,10 @@ terraform { source = "hashicorp/aws" version = "~> 4.0" } + + random = { + source = "hashicorp/random" + version = "~> 3.0" + } } -} \ No newline at end of file +} diff --git a/modules/vpc-public-subnet/versions.tf b/modules/vpc-public-subnet/versions.tf index 5b01df2..8a30ed4 100644 --- a/modules/vpc-public-subnet/versions.tf +++ b/modules/vpc-public-subnet/versions.tf @@ -6,5 +6,10 @@ terraform { source = "hashicorp/aws" version = "~> 4.0" } + + random = { + source = "hashicorp/random" + version = "~> 3.0" + } } -} \ No newline at end of file +} From a31fb10123f33da088487e81a83c93e3a718200e Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 29 May 2024 13:53:40 +0000 Subject: [PATCH 6/6] chore: Update terraform docs --- modules/vpc-private-subnet/README.md | 3 ++- modules/vpc-public-subnet/README.md | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/vpc-private-subnet/README.md b/modules/vpc-private-subnet/README.md index 5c137c0..1ab6088 100644 --- a/modules/vpc-private-subnet/README.md +++ b/modules/vpc-private-subnet/README.md @@ -11,13 +11,14 @@ |------|---------| | [terraform](#requirement\_terraform) | ~> 1.0 | | [aws](#requirement\_aws) | ~> 4.0 | +| [random](#requirement\_random) | ~> 3.0 | ## Providers | Name | Version | |------|---------| | [aws](#provider\_aws) | ~> 4.0 | -| [random](#provider\_random) | n/a | +| [random](#provider\_random) | ~> 3.0 | ## Resources diff --git a/modules/vpc-public-subnet/README.md b/modules/vpc-public-subnet/README.md index decfd28..980b9d7 100644 --- a/modules/vpc-public-subnet/README.md +++ b/modules/vpc-public-subnet/README.md @@ -11,13 +11,14 @@ |------|---------| | [terraform](#requirement\_terraform) | ~> 1.0 | | [aws](#requirement\_aws) | ~> 4.0 | +| [random](#requirement\_random) | ~> 3.0 | ## Providers | Name | Version | |------|---------| | [aws](#provider\_aws) | ~> 4.0 | -| [random](#provider\_random) | n/a | +| [random](#provider\_random) | ~> 3.0 | ## Resources