From 0ac4a4e35dc67d6f3e8275d7a07c0f602b8cbcec Mon Sep 17 00:00:00 2001 From: Vijay John Stephen Date: Thu, 24 Oct 2024 23:30:45 +0530 Subject: [PATCH] removed unwanted modules --- .terraform.lock.hcl | 23 ---- README.md | 1 - modules/subnets/.terraform-version | 1 - modules/subnets/.terraform.lock.hcl | 26 ---- modules/subnets/README.md | 73 ----------- modules/subnets/locals.tf | 15 --- modules/subnets/main.tf | 186 ---------------------------- modules/subnets/outputs.tf | 50 -------- modules/subnets/variables.tf | 146 ---------------------- versions.tf | 5 - 10 files changed, 526 deletions(-) delete mode 100644 modules/subnets/.terraform-version delete mode 100644 modules/subnets/.terraform.lock.hcl delete mode 100644 modules/subnets/README.md delete mode 100644 modules/subnets/locals.tf delete mode 100644 modules/subnets/main.tf delete mode 100644 modules/subnets/outputs.tf delete mode 100644 modules/subnets/variables.tf diff --git a/.terraform.lock.hcl b/.terraform.lock.hcl index 1ca19aa..dda8f95 100644 --- a/.terraform.lock.hcl +++ b/.terraform.lock.hcl @@ -1,29 +1,6 @@ # This file is maintained automatically by "terraform init". # Manual edits may be lost in future updates. -provider "registry.terraform.io/cloudposse/awsutils" { - version = "0.15.0" - constraints = ">= 0.15.0" - hashes = [ - "h1:L7SFFKdGXSdtui8mROf3aMJIcljEgxw/YH1ShbZrajY=", - "h1:Oj2vUB7rFx4jK9GaqIAQhrX6PScz82m5SpRDBAN/++0=", - "zh:0ebc5f3d236915f4c2e2cf77cb20a2e234e5cd0398e9377838ba2c5c81e098b4", - "zh:1921b87d2afb0afb1a211e9b997c2be36dabeaeeaae8e3d57bcdccb9e3499597", - "zh:39edbbf93feccdc9374b7592318f816b2bbd51aaf0493386ebcf3f6c1d55eeeb", - "zh:4534f0182e8acda0669a7eb9fcf0411392724f89bbbe4f4f3008fbd13efccc1c", - "zh:51238cdd6f92c544d45df5f874893eacdb76ba78ca134637af0a6c58af3c2d78", - "zh:6c71dccb64979e1562c01b1e233d09c7b5175dccab459864868d013d37132993", - "zh:81fce9fe59f2edf021c3865f0f78d60dbc3c05bf98ce9b91b2ce152e830f18c3", - "zh:84bf715f2d337de502815d4dec79ff48572920c9cc5deb2ec4936e144e9fc4a9", - "zh:8cb34b159da8973e9431f4157350b157d1150432f5a83069fd467ef51bd06ad1", - "zh:8d14bd66cf0bcb6bb7d6120667c28954b8da8efeecc8e9c508b0752c9c81a40b", - "zh:916b19d72922c3ff78f989b498040c351e7e41395b0d677bdfc774a617337c20", - "zh:bb8fd6878afa8eefc2b9e15f3a237e817b92832457938230c3c9de176c5bf70f", - "zh:bf885c0e987abd604497c4b9ab93029dd2214ac4d60533891d2d225f5fc52481", - "zh:f580afb656b8e31dd05ff27295dfdbdf4ed0158e6c592f391ae13cf9eba02d88", - ] -} - provider "registry.terraform.io/hashicorp/aws" { version = "4.57.0" constraints = ">= 4.0.0, < 6.0.0" diff --git a/README.md b/README.md index 86fe900..f5ab786 100644 --- a/README.md +++ b/README.md @@ -157,7 +157,6 @@ locals { |------|---------| | [terraform](#requirement\_terraform) | >= 1.3, < 2.0.0 | | [aws](#requirement\_aws) | >= 4.0, < 6.0 | -| [awsutils](#requirement\_awsutils) | >= 0.15 | ## Providers diff --git a/modules/subnets/.terraform-version b/modules/subnets/.terraform-version deleted file mode 100644 index e47cceb..0000000 --- a/modules/subnets/.terraform-version +++ /dev/null @@ -1 +0,0 @@ -latest:^1.4 diff --git a/modules/subnets/.terraform.lock.hcl b/modules/subnets/.terraform.lock.hcl deleted file mode 100644 index 329fa9d..0000000 --- a/modules/subnets/.terraform.lock.hcl +++ /dev/null @@ -1,26 +0,0 @@ -# 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.0" - hashes = [ - "h1:5Zfo3GfRSWBaXs4TGQNOflr1XaYj6pRnVJLX5VAjFX4=", - "h1:P43vwcDPG99x5WBbmqwUPgfJrfXf6/ucAIbGlRb7k1w=", - "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", - ] -} diff --git a/modules/subnets/README.md b/modules/subnets/README.md deleted file mode 100644 index 7a63330..0000000 --- a/modules/subnets/README.md +++ /dev/null @@ -1,73 +0,0 @@ -# Terraform Module: Subnets - -## Overview - -AWS Subnets for the ARC Infrastructure. - - -## Requirements - -| Name | Version | -|------|---------| -| [terraform](#requirement\_terraform) | >= 1.3, < 2.0.0 | -| [aws](#requirement\_aws) | >= 4.0, < 6.0 | - -## Providers - -| Name | Version | -|------|---------| -| [aws](#provider\_aws) | 4.67.0 | - -## Modules - -No modules. - -## Resources - -| Name | Type | -|------|------| -| [aws_eip.public](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/eip) | resource | -| [aws_nat_gateway.public](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/nat_gateway) | resource | -| [aws_network_acl.private](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/network_acl) | resource | -| [aws_route.default](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route) | resource | -| [aws_route.public](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route) | resource | -| [aws_route_table.private](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route_table) | resource | -| [aws_route_table.public](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route_table) | resource | -| [aws_route_table_association.private](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route_table_association) | resource | -| [aws_route_table_association.public](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route_table_association) | resource | -| [aws_subnet.private](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/subnet) | resource | -| [aws_subnet.public](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/subnet) | resource | - -## Inputs - -| Name | Description | Type | Default | Required | -|------|-------------|------|---------|:--------:| -| [az\_ngw\_ids](#input\_az\_ngw\_ids) | Only for private subnets. Map of AZ names to NAT Gateway IDs that are used as default routes when creating private subnets.
You should either supply one NAT Gateway ID for each AZ in `var.availability_zones` or leave the map empty.
If empty, no default egress route will be created and you will have to create your own using `aws_route`. | `map(string)` | `{}` | no | -| [create\_aws\_network\_acl](#input\_create\_aws\_network\_acl) | This indicates whether to create aws network acl or not | `bool` | n/a | yes | -| [igw\_id](#input\_igw\_id) | Internet Gateway ID that is used as a default route when creating public subnets (e.g. `igw-9c26a123`) | `string` | `""` | no | -| [nat\_gateway\_enabled](#input\_nat\_gateway\_enabled) | Enable the NAT Gateway between public and private subnets | `bool` | `true` | no | -| [private\_network\_acl\_egress](#input\_private\_network\_acl\_egress) | Egress network ACL rules |
list(object({
rule_no = number
action = string
cidr_block = string
from_port = number
to_port = number
protocol = string
icmp_code = optional(string, null)
icmp_type = optional(string, null)
ipv6_cidr_block = optional(string, null)
}))
|
[
{
"action": "allow",
"cidr_block": "0.0.0.0/0",
"from_port": 0,
"protocol": "-1",
"rule_no": 100,
"to_port": 0
}
]
| no | -| [private\_network\_acl\_ingress](#input\_private\_network\_acl\_ingress) | Ingress network ACL rules |
list(object({
rule_no = number
action = string
cidr_block = string
from_port = number
to_port = number
protocol = string
icmp_code = optional(string, null)
icmp_type = optional(string, null)
ipv6_cidr_block = optional(string, null)
}))
|
[
{
"action": "allow",
"cidr_block": "0.0.0.0/0",
"from_port": 0,
"protocol": "-1",
"rule_no": 100,
"to_port": 0
}
]
| no | -| [private\_network\_acl\_subnet\_ids](#input\_private\_network\_acl\_subnet\_ids) | Private network ACL Subnet IDs. This is typically unused due to using the `default_network_acl_id`. | `list(string)` | `[]` | no | -| [private\_route\_table\_additional\_tags](#input\_private\_route\_table\_additional\_tags) | Additional tags to add to the private route table | `map(string)` | `{}` | no | -| [private\_subnets](#input\_private\_subnets) | List of private subnets to add to the VPC |
list(object({
name = string
availability_zone = string
cidr_block = string
tags = optional(map(string), {})
}))
| n/a | yes | -| [public\_route\_table\_additional\_tags](#input\_public\_route\_table\_additional\_tags) | Additional tags to add to the public route table | `map(string)` | `{}` | no | -| [public\_subnets](#input\_public\_subnets) | List of public subnets to add to the VPC |
list(object({
name = string
availability_zone = string
cidr_block = string
map_public_ip_on_launch = optional(bool, false)
igw_id = optional(string, "")
tags = optional(map(string), {})
}))
| n/a | yes | -| [route\_table\_association\_enabled](#input\_route\_table\_association\_enabled) | If the route table has an association. | `bool` | `true` | no | -| [tags](#input\_tags) | Default tags to apply to every resource | `map(string)` | n/a | yes | -| [vpc\_id](#input\_vpc\_id) | VPC ID to create the cluster in (e.g. `vpc-a22222ee`) | `string` | n/a | yes | - -## Outputs - -| Name | Description | -|------|-------------| -| [private\_route\_table\_ids](#output\_private\_route\_table\_ids) | Map of AZ names to Route Table IDs | -| [private\_subnet\_arns](#output\_private\_subnet\_arns) | Map of AZ names to subnet ARNs | -| [private\_subnet\_cidr\_blocks](#output\_private\_subnet\_cidr\_blocks) | Map of AZ names to subnet CIDR blocks | -| [private\_subnet\_ids](#output\_private\_subnet\_ids) | Map of AZ names to subnet IDs | -| [public\_ngw\_ids](#output\_public\_ngw\_ids) | Map of AZ names to NAT Gateway IDs (only for public subnets) | -| [public\_route\_table\_ids](#output\_public\_route\_table\_ids) | Map of AZ names to Route Table IDs | -| [public\_subnet\_arns](#output\_public\_subnet\_arns) | Map of AZ names to subnet ARNs | -| [public\_subnet\_cidr\_blocks](#output\_public\_subnet\_cidr\_blocks) | Map of AZ names to subnet CIDR blocks | -| [public\_subnet\_ids](#output\_public\_subnet\_ids) | Map of AZ names to subnet IDs | - diff --git a/modules/subnets/locals.tf b/modules/subnets/locals.tf deleted file mode 100644 index c31207e..0000000 --- a/modules/subnets/locals.tf +++ /dev/null @@ -1,15 +0,0 @@ -locals { - // The following locals map a private subnet to respective public subnet, - // and if nat_gateway_enabled is true then this is used to update - // routes to public internet in the respective private subnet in the following local. - // If it is not true then it takes the value from the variable az_ngw_ids - // and maps it to the private subnet. If even that is empty, - // then no routes to public internet are added. - public_internet_mapping = { for x in var.private_subnets : x.name => replace(x.name, "-private-", "-public-") if var.nat_gateway_enabled == true } - - subnet_ngw_ids_resource = { for x in var.private_subnets : x.name => var.nat_gateway_enabled == true ? aws_nat_gateway.public[local.public_internet_mapping[x.name]].id : null } - - subnet_ngw_ids_custom = { for x in var.private_subnets : x.name => lookup(var.az_ngw_ids, x.availability_zone, null) } - - subnet_ngw_ids = var.nat_gateway_enabled == true ? local.subnet_ngw_ids_resource : { for key, value in local.subnet_ngw_ids_custom : key => value if value != null } -} diff --git a/modules/subnets/main.tf b/modules/subnets/main.tf deleted file mode 100644 index 4be1ab0..0000000 --- a/modules/subnets/main.tf +++ /dev/null @@ -1,186 +0,0 @@ -################################################################################ -## defaults -################################################################################ -terraform { - required_version = ">= 1.3, < 2.0.0" - - required_providers { - aws = { - source = "hashicorp/aws" - version = ">= 4.0, < 6.0" - } - } -} - -################################################################################ -## private -################################################################################ -## subnet -resource "aws_subnet" "private" { - for_each = { for x in var.private_subnets : x.name => x } - - vpc_id = var.vpc_id - availability_zone = each.value.availability_zone - cidr_block = each.value.cidr_block - - tags = merge(var.tags, each.value.tags, tomap({ - Name = each.value.name - })) -} - -## network acl -resource "aws_network_acl" "private" { - count = var.create_aws_network_acl == true ? 1 : 0 - - vpc_id = var.vpc_id - subnet_ids = var.private_network_acl_subnet_ids - - dynamic "ingress" { - for_each = var.private_network_acl_ingress - - content { - rule_no = ingress.value.rule_no - action = ingress.value.action - cidr_block = ingress.value.cidr_block - from_port = ingress.value.from_port - to_port = ingress.value.to_port - protocol = ingress.value.protocol - icmp_code = ingress.value.icmp_code - icmp_type = ingress.value.icmp_type - ipv6_cidr_block = ingress.value.ipv6_cidr_block - } - } - - dynamic "egress" { - for_each = var.private_network_acl_egress - - content { - rule_no = egress.value.rule_no - action = egress.value.action - cidr_block = egress.value.cidr_block - from_port = egress.value.from_port - to_port = egress.value.to_port - protocol = egress.value.protocol - icmp_code = egress.value.icmp_code - icmp_type = egress.value.icmp_type - ipv6_cidr_block = egress.value.ipv6_cidr_block - } - } - - tags = var.tags - depends_on = [aws_subnet.private] -} - -## route table -resource "aws_route_table" "private" { - for_each = { for x in var.private_subnets : x.name => x } - - vpc_id = var.vpc_id - - tags = merge(var.tags, var.private_route_table_additional_tags, tomap({ - Name = each.value.name - }), - ) -} - -resource "aws_route" "default" { - for_each = local.subnet_ngw_ids - - route_table_id = aws_route_table.private[each.key].id - nat_gateway_id = each.value - destination_cidr_block = "0.0.0.0/0" - - depends_on = [aws_route_table.private] -} - -resource "aws_route_table_association" "private" { - for_each = { for x in var.private_subnets : x.name => x } - - subnet_id = aws_subnet.private[each.key].id - route_table_id = aws_route_table.private[each.key].id - - depends_on = [ - aws_subnet.private, - aws_route_table.private, - ] -} - -################################################################################ -## public -################################################################################ -## subnet -resource "aws_subnet" "public" { - for_each = { for x in var.public_subnets : x.name => x } - - vpc_id = var.vpc_id - availability_zone = each.value.availability_zone - cidr_block = each.value.cidr_block - map_public_ip_on_launch = each.value.map_public_ip_on_launch - - tags = merge(var.tags, each.value.tags, tomap({ - Name = each.value.name - })) -} - -resource "aws_route_table" "public" { - for_each = { for x in var.public_subnets : x.name => x } - - vpc_id = var.vpc_id - - tags = merge(var.tags, var.public_route_table_additional_tags, tomap({ - Name = each.value.name - })) -} - -resource "aws_route" "public" { - for_each = { for x in var.public_subnets : x.name => x } - - route_table_id = aws_route_table.public[each.key].id - gateway_id = var.igw_id - destination_cidr_block = "0.0.0.0/0" - - depends_on = [aws_route_table.public] -} - -resource "aws_route_table_association" "public" { - for_each = { for x in var.public_subnets : x.name => x if var.route_table_association_enabled == true } - - subnet_id = aws_subnet.public[each.key].id - route_table_id = aws_route_table.public[each.key].id - - depends_on = [ - aws_subnet.public, - aws_route_table.public, - ] -} - -## elastic public ip -resource "aws_eip" "public" { - for_each = { for x in var.public_subnets : x.name => x if var.nat_gateway_enabled == true } - - tags = merge(var.tags, tomap({ - Name = each.value.name - })) - - lifecycle { - create_before_destroy = true - } -} - -## nat gateway -resource "aws_nat_gateway" "public" { - for_each = { for x in var.public_subnets : x.name => x if var.nat_gateway_enabled == true } - - allocation_id = aws_eip.public[each.key].id - subnet_id = aws_subnet.public[each.key].id - - tags = merge(var.tags, tomap({ - Name = each.value.name - })) - - depends_on = [aws_subnet.public] - - lifecycle { - create_before_destroy = true - } -} diff --git a/modules/subnets/outputs.tf b/modules/subnets/outputs.tf deleted file mode 100644 index 4cd0bfe..0000000 --- a/modules/subnets/outputs.tf +++ /dev/null @@ -1,50 +0,0 @@ -################################################################################ -## private -################################################################################ -output "private_subnet_ids" { - description = "Map of AZ names to subnet IDs" - value = { for k, v in aws_subnet.private : k => v.id } -} - -output "private_subnet_arns" { - description = "Map of AZ names to subnet ARNs" - value = { for k, v in aws_subnet.private : k => v.arn } -} - -output "private_subnet_cidr_blocks" { - description = "Map of AZ names to subnet CIDR blocks" - value = { for k, v in aws_subnet.private : k => v.cidr_block } -} - -output "private_route_table_ids" { - description = " Map of AZ names to Route Table IDs" - value = { for k, v in aws_route_table.private : k => v.id } -} - -################################################################################ -## public -################################################################################ -output "public_subnet_ids" { - description = "Map of AZ names to subnet IDs" - value = { for k, v in aws_subnet.public : k => v.id } -} - -output "public_subnet_arns" { - description = "Map of AZ names to subnet ARNs" - value = { for k, v in aws_subnet.public : k => v.arn } -} - -output "public_subnet_cidr_blocks" { - description = "Map of AZ names to subnet CIDR blocks" - value = { for k, v in aws_subnet.public : k => v.cidr_block } -} - -output "public_route_table_ids" { - description = " Map of AZ names to Route Table IDs" - value = { for k, v in aws_route_table.public : k => v.id } -} - -output "public_ngw_ids" { - description = "Map of AZ names to NAT Gateway IDs (only for public subnets)" - value = { for k, v in aws_nat_gateway.public : k => v.id } -} diff --git a/modules/subnets/variables.tf b/modules/subnets/variables.tf deleted file mode 100644 index 6744b4a..0000000 --- a/modules/subnets/variables.tf +++ /dev/null @@ -1,146 +0,0 @@ -################################################################################ -## shared -################################################################################ -variable "vpc_id" { - type = string - description = "VPC ID to create the cluster in (e.g. `vpc-a22222ee`)" -} - -variable "tags" { - type = map(string) - description = "Default tags to apply to every resource" -} - -################################################################################ -## default -################################################################################ -variable "private_network_acl_subnet_ids" { - type = list(string) - description = "Private network ACL Subnet IDs. This is typically unused due to using the `default_network_acl_id`." - default = [] -} - -################################################################################ -## private -################################################################################ -variable "nat_gateway_enabled" { - description = "Enable the NAT Gateway between public and private subnets" - type = bool - default = true -} - -variable "private_subnets" { - description = "List of private subnets to add to the VPC" - type = list(object({ - name = string - availability_zone = string - cidr_block = string - tags = optional(map(string), {}) - })) -} - -variable "private_network_acl_ingress" { - description = "Ingress network ACL rules" - type = list(object({ - rule_no = number - action = string - cidr_block = string - from_port = number - to_port = number - protocol = string - icmp_code = optional(string, null) - icmp_type = optional(string, null) - ipv6_cidr_block = optional(string, null) - })) - - default = [ - { - rule_no = 100 - action = "allow" - cidr_block = "0.0.0.0/0" - from_port = 0 - to_port = 0 - protocol = "-1" - }, - ] -} - -variable "private_network_acl_egress" { - description = "Egress network ACL rules" - type = list(object({ - rule_no = number - action = string - cidr_block = string - from_port = number - to_port = number - protocol = string - icmp_code = optional(string, null) - icmp_type = optional(string, null) - ipv6_cidr_block = optional(string, null) - })) - - default = [ - { - rule_no = 100 - action = "allow" - cidr_block = "0.0.0.0/0" - from_port = 0 - to_port = 0 - protocol = "-1" - }, - ] -} - -variable "az_ngw_ids" { - type = map(string) - description = <<-EOT - Only for private subnets. Map of AZ names to NAT Gateway IDs that are used as default routes when creating private subnets. - You should either supply one NAT Gateway ID for each AZ in `var.availability_zones` or leave the map empty. - If empty, no default egress route will be created and you will have to create your own using `aws_route`. - EOT - default = {} -} - -################################################################################ -## public -################################################################################ -variable "route_table_association_enabled" { - description = "If the route table has an association." - type = bool - default = true -} - -variable "public_route_table_additional_tags" { - description = "Additional tags to add to the public route table" - type = map(string) - default = {} -} - -variable "private_route_table_additional_tags" { - description = "Additional tags to add to the private route table" - type = map(string) - default = {} -} - -variable "public_subnets" { - description = "List of public subnets to add to the VPC" - type = list(object({ - name = string - availability_zone = string - cidr_block = string - map_public_ip_on_launch = optional(bool, false) - igw_id = optional(string, "") - tags = optional(map(string), {}) - })) -} - -variable "igw_id" { - type = string - description = "Internet Gateway ID that is used as a default route when creating public subnets (e.g. `igw-9c26a123`)" - default = "" -} - -variable "create_aws_network_acl" { - type = bool - description = "This indicates whether to create aws network acl or not" -} diff --git a/versions.tf b/versions.tf index 306322a..e2f112a 100644 --- a/versions.tf +++ b/versions.tf @@ -9,10 +9,5 @@ terraform { source = "hashicorp/aws" version = ">= 4.0, < 6.0" } - - awsutils = { - source = "cloudposse/awsutils" - version = ">= 0.15" - } } }