From 576aa293f5fbbe4acd9aa8ad09be2706a242a6bf Mon Sep 17 00:00:00 2001 From: Jonas Chevalier Date: Thu, 28 Jan 2021 21:46:53 +0000 Subject: [PATCH] feat: Allow the overwrite of subnets for Fargate profiles (#1117) NOTES: The EKS cluster can be provisioned with both private and public subnets. But Fargate only accepts private ones. This new variable allows to override the subnets to explicitly pass the private subnets to Fargate and work around that issue. --- examples/fargate/main.tf | 3 +++ modules/fargate/README.md | 1 + modules/fargate/fargate.tf | 2 +- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/examples/fargate/main.tf b/examples/fargate/main.tf index f3f1aa0..7fd0118 100644 --- a/examples/fargate/main.tf +++ b/examples/fargate/main.tf @@ -100,6 +100,9 @@ module "eks" { # GithubOrg = "terraform-aws-modules" # } + # using specific subnets instead of all the ones configured in eks + # subnets = ["subnet-0ca3e3d1234a56c78"] + tags = { Owner = "test" } diff --git a/modules/fargate/README.md b/modules/fargate/README.md index 592ac2e..8b4c72f 100644 --- a/modules/fargate/README.md +++ b/modules/fargate/README.md @@ -14,6 +14,7 @@ Helper submodule to create and manage resources related to `aws_eks_fargate_prof | namespace | Kubernetes namespace for selection | `string` | n/a | yes | | labels | Key-value map of Kubernetes labels for selection | `map(string)` | `{}` | no | | tags | Key-value map of resource tags. Will be merged with root module tags. | `map(string)` | `var.tags` | no | +| subnets | List of subnet IDs. Will replace the root module subnets. | `list(string)` | `var.subnets` | no | ## Requirements diff --git a/modules/fargate/fargate.tf b/modules/fargate/fargate.tf index d8e5327..43f6163 100644 --- a/modules/fargate/fargate.tf +++ b/modules/fargate/fargate.tf @@ -18,7 +18,7 @@ resource "aws_eks_fargate_profile" "this" { cluster_name = var.cluster_name fargate_profile_name = lookup(each.value, "name", format("%s-fargate-%s", var.cluster_name, replace(each.key, "_", "-"))) pod_execution_role_arn = local.pod_execution_role_arn - subnet_ids = var.subnets + subnet_ids = lookup(each.value, "subnets", var.subnets) tags = each.value.tags selector { namespace = each.value.namespace