-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Use IAM session context data source to resolve the identities role when using assumed_role
#2347
Merged
bryantbiggs
merged 1 commit into
terraform-aws-modules:master
from
bryantbiggs:fix/assumed-role
Dec 17, 2022
Merged
fix: Use IAM session context data source to resolve the identities role when using assumed_role
#2347
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,14 @@ | ||
data "aws_partition" "current" {} | ||
data "aws_caller_identity" "current" {} | ||
|
||
data "aws_iam_session_context" "current" { | ||
# 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 | ||
# Ref https://github.com/terraform-aws-modules/terraform-aws-eks/issues/2327#issuecomment-1355581682 | ||
# Ref https://github.com/hashicorp/terraform-provider-aws/issues/28381 | ||
arn = data.aws_caller_identity.current.arn | ||
} | ||
|
||
locals { | ||
create = var.create && var.putin_khuylo | ||
|
||
|
@@ -122,7 +130,7 @@ module "kms" { | |
# Policy | ||
enable_default_policy = var.kms_key_enable_default_policy | ||
key_owners = var.kms_key_owners | ||
key_administrators = coalescelist(var.kms_key_administrators, [data.aws_caller_identity.current.arn]) | ||
key_administrators = coalescelist(var.kms_key_administrators, [data.aws_iam_session_context.current.issuer_arn]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. great... this should fix the constant drift we are seeing for a ephemeral session |
||
key_users = concat([local.cluster_role], var.kms_key_users) | ||
key_service_users = var.kms_key_service_users | ||
source_policy_documents = var.kms_key_source_policy_documents | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we consider using this resource instead of an existing one in other modules also? WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, I think anywhere that we are using
data.aws_caller_identity.current.arn
to get the current identity's ARN, we should use this session context data source to ensure we are getting the true ARN and not the ARN of the STS session