Skip to content

Commit 6b8a3d9

Browse files
authored
fix: Correct encryption configuration enable logic; avoid creating Auto Mode policy when Auto Mode is not enabled (#3439)
1 parent 41d31db commit 6b8a3d9

File tree

3 files changed

+7
-9
lines changed

3 files changed

+7
-9
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ We are grateful to the community for contributing bugfixes and improvements! Ple
411411
| <a name="input_enable_irsa"></a> [enable\_irsa](#input\_enable\_irsa) | Determines whether to create an OpenID Connect Provider for EKS to enable IRSA | `bool` | `true` | no |
412412
| <a name="input_enable_kms_key_rotation"></a> [enable\_kms\_key\_rotation](#input\_enable\_kms\_key\_rotation) | Specifies whether key rotation is enabled | `bool` | `true` | no |
413413
| <a name="input_enabled_log_types"></a> [enabled\_log\_types](#input\_enabled\_log\_types) | A list of the desired control plane logs to enable. For more information, see Amazon EKS Control Plane Logging documentation (https://docs.aws.amazon.com/eks/latest/userguide/control-plane-logs.html) | `list(string)` | <pre>[<br/> "audit",<br/> "api",<br/> "authenticator"<br/>]</pre> | no |
414-
| <a name="input_encryption_config"></a> [encryption\_config](#input\_encryption\_config) | Configuration block with encryption configuration for the cluster | <pre>object({<br/> provider_key_arn = optional(string)<br/> resources = optional(list(string))<br/> })</pre> | <pre>{<br/> "resources": [<br/> "secrets"<br/> ]<br/>}</pre> | no |
414+
| <a name="input_encryption_config"></a> [encryption\_config](#input\_encryption\_config) | Configuration block with encryption configuration for the cluster | <pre>object({<br/> provider_key_arn = optional(string)<br/> resources = optional(list(string), ["secrets"])<br/> })</pre> | `{}` | no |
415415
| <a name="input_encryption_policy_description"></a> [encryption\_policy\_description](#input\_encryption\_policy\_description) | Description of the cluster encryption policy created | `string` | `"Cluster encryption policy to allow cluster role to utilize CMK provided"` | no |
416416
| <a name="input_encryption_policy_name"></a> [encryption\_policy\_name](#input\_encryption\_policy\_name) | Name to use on cluster encryption policy created | `string` | `null` | no |
417417
| <a name="input_encryption_policy_path"></a> [encryption\_policy\_path](#input\_encryption\_policy\_path) | Cluster encryption policy path | `string` | `null` | no |

main.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ locals {
2424
role_arn = try(aws_iam_role.this[0].arn, var.iam_role_arn)
2525

2626
create_outposts_local_cluster = var.outpost_config != null
27-
enable_encryption_config = length(var.encryption_config) > 0 && !local.create_outposts_local_cluster
27+
enable_encryption_config = var.encryption_config != null && !local.create_outposts_local_cluster
2828

2929
auto_mode_enabled = try(var.compute_config.enabled, false)
3030
}
@@ -590,7 +590,7 @@ resource "aws_iam_policy" "cluster_encryption" {
590590
}
591591

592592
data "aws_iam_policy_document" "custom" {
593-
count = local.create_iam_role && var.enable_auto_mode_custom_tags ? 1 : 0
593+
count = local.create_iam_role && local.auto_mode_enabled && var.enable_auto_mode_custom_tags ? 1 : 0
594594

595595
dynamic "statement" {
596596
for_each = var.enable_auto_mode_custom_tags ? [1] : []
@@ -724,7 +724,7 @@ data "aws_iam_policy_document" "custom" {
724724
}
725725

726726
resource "aws_iam_policy" "custom" {
727-
count = local.create_iam_role && var.enable_auto_mode_custom_tags ? 1 : 0
727+
count = local.create_iam_role && local.auto_mode_enabled && var.enable_auto_mode_custom_tags ? 1 : 0
728728

729729
name = var.iam_role_use_name_prefix ? null : local.iam_role_name
730730
name_prefix = var.iam_role_use_name_prefix ? "${local.iam_role_name}-" : null
@@ -737,7 +737,7 @@ resource "aws_iam_policy" "custom" {
737737
}
738738

739739
resource "aws_iam_role_policy_attachment" "custom" {
740-
count = local.create_iam_role && var.enable_auto_mode_custom_tags ? 1 : 0
740+
count = local.create_iam_role && local.auto_mode_enabled && var.enable_auto_mode_custom_tags ? 1 : 0
741741

742742
policy_arn = aws_iam_policy.custom[0].arn
743743
role = aws_iam_role.this[0].name

variables.tf

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,11 +165,9 @@ variable "encryption_config" {
165165
description = "Configuration block with encryption configuration for the cluster"
166166
type = object({
167167
provider_key_arn = optional(string)
168-
resources = optional(list(string))
168+
resources = optional(list(string), ["secrets"])
169169
})
170-
default = {
171-
resources = ["secrets"]
172-
}
170+
default = {}
173171
}
174172

175173
variable "attach_encryption_policy" {

0 commit comments

Comments
 (0)