Skip to content

Commit d606add

Browse files
committed
add fargate_subnets variable
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 e4520d2 commit d606add

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ MIT Licensed. See [LICENSE](https://github.com/terraform-aws-modules/terraform-a
192192
| enable\_irsa | Whether to create OpenID Connect Provider for EKS to enable IRSA | `bool` | `false` | no |
193193
| fargate\_pod\_execution\_role\_name | The IAM Role that provides permissions for the EKS Fargate Profile. | `string` | `null` | no |
194194
| fargate\_profiles | Fargate profiles to create. See `fargate_profile` keys section in fargate submodule's README.md for more details | `any` | `{}` | no |
195+
| fargate\_subnets | A list of private subnets to use for Fargate. Defaults to the subnets var if empty. | `list(string)` | `[]` | no |
195196
| iam\_path | If provided, all IAM roles will be created on this path. | `string` | `"/"` | no |
196197
| kubeconfig\_aws\_authenticator\_additional\_args | Any additional arguments to pass to the authenticator such as the role to assume. e.g. ["-r", "MyEksRole"]. | `list(string)` | `[]` | no |
197198
| kubeconfig\_aws\_authenticator\_command | Command to use to fetch AWS EKS credentials. | `string` | `"aws-iam-authenticator"` | no |

fargate.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ module "fargate" {
77
fargate_profiles = var.fargate_profiles
88
iam_path = var.iam_path
99
iam_policy_arn_prefix = local.policy_arn_prefix
10-
subnets = var.subnets
10+
subnets = length(var.fargate_subnets) > 0 ? var.fargate_subnets : var.subnets
1111
tags = var.tags
1212

1313
# Hack to ensure ordering of resource creation.

variables.tf

+6
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,12 @@ variable "fargate_profiles" {
356356
default = {}
357357
}
358358

359+
variable "fargate_subnets" {
360+
description = "A list of private subnets to use for Fargate. Defaults to the subnets var if empty."
361+
type = list(string)
362+
default = []
363+
}
364+
359365
variable "create_fargate_pod_execution_role" {
360366
description = "Controls if the EKS Fargate pod execution IAM role should be created."
361367
type = bool

0 commit comments

Comments
 (0)