Search code examples
aws-sdk-go

Intermittent `A conflicting conditional operation is currently in progress against this resource` when creating bucket


We've seen the conflicting conditional operation intermittently in our CI pipeline when creating a new bucket. We create the bucket with a random name so there should be no conflicting operations. We're using the terraform-aws-provider, which uses the aws-sdk-go, to create this bucket. Looks like they call CreateBucket followed by TagResource. We suspect that this error is due to the provider not calling WaitUntilBucketExists before calling TagResource. Does this seems plausible? If so, we can open an issue or PR with the terraform aws provider.


Solution

  • According to the terraform code you're right, they do seem not to use WaitUntilBucketExists, you could check it here https://github.com/terraform-providers/terraform-provider-aws/blob/27e2f31ac052cf5dce63036756337be08f2ffa30/aws/resource_aws_s3_bucket.go#L442

    err := resource.Retry(5*time.Minute, func() *resource.RetryError {
        log.Printf("[DEBUG] Trying to create new S3 bucket: %q", bucket)
        _, err := s3conn.CreateBucket(req)
        if awsErr, ok := err.(awserr.Error); ok {
            if awsErr.Code() == "OperationAborted" {
                log.Printf("[WARN] Got an error while trying to create S3 bucket %s: %s", bucket, err)
                return resource.RetryableError(
                    fmt.Errorf("[WARN] Error creating S3 bucket %s, retrying: %s",
                        bucket, err))
    

    So basically they retry for 5 min... I guess you can open a Github issue or even better, create a PR :)

    BTW, it's weird you hit the 5 minutes limit creating the bucket ... so I wonder if your CI could be hitting the threshold in AWS API rate limit. Could this be the case? Do you create several buckets at a time?