Skip to content

Commit f221ba3

Browse files
Alaa Qutaishalaa
authored andcommitted
Add IRSA support
1 parent 77f947e commit f221ba3

File tree

4 files changed

+30
-0
lines changed

4 files changed

+30
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ project adheres to [Semantic Versioning](http://semver.org/).
2020
- Updated minimum version of Terraform to avoid a bug (by @dpiddockcmp)
2121
- Fix cluster_oidc_issuer_url output from list to string (by @chewvader)
2222
- Fix idempotency issues for node groups with no remote_access configuration (by @jeffmhastings)
23+
- Added support to create IAM OpenID Connect Identity Provider to enable EKS Identity Roles for Service Accounts (IRSA). (by @alaa)
2324

2425
#### Important notes
2526

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,8 @@ MIT Licensed. See [LICENSE](https://github.com/terraform-aws-modules/terraform-a
166166
| cluster\_version | Kubernetes version to use for the EKS cluster. | string | `"1.14"` | no |
167167
| config\_output\_path | Where to save the Kubectl config file (if `write_kubeconfig = true`). Assumed to be a directory if the value ends with a forward slash `/`. | string | `"./"` | no |
168168
| create\_eks | Controls if EKS resources should be created (it affects almost all resources) | bool | `"true"` | no |
169+
| eks\_oidc\_root\_ca\_thumbprint | Thumbprint of Root CA for EKS OIDC, Valid until 2037 | string | `"9e99a48a9960b14926bb7f3b02e22da2b0ab7280"` | no |
170+
| enable\_irsa | Whether to create OpenID Connect Provider for EKS to enable IRSA | bool | `"false"` | no |
169171
| iam\_path | If provided, all IAM roles will be created on this path. | string | `"/"` | no |
170172
| 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 |
171173
| kubeconfig\_aws\_authenticator\_command | Command to use to fetch AWS EKS credentials. | string | `"aws-iam-authenticator"` | no |

irsa.tf

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Enable IAM Roles for EKS Service-Accounts (IRSA).
2+
3+
# The Root CA Thumbprint for an OpenID Connect Identity Provider is currently
4+
# Being passed as a default value which is the same for all regions and
5+
# Is valid until (Jun 28 17:39:16 2034 GMT).
6+
# https://crt.sh/?q=9E99A48A9960B14926BB7F3B02E22DA2B0AB7280
7+
# https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_providers_create_oidc_verify-thumbprint.html
8+
# https://github.com/terraform-providers/terraform-provider-aws/issues/10104
9+
10+
resource "aws_iam_openid_connect_provider" "oidc_provider" {
11+
count = var.enable_irsa ? 1 : 0
12+
client_id_list = ["sts.amazonaws.com"]
13+
thumbprint_list = [var.eks_oidc_root_ca_thumbprint]
14+
url = flatten(concat(aws_eks_cluster.this[*].identity[*].oidc.0.issuer, [""]))[0]
15+
}

variables.tf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,3 +299,15 @@ variable "node_groups" {
299299
type = any
300300
default = []
301301
}
302+
303+
variable "enable_irsa" {
304+
description = "Whether to create OpenID Connect Provider for EKS to enable IRSA"
305+
type = bool
306+
default = false
307+
}
308+
309+
variable "eks_oidc_root_ca_thumbprint" {
310+
type = string
311+
description = "Thumbprint of Root CA for EKS OIDC, Valid until 2037"
312+
default = "9e99a48a9960b14926bb7f3b02e22da2b0ab7280"
313+
}

0 commit comments

Comments
 (0)