From 0ef153492f27ab769f271206ce57f477e7c3caa4 Mon Sep 17 00:00:00 2001 From: Brian Flad Date: Tue, 21 Jul 2020 01:33:30 -0400 Subject: [PATCH] resource/aws_codepipeline: Only retry CreatePipeline errors for IAM eventual consistency Reference: https://github.com/terraform-providers/terraform-provider-aws/issues/13409 Output from acceptance testing: ``` --- PASS: TestAccAWSCodePipeline_emptyStageArtifacts (33.11s) --- PASS: TestAccAWSCodePipeline_WithNamespace (35.13s) --- PASS: TestAccAWSCodePipeline_multiregion_basic (36.83s) --- PASS: TestAccAWSCodePipeline_deployWithServiceRole (42.85s) --- PASS: TestAccAWSCodePipeline_basic (57.83s) --- PASS: TestAccAWSCodePipeline_multiregion_Update (61.32s) --- PASS: TestAccAWSCodePipeline_tags (76.28s) --- PASS: TestAccAWSCodePipeline_multiregion_ConvertSingleRegion (79.20s) ``` --- aws/resource_aws_codepipeline.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/aws/resource_aws_codepipeline.go b/aws/resource_aws_codepipeline.go index 501eb5709e4..854e2b7661f 100644 --- a/aws/resource_aws_codepipeline.go +++ b/aws/resource_aws_codepipeline.go @@ -5,7 +5,6 @@ import ( "fmt" "log" "os" - "time" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/codepipeline" @@ -13,6 +12,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/helper/validation" "github.com/terraform-providers/terraform-provider-aws/aws/internal/keyvaluetags" + iamwaiter "github.com/terraform-providers/terraform-provider-aws/aws/internal/service/iam/waiter" ) func resourceAwsCodePipeline() *schema.Resource { @@ -190,14 +190,19 @@ func resourceAwsCodePipelineCreate(d *schema.ResourceData, meta interface{}) err } var resp *codepipeline.CreatePipelineOutput - err = resource.Retry(2*time.Minute, func() *resource.RetryError { + err = resource.Retry(iamwaiter.PropagationTimeout, func() *resource.RetryError { var err error resp, err = conn.CreatePipeline(params) - if err != nil { + if isAWSErr(err, codepipeline.ErrCodeInvalidStructureException, "not authorized") { return resource.RetryableError(err) } + + if err != nil { + return resource.NonRetryableError(err) + } + return nil }) if isResourceTimeoutError(err) {