From 4935e47eb99bc1b11521a833e0ba61ebe18b2178 Mon Sep 17 00:00:00 2001 From: Lukasz Stadnik Date: Mon, 10 Feb 2025 15:37:51 +0100 Subject: [PATCH] feat(module/subnet_set): ma_public_ip_on_launch per subnet --- modules/subnet_set/README.md | 3 +-- modules/subnet_set/main.tf | 2 +- modules/subnet_set/variables.tf | 7 +------ 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/modules/subnet_set/README.md b/modules/subnet_set/README.md index 8d41ed2..8e852d3 100644 --- a/modules/subnet_set/README.md +++ b/modules/subnet_set/README.md @@ -63,11 +63,10 @@ No modules. | Name | Description | Type | Default | Required | |------|-------------|------|---------|:--------:| -| [cidrs](#input\_cidrs) | Map describing configuration of subnets and route tables to create and/or use in the set.
Keys are CIDR blocks, values can consist of following items:
- `create_subnet` - (Optional\|bool) When `true` (default), subnet is created, otherwise existing one is used.
- `create_route_table` - (Optional\|bool) When `true` a dedicated route table is created, unless existing subnet is used.
- `associate_route_table` - (Optional\|bool) Unless set to `false`, route table is associated with the subnet.
- `existing_route_table_id` - (Optional\|string) Id of an existing route table to associate with the subnet.
- `name` - (Optional\|string) Name (tag) of a subnet and, optionally a route table, to create or use. Defaults to set name appended with zone letter id.
- `route_table_name` - (Optional\|string) Name (tag) of a subnet and, optionally a route table, to create or use. Defaults to `name` value.
- `ipv6_cidr_block` - (Optional\|string) IPv6 CIDR block. The subnet size must use a /64 prefix length.
- `local_tags` - (Optional\|map) Map of tags to assign to created resources. | `map(any)` | n/a | yes | +| [cidrs](#input\_cidrs) | Map describing configuration of subnets and route tables to create and/or use in the set.
Keys are CIDR blocks, values can consist of following items:
- `create_subnet` - (Optional\|bool) When `true` (default), subnet is created, otherwise existing one is used.
- `create_route_table` - (Optional\|bool) When `true` a dedicated route table is created, unless existing subnet is used.
- `associate_route_table` - (Optional\|bool) Unless set to `false`, route table is associated with the subnet.
- `existing_route_table_id` - (Optional\|string) Id of an existing route table to associate with the subnet.
- `name` - (Optional\|string) Name (tag) of a subnet and, optionally a route table, to create or use. Defaults to set name appended with zone letter id.
- `route_table_name` - (Optional\|string) Name (tag) of a subnet and, optionally a route table, to create or use. Defaults to `name` value.
- `ipv6_cidr_block` - (Optional\|string) IPv6 CIDR block. The subnet size must use a /64 prefix length.
- `map_public_ip_on_launch` - (Optional\|bool) Specify true to indicate that instances launched into the subnet should be assigned a public IP address.
- `local_tags` - (Optional\|map) Map of tags to assign to created resources. | `map(any)` | n/a | yes | | [create\_shared\_route\_table](#input\_create\_shared\_route\_table) | Boolean flag whether to create a shared route tables. | `bool` | `false` | no | | [global\_tags](#input\_global\_tags) | Optional map of arbitrary tags to apply to all the created resources. | `map(string)` | `{}` | no | | [has\_secondary\_cidrs](#input\_has\_secondary\_cidrs) | The input that depends on the secondary CIDR ranges of the VPC `vpc_id`. The actual value (true or false) is ignored, the input is used only to delay subnet creation until the secondary CIDR ranges are processed by Terraform. | `bool` | `true` | no | -| [map\_public\_ip\_on\_launch](#input\_map\_public\_ip\_on\_launch) | See the [provider's documentation](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/subnet#map_public_ip_on_launch). | `bool` | `null` | no | | [nacl\_associations](#input\_nacl\_associations) | NACLs associations with subnets | `map(string)` | `{}` | no | | [name](#input\_name) | Subnet set name, used to construct default subnet names. | `string` | `null` | no | | [propagating\_vgws](#input\_propagating\_vgws) | See the [provider's documentation](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route_table). | `list(string)` | `[]` | no | diff --git a/modules/subnet_set/main.tf b/modules/subnet_set/main.tf index e7a6c88..ee59cbd 100644 --- a/modules/subnet_set/main.tf +++ b/modules/subnet_set/main.tf @@ -38,7 +38,7 @@ resource "aws_subnet" "this" { ipv6_cidr_block = try(each.value.ipv6_cidr_block, null) availability_zone = each.key vpc_id = var.vpc_id - map_public_ip_on_launch = var.map_public_ip_on_launch + map_public_ip_on_launch = try(each.value.map_public_ip_on_launch, null) tags = merge(var.global_tags, each.value.local_tags, { Name = each.value.name }) depends_on = [ diff --git a/modules/subnet_set/variables.tf b/modules/subnet_set/variables.tf index dba30c1..51f8f3b 100644 --- a/modules/subnet_set/variables.tf +++ b/modules/subnet_set/variables.tf @@ -15,6 +15,7 @@ variable "cidrs" { - `name` - (Optional|string) Name (tag) of a subnet and, optionally a route table, to create or use. Defaults to set name appended with zone letter id. - `route_table_name` - (Optional|string) Name (tag) of a subnet and, optionally a route table, to create or use. Defaults to `name` value. - `ipv6_cidr_block` - (Optional|string) IPv6 CIDR block. The subnet size must use a /64 prefix length. + - `map_public_ip_on_launch` - (Optional|bool) Specify true to indicate that instances launched into the subnet should be assigned a public IP address. - `local_tags` - (Optional|map) Map of tags to assign to created resources. EOF type = map(any) @@ -31,12 +32,6 @@ variable "create_shared_route_table" { type = bool } -variable "map_public_ip_on_launch" { - description = "See the [provider's documentation](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/subnet#map_public_ip_on_launch)." - default = null - type = bool -} - variable "propagating_vgws" { description = "See the [provider's documentation](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route_table)." default = []