hashicorp / terraform-provider-aws

The AWS Provider enables Terraform to manage AWS resources.
https://registry.terraform.io/providers/hashicorp/aws
Mozilla Public License 2.0
9.86k stars 9.2k forks source link

Error: Some AWS operations do not support assumed roles #19958

Closed YakDriver closed 3 years ago

YakDriver commented 3 years ago

Community Note

Description

AWS services have operations that require a principal (e.g., an IAM user, role, or group). Sometimes these operations fail if an assumed-role ARN is passed in. Ideally, what you want is to grant/convey/designate the IAM source role so that the STS assumed role will have the benefit of the change, and the operation will succeed.

For example, in the Lake Formation service, you cannot make an assumed role a data lake administrator. If you try to, you receive this error:

InvalidInputException: Unsupported principal identifier:arn:aws:sts::123456789012:assumed-role/role_name/session-identifier. Arns identifying principals with temporary credentials are not supported.

However, if you pass in the source IAM role (arn:aws:iam::123456789012:role/role_name), the operation will succeed. The role will become an administrator and the person using the assumed role will have the benefit of the change as well.

Another example is in Service Catalog. There you may get this type of similar error:

InvalidParametersException: Invalid parameter principalArn, assumed-role is not a recognized IAM identity type

However, in the same vein, if you pass in the source IAM role, the operation will succeed.

A solution is to create a new data source call aws_iam_session_context to find the IAM source role of an STS assumed role. This data source should allow passing through IAM roles and users so that it can be used whether the role is STS or IAM and then everyone can use the same config.

Affected Data Source

Potential Terraform Configuration

data "aws_caller_identity" "current" {}

data "aws_iam_session_context" "example" {
  arn = data.aws_called_identity.current.arn
}

References

github-actions[bot] commented 3 years ago

This functionality has been released in v3.48.0 of the Terraform AWS Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

github-actions[bot] commented 3 years ago

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. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.