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