I am trying to attach a policy to an IAM role in Terraform. I only know the ARN number of the role, not its "friendly name". But the policy attachment function requires me to use a friendly name, instead of the ARN number.
How can I get the friendly name of an IAM role if I already have the ARN number?
Here's what I have so far -- it's giving me "ValidationError: The specified value for roleName is invalid. It must contain only alphanumeric characters and/or the following: +=,.@_-". I believe this is because I am using the ARN number of the role name instead of the friendly role name.
resource "aws_iam_role_policy_attachment" "my-policy-attachment" {
role = "arn:aws:iam::my_user_account_id:role/my_role_name"
policy_arn = aws_iam_policy.my_policy.arn
}
Thanks!