-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
feat: Support EKS Auto Mode custom node pools only creation #3514
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ terraform { | |
required_providers { | ||
aws = { | ||
source = "hashicorp/aws" | ||
version = ">= 6.9" | ||
version = ">= 6.13" | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ terraform { | |
required_providers { | ||
aws = { | ||
source = "hashicorp/aws" | ||
version = ">= 6.9" | ||
version = ">= 6.13" | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ terraform { | |
required_providers { | ||
aws = { | ||
source = "hashicorp/aws" | ||
version = ">= 6.9" | ||
version = ">= 6.13" | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,7 +26,7 @@ locals { | |
create_outposts_local_cluster = var.outpost_config != null | ||
enable_encryption_config = var.encryption_config != null && !local.create_outposts_local_cluster | ||
|
||
auto_mode_enabled = try(var.compute_config.enabled, false) | ||
create_auto_mode_iam_resources = var.compute_config.enabled || var.create_auto_mode_iam_resources | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can appreciate the logic behind having a separate var to create the auto mode iam resources. If that's the interface you wish to expose, then certainly makes sense. |
||
} | ||
|
||
################################################################################ | ||
|
@@ -58,7 +58,7 @@ resource "aws_eks_cluster" "this" { | |
} | ||
|
||
dynamic "compute_config" { | ||
for_each = var.compute_config != null ? [var.compute_config] : [] | ||
for_each = [var.compute_config] | ||
|
||
content { | ||
enabled = compute_config.value.enabled | ||
|
@@ -81,10 +81,10 @@ resource "aws_eks_cluster" "this" { | |
|
||
content { | ||
dynamic "elastic_load_balancing" { | ||
for_each = local.auto_mode_enabled ? [1] : [] | ||
for_each = [var.compute_config] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This approach works also! Just an alternative way to do the same thing I was doing in #3513. :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually, I think you'll run into an error when There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh I see, that's why you had to change the default to |
||
|
||
content { | ||
enabled = local.auto_mode_enabled | ||
enabled = elastic_load_balancing.value.enabled | ||
} | ||
} | ||
|
||
|
@@ -148,11 +148,11 @@ resource "aws_eks_cluster" "this" { | |
} | ||
|
||
dynamic "storage_config" { | ||
for_each = local.auto_mode_enabled ? [1] : [] | ||
for_each = [var.compute_config] | ||
|
||
content { | ||
block_storage { | ||
enabled = local.auto_mode_enabled | ||
enabled = storage_config.value.enabled | ||
} | ||
} | ||
} | ||
|
@@ -476,7 +476,7 @@ locals { | |
# Standard EKS cluster | ||
eks_standard_iam_role_policies = { for k, v in { | ||
AmazonEKSClusterPolicy = "${local.iam_role_policy_prefix}/AmazonEKSClusterPolicy", | ||
} : k => v if !local.create_outposts_local_cluster && !local.auto_mode_enabled } | ||
} : k => v if !local.create_outposts_local_cluster && !local.create_auto_mode_iam_resources } | ||
|
||
# EKS cluster with EKS auto mode enabled | ||
eks_auto_mode_iam_role_policies = { for k, v in { | ||
|
@@ -485,12 +485,12 @@ locals { | |
AmazonEKSBlockStoragePolicy = "${local.iam_role_policy_prefix}/AmazonEKSBlockStoragePolicy" | ||
AmazonEKSLoadBalancingPolicy = "${local.iam_role_policy_prefix}/AmazonEKSLoadBalancingPolicy" | ||
AmazonEKSNetworkingPolicy = "${local.iam_role_policy_prefix}/AmazonEKSNetworkingPolicy" | ||
} : k => v if !local.create_outposts_local_cluster && local.auto_mode_enabled } | ||
} : k => v if !local.create_outposts_local_cluster && local.create_auto_mode_iam_resources } | ||
|
||
# EKS local cluster on Outposts | ||
eks_outpost_iam_role_policies = { for k, v in { | ||
AmazonEKSClusterPolicy = "${local.iam_role_policy_prefix}/AmazonEKSLocalOutpostClusterPolicy" | ||
} : k => v if local.create_outposts_local_cluster && !local.auto_mode_enabled } | ||
} : k => v if local.create_outposts_local_cluster && !local.create_auto_mode_iam_resources } | ||
} | ||
|
||
data "aws_iam_policy_document" "assume_role_policy" { | ||
|
@@ -591,7 +591,7 @@ resource "aws_iam_policy" "cluster_encryption" { | |
} | ||
|
||
data "aws_iam_policy_document" "custom" { | ||
count = local.create_iam_role && local.auto_mode_enabled && var.enable_auto_mode_custom_tags ? 1 : 0 | ||
count = local.create_iam_role && local.create_auto_mode_iam_resources && var.enable_auto_mode_custom_tags ? 1 : 0 | ||
|
||
dynamic "statement" { | ||
for_each = var.enable_auto_mode_custom_tags ? [1] : [] | ||
|
@@ -725,7 +725,7 @@ data "aws_iam_policy_document" "custom" { | |
} | ||
|
||
resource "aws_iam_policy" "custom" { | ||
count = local.create_iam_role && local.auto_mode_enabled && var.enable_auto_mode_custom_tags ? 1 : 0 | ||
count = local.create_iam_role && local.create_auto_mode_iam_resources && var.enable_auto_mode_custom_tags ? 1 : 0 | ||
|
||
name = var.iam_role_use_name_prefix ? null : local.iam_role_name | ||
name_prefix = var.iam_role_use_name_prefix ? "${local.iam_role_name}-" : null | ||
|
@@ -738,7 +738,7 @@ resource "aws_iam_policy" "custom" { | |
} | ||
|
||
resource "aws_iam_role_policy_attachment" "custom" { | ||
count = local.create_iam_role && local.auto_mode_enabled && var.enable_auto_mode_custom_tags ? 1 : 0 | ||
count = local.create_iam_role && local.create_auto_mode_iam_resources && var.enable_auto_mode_custom_tags ? 1 : 0 | ||
|
||
policy_arn = aws_iam_policy.custom[0].arn | ||
role = aws_iam_role.this[0].name | ||
|
@@ -875,7 +875,7 @@ resource "aws_eks_identity_provider_config" "this" { | |
################################################################################ | ||
|
||
locals { | ||
create_node_iam_role = local.create && var.create_node_iam_role && local.auto_mode_enabled | ||
create_node_iam_role = local.create && var.create_node_iam_role && local.create_auto_mode_iam_resources | ||
node_iam_role_name = coalesce(var.node_iam_role_name, "${var.name}-eks-auto") | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ terraform { | |
required_providers { | ||
aws = { | ||
source = "hashicorp/aws" | ||
version = ">= 6.9" | ||
version = ">= 6.13" | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ terraform { | |
required_providers { | ||
aws = { | ||
source = "hashicorp/aws" | ||
version = ">= 6.9" | ||
version = ">= 6.13" | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ terraform { | |
required_providers { | ||
aws = { | ||
source = "hashicorp/aws" | ||
version = ">= 6.9" | ||
version = ">= 6.13" | ||
} | ||
} | ||
} |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't quite enough. It is still necessary to enable auto mode, in order to use custom node pools with auto mode...