Skip to content

Commit 4d1a071

Browse files
committed
feat(eks-addon): support aws v6
1 parent 84ba172 commit 4d1a071

File tree

6 files changed

+100
-36
lines changed

6 files changed

+100
-36
lines changed

modules/eks-addon/README.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,20 @@ This module creates following resources.
99

1010
| Name | Version |
1111
|------|---------|
12-
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.10 |
13-
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.42 |
12+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.12 |
13+
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 6.12 |
1414

1515
## Providers
1616

1717
| Name | Version |
1818
|------|---------|
19-
| <a name="provider_aws"></a> [aws](#provider\_aws) | 5.50.0 |
19+
| <a name="provider_aws"></a> [aws](#provider\_aws) | 6.21.0 |
2020

2121
## Modules
2222

2323
| Name | Source | Version |
2424
|------|--------|---------|
25-
| <a name="module_resource_group"></a> [resource\_group](#module\_resource\_group) | tedilabs/misc/aws//modules/resource-group | ~> 0.10.0 |
25+
| <a name="module_resource_group"></a> [resource\_group](#module\_resource\_group) | tedilabs/misc/aws//modules/resource-group | ~> 0.12.0 |
2626

2727
## Resources
2828

@@ -44,10 +44,10 @@ This module creates following resources.
4444
| <a name="input_conflict_resolution_strategy_on_create"></a> [conflict\_resolution\_strategy\_on\_create](#input\_conflict\_resolution\_strategy\_on\_create) | (Optional) How to resolve field value conflicts when migrating a self-managed add-on to an EKS add-on. Valid values are `NONE` and `OVERWRITE`. Defaults to `OVERWRITE`.<br/> `NONE` - If the self-managed version of the add-on is installed on the cluster, Amazon EKS doesn't change the value. Creation of the add-on might fail.<br/> `OVERWRITE` - If the self-managed version of the add-on is installed on your cluster and the Amazon EKS default value is different than the existing value, Amazon EKS changes the value to the Amazon EKS default value. | `string` | `"OVERWRITE"` | no |
4545
| <a name="input_conflict_resolution_strategy_on_update"></a> [conflict\_resolution\_strategy\_on\_update](#input\_conflict\_resolution\_strategy\_on\_update) | (Optional) How to resolve field value conflicts for an EKS add-on if you've changed a value from the EKS default value. Valid values are `NONE`, `OVERWRITE` and `PRESERVE`. Defaults to `OVERWRITE`.<br/> `NONE` - Amazon EKS doesn't change the value. The update might fail.<br/> `OVERWRITE` - Amazon EKS overwrites the changed value back to the Amazon EKS default value.<br/> `PRESERVE` - Amazon EKS preserves the value. If you choose this option, we recommend that you test any field and value changes on a non-production cluster before updating the add-on on the production cluster. | `string` | `"OVERWRITE"` | no |
4646
| <a name="input_module_tags_enabled"></a> [module\_tags\_enabled](#input\_module\_tags\_enabled) | (Optional) Whether to create AWS Resource Tags for the module informations. | `bool` | `true` | no |
47+
| <a name="input_pod_identity_associations"></a> [pod\_identity\_associations](#input\_pod\_identity\_associations) | (Optional) A list of configurations for EKS Pod Identity associations for the add-on. Each block of `pod_identity_association` as defined below.<br/> (Required) `service_account` - The name of the Kubernetes service account to associate with the IAM role.<br/> (Required) `iam_role` - The ARN (Amazon Resource Name) of the IAM role to associate with the Kubernetes service account. The EKS Pod Identity agent manages credentials to assume this role for applications in the containers in the pods that use this service account. | <pre>list(object({<br/> service_account = string<br/> iam_role = string<br/> }))</pre> | `[]` | no |
4748
| <a name="input_preserve_on_delete"></a> [preserve\_on\_delete](#input\_preserve\_on\_delete) | (Optional) Whether to preserve the created Kubernetes resources on the cluster when deleting the EKS add-on. Defaults to `false`. | `bool` | `false` | no |
48-
| <a name="input_resource_group_description"></a> [resource\_group\_description](#input\_resource\_group\_description) | (Optional) The description of Resource Group. | `string` | `"Managed by Terraform."` | no |
49-
| <a name="input_resource_group_enabled"></a> [resource\_group\_enabled](#input\_resource\_group\_enabled) | (Optional) Whether to create Resource Group to find and group AWS resources which are created by this module. | `bool` | `true` | no |
50-
| <a name="input_resource_group_name"></a> [resource\_group\_name](#input\_resource\_group\_name) | (Optional) The name of Resource Group. A Resource Group name can have a maximum of 127 characters, including letters, numbers, hyphens, dots, and underscores. The name cannot start with `AWS` or `aws`. | `string` | `""` | no |
49+
| <a name="input_region"></a> [region](#input\_region) | (Optional) The region in which to create the module resources. If not provided, the module resources will be created in the provider's configured region. | `string` | `null` | no |
50+
| <a name="input_resource_group"></a> [resource\_group](#input\_resource\_group) | (Optional) A configurations of Resource Group for this module. `resource_group` as defined below.<br/> (Optional) `enabled` - Whether to create Resource Group to find and group AWS resources which are created by this module. Defaults to `true`.<br/> (Optional) `name` - The name of Resource Group. A Resource Group name can have a maximum of 127 characters, including letters, numbers, hyphens, dots, and underscores. The name cannot start with `AWS` or `aws`. If not provided, a name will be generated using the module name and instance name.<br/> (Optional) `description` - The description of Resource Group. Defaults to `Managed by Terraform.`. | <pre>object({<br/> enabled = optional(bool, true)<br/> name = optional(string, "")<br/> description = optional(string, "Managed by Terraform.")<br/> })</pre> | `{}` | no |
5151
| <a name="input_service_account_role"></a> [service\_account\_role](#input\_service\_account\_role) | (Optional) The ARN (Amazon Resource Name) of the IAM Role to bind to the add-on's service account. The role must be assigned the IAM permissions required by the add-on. If you don't specify an existing IAM role, then the add-on uses the permissions assigned to the node IAM role. | `string` | `null` | no |
5252
| <a name="input_tags"></a> [tags](#input\_tags) | (Optional) A map of tags to add to all resources. | `map(string)` | `{}` | no |
5353
| <a name="input_timeouts"></a> [timeouts](#input\_timeouts) | (Optional) How long to wait for the EKS Fargate Profile to be created/updated/deleted. | <pre>object({<br/> create = optional(string, "20m")<br/> update = optional(string, "20m")<br/> delete = optional(string, "40m")<br/> })</pre> | `{}` | no |
@@ -58,6 +58,7 @@ This module creates following resources.
5858
|------|-------------|
5959
| <a name="output_arn"></a> [arn](#output\_arn) | The ARN of the EKS add-on. |
6060
| <a name="output_cluster_name"></a> [cluster\_name](#output\_cluster\_name) | The name of the EKS cluster. |
61+
| <a name="output_configuration"></a> [configuration](#output\_configuration) | The set of configuration values for the add-on. |
6162
| <a name="output_conflict_resolution_strategy_on_create"></a> [conflict\_resolution\_strategy\_on\_create](#output\_conflict\_resolution\_strategy\_on\_create) | How to resolve field value conflicts when migrating a self-managed add-on to an EKS add-on. |
6263
| <a name="output_conflict_resolution_strategy_on_update"></a> [conflict\_resolution\_strategy\_on\_update](#output\_conflict\_resolution\_strategy\_on\_update) | How to resolve field value conflicts for an EKS add-on if you've changed a value from the EKS default value. |
6364
| <a name="output_created_at"></a> [created\_at](#output\_created\_at) | Date and time in RFC3339 format that the EKS add-on was created. |
@@ -66,6 +67,9 @@ This module creates following resources.
6667
| <a name="output_is_latest"></a> [is\_latest](#output\_is\_latest) | Whether the EKS add-on version is the latest available. |
6768
| <a name="output_latest_version"></a> [latest\_version](#output\_latest\_version) | The latest version of the EKS add-on compatible with the EKS cluster version. |
6869
| <a name="output_name"></a> [name](#output\_name) | The name of the EKS add-on. |
70+
| <a name="output_pod_identity_associations"></a> [pod\_identity\_associations](#output\_pod\_identity\_associations) | The list of pod identity associations for the EKS add-on. |
71+
| <a name="output_region"></a> [region](#output\_region) | The AWS region this module resources resides in. |
72+
| <a name="output_resource_group"></a> [resource\_group](#output\_resource\_group) | The resource group created to manage resources in this module. |
6973
| <a name="output_service_account_role"></a> [service\_account\_role](#output\_service\_account\_role) | The ARN (Amazon Resource Name) of the IAM Role to bind to the add-on's service account |
7074
| <a name="output_updated_at"></a> [updated\_at](#output\_updated\_at) | Date and time in RFC3339 format that the EKS add-on was updated. |
7175
| <a name="output_version"></a> [version](#output\_version) | The version of the EKS add-on. |

modules/eks-addon/main.tf

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,32 @@ locals {
2020
###################################################
2121

2222
resource "aws_eks_addon" "this" {
23+
region = var.region
24+
2325
cluster_name = var.cluster_name
2426

2527
addon_name = var.name
2628
addon_version = var.addon_version
2729

28-
configuration_values = var.configuration
29-
30-
service_account_role_arn = var.service_account_role
31-
30+
configuration_values = var.configuration
3231
resolve_conflicts_on_create = var.conflict_resolution_strategy_on_create
3332
resolve_conflicts_on_update = var.conflict_resolution_strategy_on_update
3433
preserve = var.preserve_on_delete
3534

35+
36+
## Auth
37+
service_account_role_arn = var.service_account_role
38+
39+
dynamic "pod_identity_association" {
40+
for_each = var.pod_identity_associations
41+
iterator = association
42+
43+
content {
44+
service_account = association.value.service_account
45+
role_arn = association.value.iam_role
46+
}
47+
}
48+
3649
timeouts {
3750
create = var.timeouts.create
3851
update = var.timeouts.update
@@ -54,15 +67,21 @@ resource "aws_eks_addon" "this" {
5467
###################################################
5568

5669
data "aws_eks_cluster" "this" {
70+
region = var.region
71+
5772
name = aws_eks_addon.this.cluster_name
5873
}
5974

6075
data "aws_eks_addon_version" "default" {
76+
region = var.region
77+
6178
addon_name = var.name
6279
kubernetes_version = data.aws_eks_cluster.this.version
6380
}
6481

6582
data "aws_eks_addon_version" "latest" {
83+
region = var.region
84+
6685
addon_name = var.name
6786
kubernetes_version = data.aws_eks_cluster.this.version
6887
most_recent = true

modules/eks-addon/outputs.tf

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
output "region" {
2+
description = "The AWS region this module resources resides in."
3+
value = aws_eks_addon.this.region
4+
}
5+
16
output "id" {
27
description = "The ID of the EKS add-on."
38
value = aws_eks_addon.this.id
@@ -38,9 +43,9 @@ output "is_latest" {
3843
value = aws_eks_addon.this.addon_version == data.aws_eks_addon_version.latest.version
3944
}
4045

41-
output "service_account_role" {
42-
description = "The ARN (Amazon Resource Name) of the IAM Role to bind to the add-on's service account"
43-
value = aws_eks_addon.this.service_account_role_arn
46+
output "configuration" {
47+
description = "The set of configuration values for the add-on."
48+
value = aws_eks_addon.this.configuration_values
4449
}
4550

4651
output "conflict_resolution_strategy_on_create" {
@@ -53,6 +58,22 @@ output "conflict_resolution_strategy_on_update" {
5358
value = aws_eks_addon.this.resolve_conflicts_on_update
5459
}
5560

61+
output "service_account_role" {
62+
description = "The ARN (Amazon Resource Name) of the IAM Role to bind to the add-on's service account"
63+
value = aws_eks_addon.this.service_account_role_arn
64+
}
65+
66+
output "pod_identity_associations" {
67+
description = "The list of pod identity associations for the EKS add-on."
68+
value = [
69+
for association in aws_eks_addon.this.pod_identity_association :
70+
{
71+
service_account = association.service_account
72+
role_arn = association.role_arn
73+
}
74+
]
75+
}
76+
5677
output "created_at" {
5778
description = "Date and time in RFC3339 format that the EKS add-on was created."
5879
value = aws_eks_addon.this.created_at
@@ -63,14 +84,6 @@ output "updated_at" {
6384
value = aws_eks_addon.this.modified_at
6485
}
6586

66-
# output "debug" {
67-
# value = {
68-
# for k, v in aws_eks_addon.this :
69-
# k => v
70-
# if !contains(["id", "arn", "cluster_name", "addon_name", "addon_version", "service_account_role_arn", "resolve_conflicts_on_create", "resolve_conflicts_on_update", "created_at", "modified_at", "tags", "tags_all"], k)
71-
# }
72-
# }
73-
7487
output "resource_group" {
7588
description = "The resource group created to manage resources in this module."
7689
value = merge(
@@ -86,3 +99,11 @@ output "resource_group" {
8699
)
87100
)
88101
}
102+
103+
# output "debug" {
104+
# value = {
105+
# for k, v in aws_eks_addon.this :
106+
# k => v
107+
# if !contains(["id", "arn", "cluster_name", "addon_name", "addon_version", "service_account_role_arn", "resolve_conflicts_on_create", "resolve_conflicts_on_update", "created_at", "modified_at", "tags", "tags_all", "timeouts", "region", "preserve", "configuration_values", "pod_identity_association"], k)
108+
# }
109+
# }

modules/eks-addon/resource-group.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ module "resource_group" {
1616

1717
count = (var.resource_group.enabled && var.module_tags_enabled) ? 1 : 0
1818

19+
region = var.region
20+
1921
name = local.resource_group_name
2022
description = var.resource_group.description
2123

modules/eks-addon/variables.tf

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
variable "region" {
2+
description = "(Optional) The region in which to create the module resources. If not provided, the module resources will be created in the provider's configured region."
3+
type = string
4+
default = null
5+
nullable = true
6+
}
7+
18
variable "cluster_name" {
29
description = "(Required) The name of the Amazon EKS cluster to add the EKS add-on to."
310
type = string
@@ -24,15 +31,6 @@ variable "configuration" {
2431
nullable = true
2532
}
2633

27-
variable "service_account_role" {
28-
description = <<EOF
29-
(Optional) The ARN (Amazon Resource Name) of the IAM Role to bind to the add-on's service account. The role must be assigned the IAM permissions required by the add-on. If you don't specify an existing IAM role, then the add-on uses the permissions assigned to the node IAM role.
30-
EOF
31-
type = string
32-
default = null
33-
nullable = true
34-
}
35-
3634
variable "conflict_resolution_strategy_on_create" {
3735
description = <<EOF
3836
(Optional) How to resolve field value conflicts when migrating a self-managed add-on to an EKS add-on. Valid values are `NONE` and `OVERWRITE`. Defaults to `OVERWRITE`.
@@ -76,6 +74,29 @@ variable "preserve_on_delete" {
7674
nullable = false
7775
}
7876

77+
variable "service_account_role" {
78+
description = <<EOF
79+
(Optional) The ARN (Amazon Resource Name) of the IAM Role to bind to the add-on's service account. The role must be assigned the IAM permissions required by the add-on. If you don't specify an existing IAM role, then the add-on uses the permissions assigned to the node IAM role.
80+
EOF
81+
type = string
82+
default = null
83+
nullable = true
84+
}
85+
86+
variable "pod_identity_associations" {
87+
description = <<EOF
88+
(Optional) A list of configurations for EKS Pod Identity associations for the add-on. Each block of `pod_identity_association` as defined below.
89+
(Required) `service_account` - The name of the Kubernetes service account to associate with the IAM role.
90+
(Required) `iam_role` - The ARN (Amazon Resource Name) of the IAM role to associate with the Kubernetes service account. The EKS Pod Identity agent manages credentials to assume this role for applications in the containers in the pods that use this service account.
91+
EOF
92+
type = list(object({
93+
service_account = string
94+
iam_role = string
95+
}))
96+
default = []
97+
nullable = false
98+
}
99+
79100
variable "timeouts" {
80101
description = "(Optional) How long to wait for the EKS Fargate Profile to be created/updated/deleted."
81102
type = object({
@@ -106,9 +127,6 @@ variable "module_tags_enabled" {
106127
# Resource Group
107128
###################################################
108129

109-
110-
111-
112130
variable "resource_group" {
113131
description = <<EOF
114132
(Optional) A configurations of Resource Group for this module. `resource_group` as defined below.

modules/eks-addon/versions.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
terraform {
2-
required_version = ">= 1.6"
2+
required_version = ">= 1.12"
33

44
required_providers {
55
aws = {
66
source = "hashicorp/aws"
7-
version = ">= 5.42"
7+
version = ">= 6.12"
88
}
99
}
1010
}

0 commit comments

Comments
 (0)