Skip to content

Commit 3a5d830

Browse files
committed
feat: support Fargate in private+public EKS environments
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.
1 parent 65777d0 commit 3a5d830

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
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-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ 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
2323
selector {
2424
namespace = each.value.namespace

0 commit comments

Comments
 (0)