Skip to content

Commit

Permalink
Merge branch 'f-aws_api_gateway_method_settings-concurrency-issue' of…
Browse files Browse the repository at this point in the history
… ssh://github.com/saurabh-hirani/terraform-provider-aws into saurabh-hirani-f-aws_api_gateway_method_settings-concurrency-issue
  • Loading branch information
bflad committed Jan 13, 2021
2 parents 4d91a6c + fa8de77 commit 26f4b5f
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions aws/resource_aws_api_gateway_method_settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,17 @@ import (
"log"
"strings"

"sync"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/apigateway"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
)

var resourceAwsApiGatewayMethodSettingsUpdateMutex = &sync.Mutex{}
var resourceAwsApiGatewayMethodSettingsDeleteMutex = &sync.Mutex{}

func resourceAwsApiGatewayMethodSettings() *schema.Resource {
return &schema.Resource{
Create: resourceAwsApiGatewayMethodSettingsUpdate,
Expand Down Expand Up @@ -251,7 +256,14 @@ func resourceAwsApiGatewayMethodSettingsUpdate(d *schema.ResourceData, meta inte
PatchOperations: ops,
}
log.Printf("[DEBUG] Updating API Gateway Stage: %s", input)
_, err := conn.UpdateStage(&input)

resourceAwsApiGatewayMethodSettingsUpdateMutex.Lock()
defer resourceAwsApiGatewayMethodSettingsUpdateMutex.Unlock()

_, err := retryOnAwsCode(apigateway.ErrCodeConflictException, func() (interface{}, error) {
return conn.UpdateStage(&input)
})

if err != nil {
return fmt.Errorf("updating API Gateway Stage failed: %w", err)
}
Expand All @@ -276,7 +288,14 @@ func resourceAwsApiGatewayMethodSettingsDelete(d *schema.ResourceData, meta inte
},
}
log.Printf("[DEBUG] Updating API Gateway Stage: %s", input)
_, err := conn.UpdateStage(&input)

resourceAwsApiGatewayMethodSettingsDeleteMutex.Lock()
defer resourceAwsApiGatewayMethodSettingsDeleteMutex.Unlock()

_, err := retryOnAwsCode(apigateway.ErrCodeConflictException, func() (interface{}, error) {
return conn.UpdateStage(&input)
})

if err != nil {
return fmt.Errorf("updating API Gateway Stage failed: %w", err)
}
Expand Down

0 comments on commit 26f4b5f

Please sign in to comment.