mirror of
https://github.com/ysoftdevs/terraform-aws-eks.git
synced 2026-01-17 09:07:20 +01:00
fix: Invoke aws_iam_session_context data source only when required (#3058)
* fix: Call `aws_iam_session_context` data resource only if needed * Typo. * Move index. * Fix condition. --------- Co-authored-by: Bryant Biggs <bryantbiggs@gmail.com>
This commit is contained in:
5
main.tf
5
main.tf
@@ -2,6 +2,7 @@ data "aws_partition" "current" {}
|
|||||||
data "aws_caller_identity" "current" {}
|
data "aws_caller_identity" "current" {}
|
||||||
|
|
||||||
data "aws_iam_session_context" "current" {
|
data "aws_iam_session_context" "current" {
|
||||||
|
count = (var.create && var.enable_cluster_creator_admin_permissions) || (var.create && var.create_kms_key && local.enable_cluster_encryption_config) ? 1 : 0
|
||||||
# This data source provides information on the IAM source role of an STS assumed role
|
# This data source provides information on the IAM source role of an STS assumed role
|
||||||
# For non-role ARNs, this data source simply passes the ARN through issuer ARN
|
# For non-role ARNs, this data source simply passes the ARN through issuer ARN
|
||||||
# Ref https://github.com/terraform-aws-modules/terraform-aws-eks/issues/2327#issuecomment-1355581682
|
# Ref https://github.com/terraform-aws-modules/terraform-aws-eks/issues/2327#issuecomment-1355581682
|
||||||
@@ -147,7 +148,7 @@ locals {
|
|||||||
# better controlled by users through Terraform
|
# better controlled by users through Terraform
|
||||||
bootstrap_cluster_creator_admin_permissions = {
|
bootstrap_cluster_creator_admin_permissions = {
|
||||||
cluster_creator = {
|
cluster_creator = {
|
||||||
principal_arn = data.aws_iam_session_context.current.issuer_arn
|
principal_arn = data.aws_iam_session_context.current[0].issuer_arn
|
||||||
type = "STANDARD"
|
type = "STANDARD"
|
||||||
|
|
||||||
policy_associations = {
|
policy_associations = {
|
||||||
@@ -236,7 +237,7 @@ module "kms" {
|
|||||||
# Policy
|
# Policy
|
||||||
enable_default_policy = var.kms_key_enable_default_policy
|
enable_default_policy = var.kms_key_enable_default_policy
|
||||||
key_owners = var.kms_key_owners
|
key_owners = var.kms_key_owners
|
||||||
key_administrators = coalescelist(var.kms_key_administrators, [data.aws_iam_session_context.current.issuer_arn])
|
key_administrators = coalescelist(var.kms_key_administrators, [data.aws_iam_session_context.current[0].issuer_arn])
|
||||||
key_users = concat([local.cluster_role], var.kms_key_users)
|
key_users = concat([local.cluster_role], var.kms_key_users)
|
||||||
key_service_users = var.kms_key_service_users
|
key_service_users = var.kms_key_service_users
|
||||||
source_policy_documents = var.kms_key_source_policy_documents
|
source_policy_documents = var.kms_key_source_policy_documents
|
||||||
|
|||||||
Reference in New Issue
Block a user