Skip to content

Commit e56f84d

Browse files
authored
fix: Remove broken IRSA migrations.tf; add default IRSA policy descriptions for backwards compat (#592)
1 parent 4d779a5 commit e56f84d

File tree

7 files changed

+32
-177
lines changed

7 files changed

+32
-177
lines changed

docs/UPGRADE-6.0.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -813,7 +813,7 @@ None
813813

814814
#### `iam-role-for-service-accounts`
815815

816-
None
816+
TODO - coming soon after `v6.0.1` patch release
817817

818818
#### `iam-user`
819819

examples/iam-role-for-service-accounts/main.tf

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -231,9 +231,10 @@ module "load_balancer_controller_irsa" {
231231
module "load_balancer_controller_targetgroup_binding_only_irsa" {
232232
source = "../../modules/iam-role-for-service-accounts"
233233

234-
name = "load-balancer-controller-targetgroup-binding-only"
234+
name = "lbc-targetgroup-binding-only"
235235

236236
attach_load_balancer_controller_targetgroup_binding_only_policy = true
237+
load_balancer_controller_targetgroup_arns = ["arn:aws:elasticloadbalancing:eu-west-1:012345678901:targetgroup/my-target-group"]
237238

238239
oidc_providers = {
239240
this = {
@@ -250,7 +251,8 @@ module "amazon_managed_service_prometheus_irsa" {
250251

251252
name = "amazon-managed-service-prometheus"
252253

253-
attach_amazon_managed_service_prometheus_policy = true
254+
attach_amazon_managed_service_prometheus_policy = true
255+
amazon_managed_service_prometheus_workspace_arns = ["arn:aws:prometheus:eu-west-1:012345678901:workspace/12345678-1234-1234-1234-123456789012"]
254256

255257
oidc_providers = {
256258
this = {
@@ -267,7 +269,8 @@ module "node_termination_handler_irsa" {
267269

268270
name = "node-termination-handler"
269271

270-
attach_node_termination_handler_policy = true
272+
attach_node_termination_handler_policy = true
273+
node_termination_handler_sqs_queue_arns = ["arn:aws:sqs:eu-west-1:012345678901:node-termination-handler"]
271274

272275
oidc_providers = {
273276
this = {

modules/iam-role-for-service-accounts/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ No modules.
201201
| <a name="input_mountpoint_s3_csi_bucket_arns"></a> [mountpoint\_s3\_csi\_bucket\_arns](#input\_mountpoint\_s3\_csi\_bucket\_arns) | S3 bucket ARNs to allow Mountpoint S3 CSI to list buckets | `list(string)` | `[]` | no |
202202
| <a name="input_mountpoint_s3_csi_kms_arns"></a> [mountpoint\_s3\_csi\_kms\_arns](#input\_mountpoint\_s3\_csi\_kms\_arns) | KMS Key ARNs to allow Mountpoint S3 CSI driver to download and upload Objects of a S3 bucket using `aws:kms` SSE | `list(string)` | `[]` | no |
203203
| <a name="input_mountpoint_s3_csi_path_arns"></a> [mountpoint\_s3\_csi\_path\_arns](#input\_mountpoint\_s3\_csi\_path\_arns) | S3 path ARNs to allow Mountpoint S3 CSI driver to manage items at the provided path(s). This is required if `attach_mountpoint_s3_csi_policy = true` | `list(string)` | `[]` | no |
204-
| <a name="input_name"></a> [name](#input\_name) | Name to use on IAM role created | `string` | `null` | no |
204+
| <a name="input_name"></a> [name](#input\_name) | Name to use on IAM role created | `string` | `""` | no |
205205
| <a name="input_node_termination_handler_sqs_queue_arns"></a> [node\_termination\_handler\_sqs\_queue\_arns](#input\_node\_termination\_handler\_sqs\_queue\_arns) | List of SQS ARNs that contain node termination events | `list(string)` | `[]` | no |
206206
| <a name="input_oidc_providers"></a> [oidc\_providers](#input\_oidc\_providers) | Map of OIDC providers where each provider map should contain the `provider`, `provider_arn`, and `namespace_service_accounts` | `any` | `{}` | no |
207207
| <a name="input_override_inline_policy_documents"></a> [override\_inline\_policy\_documents](#input\_override\_inline\_policy\_documents) | List of IAM policy documents that are merged together into the exported document. In merging, statements with non-blank `sid`s will override statements with the same `sid` | `list(string)` | `[]` | no |

modules/iam-role-for-service-accounts/main.tf

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,26 @@ data "aws_partition" "current" {
55
locals {
66
partition = try(data.aws_partition.current[0].partition, "")
77
dns_suffix = try(data.aws_partition.current[0].dns_suffix, "")
8+
9+
policy_description = try(coalesce(
10+
var.policy_description,
11+
var.attach_aws_gateway_controller_policy ? "Provides permissions for the AWS Gateway Controller" : null,
12+
var.attach_cert_manager_policy ? "Cert Manager policy to allow management of Route53 hosted zone records" : null,
13+
var.attach_cluster_autoscaler_policy ? "Cluster autoscaler policy to allow examination and modification of EC2 Auto Scaling Groups" : null,
14+
var.attach_ebs_csi_policy ? "Provides permissions to manage EBS volumes via the container storage interface driver" : null,
15+
var.attach_efs_csi_policy ? "Provides permissions to manage EFS volumes via the container storage interface driver" : null,
16+
var.attach_mountpoint_s3_csi_policy ? "Mountpoint S3 CSI driver policy to allow management of S3" : null,
17+
var.attach_external_dns_policy ? "External DNS policy to allow management of Route53 hosted zone records" : null,
18+
var.attach_external_secrets_policy ? "Provides permissions to for External Secrets to retrieve secrets from AWS SSM and AWS Secrets Manager" : null,
19+
var.attach_fsx_lustre_csi_policy ? "Provides permissions to manage FSx Lustre volumes via the container storage interface driver" : null,
20+
var.attach_fsx_openzfs_csi_policy ? "Provides permissions to manage FSx OpenZFS volumes via the container storage interface driver" : null,
21+
var.attach_load_balancer_controller_policy ? "Provides permissions for AWS Load Balancer Controller addon" : null,
22+
var.attach_load_balancer_controller_targetgroup_binding_only_policy ? "Provides permissions for AWS Load Balancer Controller addon in TargetGroup binding only scenario" : null,
23+
var.attach_amazon_managed_service_prometheus_policy ? "Provides permissions to for Amazon Managed Service for Prometheus" : null,
24+
var.attach_node_termination_handler_policy ? "Provides permissions to handle node termination events via the Node Termination Handler" : null,
25+
var.attach_velero_policy ? "Provides Velero permissions to backup and restore cluster resources" : null,
26+
var.attach_vpc_cni_policy ? "Provides the Amazon VPC CNI Plugin (amazon-vpc-cni-k8s) the permissions it requires to modify the IPv4/IPv6 address configuration on your EKS worker nodes" : null,
27+
), null)
828
}
929

1030
################################################################################
@@ -70,7 +90,7 @@ resource "aws_iam_role_policy_attachment" "additional" {
7090
################################################################################
7191

7292
locals {
73-
create_policy = var.create && var.create_policy
93+
create_policy = var.create && var.create_policy && (length(local.source_policy_documents) > 0 || length(var.override_policy_documents) > 0 || var.permissions != null)
7494

7595
source_policy_documents = flatten(concat(
7696
data.aws_iam_policy_document.aws_gateway_controller[*].json,
@@ -151,7 +171,7 @@ resource "aws_iam_policy" "this" {
151171
name = var.use_name_prefix ? null : local.policy_name
152172
name_prefix = var.use_name_prefix ? "${local.policy_name}-" : null
153173
path = coalesce(var.policy_path, var.path)
154-
description = try(coalesce(var.policy_description, var.description), null)
174+
description = try(coalesce(var.policy_description, local.policy_description), null)
155175
policy = data.aws_iam_policy_document.this[0].json
156176

157177
tags = var.tags

modules/iam-role-for-service-accounts/migrations.tf

Lines changed: 0 additions & 168 deletions
This file was deleted.

modules/iam-role-for-service-accounts/variables.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ variable "tags" {
1717
variable "name" {
1818
description = "Name to use on IAM role created"
1919
type = string
20-
default = null
20+
default = ""
2121
}
2222

2323
variable "use_name_prefix" {

wrappers/iam-role-for-service-accounts/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ module "wrapper" {
4141
mountpoint_s3_csi_bucket_arns = try(each.value.mountpoint_s3_csi_bucket_arns, var.defaults.mountpoint_s3_csi_bucket_arns, [])
4242
mountpoint_s3_csi_kms_arns = try(each.value.mountpoint_s3_csi_kms_arns, var.defaults.mountpoint_s3_csi_kms_arns, [])
4343
mountpoint_s3_csi_path_arns = try(each.value.mountpoint_s3_csi_path_arns, var.defaults.mountpoint_s3_csi_path_arns, [])
44-
name = try(each.value.name, var.defaults.name, null)
44+
name = try(each.value.name, var.defaults.name, "")
4545
node_termination_handler_sqs_queue_arns = try(each.value.node_termination_handler_sqs_queue_arns, var.defaults.node_termination_handler_sqs_queue_arns, [])
4646
oidc_providers = try(each.value.oidc_providers, var.defaults.oidc_providers, {})
4747
override_inline_policy_documents = try(each.value.override_inline_policy_documents, var.defaults.override_inline_policy_documents, [])

0 commit comments

Comments
 (0)