Skip to content

Commit 0f4bf0a

Browse files
bryantbiggsspr-mweber3
authored andcommitted
fix: Use IAM session context data source to resolve the identities role when using assumed_role (terraform-aws-modules#2347)
1 parent f2c71ba commit 0f4bf0a

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,7 @@ We are grateful to the community for contributing bugfixes and improvements! Ple
270270
| [aws_eks_addon_version.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/eks_addon_version) | data source |
271271
| [aws_iam_policy_document.assume_role_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
272272
| [aws_iam_policy_document.cni_ipv6_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
273+
| [aws_iam_session_context.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_session_context) | data source |
273274
| [aws_partition.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/partition) | data source |
274275
| [tls_certificate.this](https://registry.terraform.io/providers/hashicorp/tls/latest/docs/data-sources/certificate) | data source |
275276

main.tf

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
data "aws_partition" "current" {}
22
data "aws_caller_identity" "current" {}
33

4+
data "aws_iam_session_context" "current" {
5+
# This data source provides information on the IAM source role of an STS assumed role
6+
# For non-role ARNs, this data source simply passes the ARN through issuer ARN
7+
# Ref https://github.com/terraform-aws-modules/terraform-aws-eks/issues/2327#issuecomment-1355581682
8+
# Ref https://github.com/hashicorp/terraform-provider-aws/issues/28381
9+
arn = data.aws_caller_identity.current.arn
10+
}
11+
412
locals {
513
create = var.create && var.putin_khuylo
614

@@ -122,7 +130,7 @@ module "kms" {
122130
# Policy
123131
enable_default_policy = var.kms_key_enable_default_policy
124132
key_owners = var.kms_key_owners
125-
key_administrators = coalescelist(var.kms_key_administrators, [data.aws_caller_identity.current.arn])
133+
key_administrators = coalescelist(var.kms_key_administrators, [data.aws_iam_session_context.current.issuer_arn])
126134
key_users = concat([local.cluster_role], var.kms_key_users)
127135
key_service_users = var.kms_key_service_users
128136
source_policy_documents = var.kms_key_source_policy_documents

0 commit comments

Comments
 (0)