Skip to content

Commit

Permalink
r/servicecat_prin_port_assoc: Rework not found handling
Browse files Browse the repository at this point in the history
  • Loading branch information
YakDriver committed Jun 1, 2021
1 parent 6baa633 commit 4039de4
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions aws/resource_aws_servicecatalog_principal_portfolio_association.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,13 @@ func resourceAwsServiceCatalogPrincipalPortfolioAssociation() *schema.Resource {
Required: true,
ForceNew: true,
},
"principal_unique_id": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
/*
"principal_unique_id": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
*/
"principal_type": {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -124,7 +126,7 @@ func resourceAwsServiceCatalogPrincipalPortfolioAssociationRead(d *schema.Resour

output, err := waiter.PrincipalPortfolioAssociationReady(conn, acceptLanguage, principalARN, portfolioID)

if !d.IsNewResource() && tfresource.NotFound(err) {
if !d.IsNewResource() && (tfresource.NotFound(err) || tfawserr.ErrCodeEquals(err, servicecatalog.ErrCodeResourceNotFoundException)) {
log.Printf("[WARN] Service Catalog Principal Portfolio Association (%s) not found, removing from state", d.Id())
d.SetId("")
return nil
Expand Down Expand Up @@ -177,7 +179,11 @@ func resourceAwsServiceCatalogPrincipalPortfolioAssociationDelete(d *schema.Reso

err = waiter.PrincipalPortfolioAssociationDeleted(conn, acceptLanguage, principalARN, portfolioID)

if err != nil && !tfresource.NotFound(err) {
if tfresource.NotFound(err) || tfawserr.ErrCodeEquals(err, servicecatalog.ErrCodeResourceNotFoundException) {
return nil
}

if err != nil {
return fmt.Errorf("error waiting for Service Catalog Principal Portfolio Disassociation (%s): %w", d.Id(), err)
}

Expand Down

0 comments on commit 4039de4

Please sign in to comment.