From 25920cfe94d944db6d0d2715621851c3bfd0998a Mon Sep 17 00:00:00 2001 From: Vinod Dampuru Date: Fri, 3 Jan 2025 11:02:32 +0800 Subject: [PATCH 1/3] feat: Add vpc_lattice_configuration for service --- main.tf | 1 + modules/service/README.md | 1 + modules/service/main.tf | 10 ++++++++++ modules/service/variables.tf | 6 ++++++ wrappers/service/main.tf | 1 + 5 files changed, 19 insertions(+) diff --git a/main.tf b/main.tf index 5e380de7..54cb442f 100644 --- a/main.tf +++ b/main.tf @@ -82,6 +82,7 @@ module "service" { propagate_tags = try(each.value.propagate_tags, null) scheduling_strategy = try(each.value.scheduling_strategy, null) service_connect_configuration = lookup(each.value, "service_connect_configuration", {}) + vpc_lattice_configuration = lookup(each.value, "vpc_lattice_configuration", {}) service_registries = lookup(each.value, "service_registries", {}) timeouts = try(each.value.timeouts, {}) triggers = try(each.value.triggers, {}) diff --git a/modules/service/README.md b/modules/service/README.md index 4faaf8f1..c5929465 100644 --- a/modules/service/README.md +++ b/modules/service/README.md @@ -288,6 +288,7 @@ module "ecs_service" { | [security\_group\_use\_name\_prefix](#input\_security\_group\_use\_name\_prefix) | Determines whether the security group name (`security_group_name`) is used as a prefix | `bool` | `true` | no | | [service\_connect\_configuration](#input\_service\_connect\_configuration) | The ECS Service Connect configuration for this service to discover and connect to services, and be discovered by, and connected from, other services within a namespace | `any` | `{}` | no | | [service\_registries](#input\_service\_registries) | Service discovery registries for the service | `any` | `{}` | no | +| [vpc\_lattice\_configuration](#input\_vpc\_lattice\_configuration) | The VPC Lattice configuration for your service that allows Lattice to connect, secure, and monitor your service across multiple accounts and VPCs | `any` | `{}` | no | | [service\_tags](#input\_service\_tags) | A map of additional tags to add to the service | `map(string)` | `{}` | no | | [skip\_destroy](#input\_skip\_destroy) | If true, the task is not deleted when the service is deleted | `bool` | `null` | no | | [subnet\_ids](#input\_subnet\_ids) | List of subnets to associate with the task or service | `list(string)` | `[]` | no | diff --git a/modules/service/main.tf b/modules/service/main.tf index b7ecef9e..75f67edb 100644 --- a/modules/service/main.tf +++ b/modules/service/main.tf @@ -188,6 +188,16 @@ resource "aws_ecs_service" "this" { } } + dynamic "vpc_lattice_configuration" { + for_each = length(var.vpc_lattice_configuration) > 0 ? [var.vpc_lattice_configuration] : [] + + content { + role_arn = try(vpc_lattice_configuration.value.role_arn, null) + target_group_arn = try(vpc_lattice_configuration.value.target_group_arn, null) + port_name = try(vpc_lattice_configuration.value.port_name, null) + } + } + task_definition = local.task_definition triggers = var.triggers wait_for_steady_state = var.wait_for_steady_state diff --git a/modules/service/variables.tf b/modules/service/variables.tf index 9a55e989..0f5e99cb 100644 --- a/modules/service/variables.tf +++ b/modules/service/variables.tf @@ -176,6 +176,12 @@ variable "service_registries" { default = {} } +variable "vpc_lattice_configuration" { + description = "The VPC Lattice configuration for your service that allows Lattice to connect, secure, and monitor your service across multiple accounts and VPCs" + type = any + default = {} +} + variable "timeouts" { description = "Create, update, and delete timeout configurations for the service" type = map(string) diff --git a/wrappers/service/main.tf b/wrappers/service/main.tf index 9a7d6aec..0f9b8af7 100644 --- a/wrappers/service/main.tf +++ b/wrappers/service/main.tf @@ -91,6 +91,7 @@ module "wrapper" { security_group_tags = try(each.value.security_group_tags, var.defaults.security_group_tags, {}) security_group_use_name_prefix = try(each.value.security_group_use_name_prefix, var.defaults.security_group_use_name_prefix, true) service_connect_configuration = try(each.value.service_connect_configuration, var.defaults.service_connect_configuration, {}) + vpc_lattice_configuration = try(each.value.vpc_lattice_configuration, var.defaults.vpc_lattice_configuration, {}) service_registries = try(each.value.service_registries, var.defaults.service_registries, {}) service_tags = try(each.value.service_tags, var.defaults.service_tags, {}) skip_destroy = try(each.value.skip_destroy, var.defaults.skip_destroy, null) From d49af3d6d975325289fcf107e47e82dcf2c55fe8 Mon Sep 17 00:00:00 2001 From: Vinod Dampuru Date: Wed, 5 Feb 2025 10:40:30 +0800 Subject: [PATCH 2/3] feat: Correcting the typo for `vpc_lattice_configurations` --- main.tf | 2 +- modules/service/main.tf | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/main.tf b/main.tf index 54cb442f..d08238c3 100644 --- a/main.tf +++ b/main.tf @@ -82,7 +82,7 @@ module "service" { propagate_tags = try(each.value.propagate_tags, null) scheduling_strategy = try(each.value.scheduling_strategy, null) service_connect_configuration = lookup(each.value, "service_connect_configuration", {}) - vpc_lattice_configuration = lookup(each.value, "vpc_lattice_configuration", {}) + vpc_lattice_configuration = lookup(each.value, "vpc_lattice_configuration", {}) service_registries = lookup(each.value, "service_registries", {}) timeouts = try(each.value.timeouts, {}) triggers = try(each.value.triggers, {}) diff --git a/modules/service/main.tf b/modules/service/main.tf index 75f67edb..b9f94bf1 100644 --- a/modules/service/main.tf +++ b/modules/service/main.tf @@ -188,7 +188,7 @@ resource "aws_ecs_service" "this" { } } - dynamic "vpc_lattice_configuration" { + dynamic "vpc_lattice_configurations" { for_each = length(var.vpc_lattice_configuration) > 0 ? [var.vpc_lattice_configuration] : [] content { From 25a01b96be866d95effe9dfe95bf1d6400b5ed6b Mon Sep 17 00:00:00 2001 From: Vinod Dampuru Date: Mon, 3 Mar 2025 11:17:21 +0800 Subject: [PATCH 3/3] Fixing `pre-commit` hooks issue and using the correct name for dynamic blocks --- modules/service/README.md | 2 +- modules/service/main.tf | 6 +++--- wrappers/service/main.tf | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/service/README.md b/modules/service/README.md index c5929465..7255c9bc 100644 --- a/modules/service/README.md +++ b/modules/service/README.md @@ -288,7 +288,6 @@ module "ecs_service" { | [security\_group\_use\_name\_prefix](#input\_security\_group\_use\_name\_prefix) | Determines whether the security group name (`security_group_name`) is used as a prefix | `bool` | `true` | no | | [service\_connect\_configuration](#input\_service\_connect\_configuration) | The ECS Service Connect configuration for this service to discover and connect to services, and be discovered by, and connected from, other services within a namespace | `any` | `{}` | no | | [service\_registries](#input\_service\_registries) | Service discovery registries for the service | `any` | `{}` | no | -| [vpc\_lattice\_configuration](#input\_vpc\_lattice\_configuration) | The VPC Lattice configuration for your service that allows Lattice to connect, secure, and monitor your service across multiple accounts and VPCs | `any` | `{}` | no | | [service\_tags](#input\_service\_tags) | A map of additional tags to add to the service | `map(string)` | `{}` | no | | [skip\_destroy](#input\_skip\_destroy) | If true, the task is not deleted when the service is deleted | `bool` | `null` | no | | [subnet\_ids](#input\_subnet\_ids) | List of subnets to associate with the task or service | `list(string)` | `[]` | no | @@ -321,6 +320,7 @@ module "ecs_service" { | [timeouts](#input\_timeouts) | Create, update, and delete timeout configurations for the service | `map(string)` | `{}` | no | | [triggers](#input\_triggers) | Map of arbitrary keys and values that, when changed, will trigger an in-place update (redeployment). Useful with `timestamp()` | `any` | `{}` | no | | [volume](#input\_volume) | Configuration block for volumes that containers in your task may use | `any` | `{}` | no | +| [vpc\_lattice\_configuration](#input\_vpc\_lattice\_configuration) | The VPC Lattice configuration for your service that allows Lattice to connect, secure, and monitor your service across multiple accounts and VPCs | `any` | `{}` | no | | [wait\_for\_steady\_state](#input\_wait\_for\_steady\_state) | If true, Terraform will wait for the service to reach a steady state before continuing. Default is `false` | `bool` | `null` | no | | [wait\_until\_stable](#input\_wait\_until\_stable) | Whether terraform should wait until the task set has reached `STEADY_STATE` | `bool` | `null` | no | | [wait\_until\_stable\_timeout](#input\_wait\_until\_stable\_timeout) | Wait timeout for task set to reach `STEADY_STATE`. Valid time units include `ns`, `us` (or µs), `ms`, `s`, `m`, and `h`. Default `10m` | `string` | `null` | no | diff --git a/modules/service/main.tf b/modules/service/main.tf index b9f94bf1..47110b99 100644 --- a/modules/service/main.tf +++ b/modules/service/main.tf @@ -192,9 +192,9 @@ resource "aws_ecs_service" "this" { for_each = length(var.vpc_lattice_configuration) > 0 ? [var.vpc_lattice_configuration] : [] content { - role_arn = try(vpc_lattice_configuration.value.role_arn, null) - target_group_arn = try(vpc_lattice_configuration.value.target_group_arn, null) - port_name = try(vpc_lattice_configuration.value.port_name, null) + role_arn = try(vpc_lattice_configurations.value.role_arn, null) + target_group_arn = try(vpc_lattice_configurations.value.target_group_arn, null) + port_name = try(vpc_lattice_configurations.value.port_name, null) } } diff --git a/wrappers/service/main.tf b/wrappers/service/main.tf index 0f9b8af7..3113a3e7 100644 --- a/wrappers/service/main.tf +++ b/wrappers/service/main.tf @@ -91,7 +91,6 @@ module "wrapper" { security_group_tags = try(each.value.security_group_tags, var.defaults.security_group_tags, {}) security_group_use_name_prefix = try(each.value.security_group_use_name_prefix, var.defaults.security_group_use_name_prefix, true) service_connect_configuration = try(each.value.service_connect_configuration, var.defaults.service_connect_configuration, {}) - vpc_lattice_configuration = try(each.value.vpc_lattice_configuration, var.defaults.vpc_lattice_configuration, {}) service_registries = try(each.value.service_registries, var.defaults.service_registries, {}) service_tags = try(each.value.service_tags, var.defaults.service_tags, {}) skip_destroy = try(each.value.skip_destroy, var.defaults.skip_destroy, null) @@ -125,6 +124,7 @@ module "wrapper" { timeouts = try(each.value.timeouts, var.defaults.timeouts, {}) triggers = try(each.value.triggers, var.defaults.triggers, {}) volume = try(each.value.volume, var.defaults.volume, {}) + vpc_lattice_configuration = try(each.value.vpc_lattice_configuration, var.defaults.vpc_lattice_configuration, {}) wait_for_steady_state = try(each.value.wait_for_steady_state, var.defaults.wait_for_steady_state, null) wait_until_stable = try(each.value.wait_until_stable, var.defaults.wait_until_stable, null) wait_until_stable_timeout = try(each.value.wait_until_stable_timeout, var.defaults.wait_until_stable_timeout, null)