Skip to content

Commit 57ba0b1

Browse files
Lena-nfbzimbatm
authored andcommitted
fix: Merge tags from Fargate profiles with common tags from cluster (terraform-aws-modules#1159)
1 parent 618019e commit 57ba0b1

File tree

4 files changed

+6
-3
lines changed

4 files changed

+6
-3
lines changed

examples/fargate/main.tf

+3
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@ module "eks" {
100100
# GithubOrg = "terraform-aws-modules"
101101
# }
102102

103+
# using specific subnets instead of all the ones configured in eks
104+
# subnets = ["subnet-0ca3e3d1234a56c78"]
105+
103106
tags = {
104107
Owner = "test"
105108
}

modules/fargate/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Helper submodule to create and manage resources related to `aws_eks_fargate_prof
1414
| namespace | Kubernetes namespace for selection | `string` | n/a | yes |
1515
| labels | Key-value map of Kubernetes labels for selection | `map(string)` | `{}` | no |
1616
| tags | Key-value map of resource tags. Will be merged with root module tags. | `map(string)` | `var.tags` | no |
17+
| subnets | List of subnet IDs. Will replace the root module subnets. | `list(string)` | `var.subnets` | no |
1718

1819
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
1920
## Requirements

modules/fargate/fargate.tf

+1-2
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,8 @@ resource "aws_eks_fargate_profile" "this" {
1818
cluster_name = var.cluster_name
1919
fargate_profile_name = lookup(each.value, "name", format("%s-fargate-%s", var.cluster_name, replace(each.key, "_", "-")))
2020
pod_execution_role_arn = local.pod_execution_role_arn
21-
subnet_ids = var.subnets
21+
subnet_ids = lookup(each.value, "subnets", var.subnets)
2222
tags = each.value.tags
23-
2423
selector {
2524
namespace = each.value.namespace
2625
labels = lookup(each.value, "labels", null)

modules/fargate/locals.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ locals {
44
pod_execution_role_name = var.create_fargate_pod_execution_role ? element(concat(aws_iam_role.eks_fargate_pod.*.name, list("")), 0) : element(concat(data.aws_iam_role.custom_fargate_iam_role.*.name, list("")), 0)
55

66
fargate_profiles_expanded = { for k, v in var.fargate_profiles : k => merge(
7-
{ tags = var.tags },
87
v,
8+
{ tags = merge(var.tags, lookup(v, "tags", {})) },
99
) if var.create_eks }
1010
}

0 commit comments

Comments
 (0)