-
Notifications
You must be signed in to change notification settings - Fork 9.2k
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
[Bug]: Assume role identity is different than what aws_caller_identity
reports
#28381
Comments
Community NoteVoting for Prioritization
Volunteering to Work on This Issue
|
TIL - theres a data source for this. As pointed out by @fknittel - this works as intended for both scenarios (w/ or w/o assume_role): provider "aws" {
region = "us-east-1"
assume_role {
role_arn = "arn:aws:iam::111111111111:role/terraform"
}
}
data "aws_caller_identity" "current" {}
data "aws_iam_session_context" "current" {
arn = data.aws_caller_identity.current.arn
}
data "aws_iam_policy_document" "this" {
statement {
sid = "Default"
actions = ["kms:*"]
resources = ["*"]
principals {
type = "AWS"
identifiers = [data.aws_iam_session_context.current.issuer_arn]
}
}
}
output "policy" {
value = data.aws_iam_policy_document.this.json
} |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. |
Terraform Core Version
1.3.6
AWS Provider Version
4.46.0
Affected Resource(s)
Expected Behavior
When providing an IAM role to assume in the provider via
assume_role
, I would expect that the data sourceaws_caller_identity
would return the ARN of the role to be assumed.Actual Behavior
The role ARN returned is an STS session ARN for the SDK
Terraform Configuration Files
Note: the role ARN to assume will need to be updated (i.e. -
"arn:aws:iam::111111111111:role/terraform"
should be updated)Steps to Reproduce
Using the code provided above:
terraform init
terraform plan
Debug Output
No response
Panic Output
No response
Important Factoids
No response
References
No response
Would you like to implement a fix?
None
The text was updated successfully, but these errors were encountered: