Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Final retries and deleting extraneous retry blocks from cognito resources #9684

Merged
merged 1 commit into from
Aug 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 7 additions & 12 deletions aws/resource_aws_cognito_identity_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@ package aws
import (
"fmt"
"log"
"time"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/arn"
"github.com/aws/aws-sdk-go/aws/awserr"
"github.com/aws/aws-sdk-go/service/cognitoidentity"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/helper/schema"
)

Expand Down Expand Up @@ -245,15 +243,12 @@ func resourceAwsCognitoIdentityPoolDelete(d *schema.ResourceData, meta interface
conn := meta.(*AWSClient).cognitoconn
log.Printf("[DEBUG] Deleting Cognito Identity Pool: %s", d.Id())

return resource.Retry(5*time.Minute, func() *resource.RetryError {
_, err := conn.DeleteIdentityPool(&cognitoidentity.DeleteIdentityPoolInput{
IdentityPoolId: aws.String(d.Id()),
})

if err == nil {
return nil
}

return resource.NonRetryableError(err)
_, err := conn.DeleteIdentityPool(&cognitoidentity.DeleteIdentityPoolInput{
IdentityPoolId: aws.String(d.Id()),
})

if err != nil {
return fmt.Errorf("Error deleting Cognito identity pool: %s", err)
}
return nil
}
22 changes: 9 additions & 13 deletions aws/resource_aws_cognito_identity_pool_roles_attachment.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@ package aws
import (
"fmt"
"log"
"time"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/awserr"
"github.com/aws/aws-sdk-go/service/cognitoidentity"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/helper/validation"
)
Expand Down Expand Up @@ -222,19 +220,17 @@ func resourceAwsCognitoIdentityPoolRolesAttachmentDelete(d *schema.ResourceData,
conn := meta.(*AWSClient).cognitoconn
log.Printf("[DEBUG] Deleting Cognito Identity Pool Roles Association: %s", d.Id())

return resource.Retry(5*time.Minute, func() *resource.RetryError {
_, err := conn.SetIdentityPoolRoles(&cognitoidentity.SetIdentityPoolRolesInput{
IdentityPoolId: aws.String(d.Get("identity_pool_id").(string)),
Roles: expandCognitoIdentityPoolRoles(make(map[string]interface{})),
RoleMappings: expandCognitoIdentityPoolRoleMappingsAttachment([]interface{}{}),
})
_, err := conn.SetIdentityPoolRoles(&cognitoidentity.SetIdentityPoolRolesInput{
IdentityPoolId: aws.String(d.Get("identity_pool_id").(string)),
Roles: expandCognitoIdentityPoolRoles(make(map[string]interface{})),
RoleMappings: expandCognitoIdentityPoolRoleMappingsAttachment([]interface{}{}),
})

if err == nil {
return nil
}
if err != nil {
return fmt.Errorf("Error deleting Cognito identity pool roles association: %s", err)
}

return resource.NonRetryableError(err)
})
return nil
}

// Validating that each role_mapping ambiguous_role_resolution
Expand Down
6 changes: 6 additions & 0 deletions aws/resource_aws_cognito_user_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -673,6 +673,9 @@ func resourceAwsCognitoUserPoolCreate(d *schema.ResourceData, meta interface{})

return resource.NonRetryableError(err)
})
if isResourceTimeoutError(err) {
resp, err = conn.CreateUserPool(params)
}
if err != nil {
return fmt.Errorf("Error creating Cognito User Pool: %s", err)
}
Expand Down Expand Up @@ -944,6 +947,9 @@ func resourceAwsCognitoUserPoolUpdate(d *schema.ResourceData, meta interface{})

return resource.NonRetryableError(err)
})
if isResourceTimeoutError(err) {
_, err = conn.UpdateUserPool(params)
}
if err != nil {
return fmt.Errorf("Error updating Cognito User pool: %s", err)
}
Expand Down