Skip to content

Commit

Permalink
feat: mark account as deleted if provisioned product is not found
Browse files Browse the repository at this point in the history
  • Loading branch information
heiko.rothe committed Jun 11, 2021
1 parent f0c2f02 commit 0f4ef31
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions internal/provider/resource_aws_account.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/organizations"
"github.com/aws/aws-sdk-go/service/servicecatalog"
"github.com/hashicorp/aws-sdk-go-base/tfawserr"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
Expand Down Expand Up @@ -193,6 +194,11 @@ func resourceAWSAccountRead(_ context.Context, d *schema.ResourceData, m interfa
product, err := scconn.DescribeProvisionedProduct(&servicecatalog.DescribeProvisionedProductInput{
Id: aws.String(d.Id()),
})

if !d.IsNewResource() && tfawserr.ErrCodeEquals(err, servicecatalog.ErrCodeResourceNotFoundException) {
d.SetId("")
return nil
}
if err != nil {
return diag.Errorf("error reading configuration of provisioned product: %v", err)
}
Expand Down

0 comments on commit 0f4ef31

Please sign in to comment.