Terraform plan failing to modifying elastic cache user group association process

Hi Team

We use terraform to maintain your AWS infrastructure and elasticache (Redis) is one of the services to use. Jenkins runs our pipelines in multiple workers and sometimes we get failure while configuring the elasticache user groups resources.

Error: deleting ElastiCache User Group Association (“xxxxxx-serivice): InvalidUserGroupState: User group x-default-user-group has status modifying. Only active user groups can be modified.
	status code: 400, request id: xxxxxx-xxxx-xxxx-xxxx

also, terraform changes for elasticache are taking time significantly higher than other services.

xxxx_elasticache_user: Still destroying... [id=xxxxxx-xxxx-xxxx-xxxx, 30s elapsed]

xxxx_elasticache_user: Still destroying... [id=xxxxxx-xxxx-xxxx-xxxx, 40s elapsed]

xxxx_elasticache_user: Still destroying... [id=xxxxxx-xxxx-xxxx-xxxx, 50s elapsed]

I could not find a clear solution in the documentation and other resources to improve this process.

We followed the recommendations in the official documents, but it was unable to help us and were unsuccessful.

Resource: aws_elasticache_user_group_association

Is there an optimal solution or suggestion to officially this situation? We have reduced the number of our Jenkins workers for the moment, but this situation can still happen

What specifically are you trying to do? Different resources will take different amounts of time for AWS to complete changes. For example EKS can take 10 minutes for a new cluster to be created or deleted. The time things takes depends on AWS rather than being something Terraform controls.

The error you listed at the top suggests that you are trying to make a change too soon after another one. Similarly if you delete a S3 bucket there is a period of time before AWS allows you to use the same bucket name.

yes, more than one elasticache is created or destroyed simultaneously. It’s acceptable to take a long time here, but how can I prevent it from getting an error? I can prioritize preventing it from getting errors. I really couldn’t find an optimum solution for this situation in the documentation

The error message you pasted suggests you are trying to delete something that recently was modified, before the change had fully been completed by AWS. To not get that error you need to wait long enough between any changes and deleting things.