- Newest
- Most votes
- Most comments
I suggest you open the CloudTrail console, switch to the us-east-1 region (N. Virginia), and set the event filter to match "Event name" = "CreateRole". Expose the "Error code" column in the list view (under the gear symbol). Look for the event with the non-empty error code, and check if there are other CreateRole calls made just moments earlier. If so, check if the role name is the same (even though it wouldn't be expected to be).
If not, then change the Event name filter to match "DeleteRole" instead. Check if a role by the same name has been deleted shortly before the event timestamp that was shown for the failed CreateRole attempt.
The primary copy of IAM is in us-east-1, but data there is replicated to all the other enabled regions in the partition, so if Terraform just deleted the role moments earlier, IAM might not have reached eventual consistency by the time the new CreateRole attempt is made.
Well, this might be a good advice, it made me become even better with CloudTrail. But no, it do not correspond to what I experience. Just analyzed 4 cases and no one had close another create/delete role with same name. One very light suspect - I create a policy and role with same name, could they conflict? They should not at least. This is my only suspect
The names of IAM roles and managed policies don't share a namespace, so I don't believe they could conflict. It's rather common to see roles dedicated to a specific purpose, like serving as a Lambda execution role, sharing a name with the single policy that is attached.
There's a similar report from a bit under a year ago in the Github repo for the AWS provider for Terraform: https://github.com/hashicorp/terraform-provider-aws/issues/34371
It discusses several things, including changes AWS made to IAM back then and possibly rolled back, but the main conclusion is that the ConcurrentModification errors were returned when making multiple changes to the same IAM resource simultaneously, such as when attaching multiple managed policies to a role without waiting each attachment to be completed before requesting the next one.
A workaround that worked for one user was to tell Terraform not to parallelise requests with:
terraform apply -parallelism=1
but since the report is from a long time ago, I'd suggest you check first that you're using the latest versions of Terraform and the AWS provider, and if the error persists, try the -parallelism=1 option to narrow down if we're likely seeing the same or similar problem.
Relevant content
asked 4 years ago
asked 4 years ago
- AWS OFFICIALUpdated 2 years ago

Can you share all the relevant tf code that relates to the role including any policy attachments and creation etc