Skip to content

Commit

Permalink
r/servicecat_constraint: Rework not found
Browse files Browse the repository at this point in the history
  • Loading branch information
YakDriver committed May 17, 2021
1 parent 93704c7 commit fa60ac1
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions aws/resource_aws_servicecatalog_constraint.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ func resourceAwsServiceCatalogConstraintRead(d *schema.ResourceData, meta interf

output, err := waiter.ConstraintReady(conn, d.Get("accept_language").(string), d.Id())

if !d.IsNewResource() && tfawserr.ErrCodeEquals(err, servicecatalog.ErrCodeResourceNotFoundException) {
if !d.IsNewResource() && tfresource.NotFound(err) {
log.Printf("[WARN] Service Catalog Constraint (%s) not found, removing from state", d.Id())
d.SetId("")
return nil
Expand All @@ -148,6 +148,14 @@ func resourceAwsServiceCatalogConstraintRead(d *schema.ResourceData, meta interf
return fmt.Errorf("error getting Service Catalog Constraint (%s): empty response", d.Id())
}

acceptLanguage := d.Get("accept_language").(string)

if acceptLanguage == "" {
acceptLanguage = "en"
}

d.Set("accept_language", acceptLanguage)

d.Set("parameters", output.ConstraintParameters)
d.Set("status", output.Status)

Expand Down Expand Up @@ -227,7 +235,9 @@ func resourceAwsServiceCatalogConstraintDelete(d *schema.ResourceData, meta inte
return fmt.Errorf("error deleting Service Catalog Constraint (%s): %w", d.Id(), err)
}

if err := waiter.ConstraintDeleted(conn, d.Get("accept_language").(string), d.Id()); err != nil {
err = waiter.ConstraintDeleted(conn, d.Get("accept_language").(string), d.Id())

if err != nil && !tfresource.NotFound(err) {
return fmt.Errorf("error waiting for Service Catalog Constraint (%s) to be deleted: %w", d.Id(), err)
}

Expand Down

0 comments on commit fa60ac1

Please sign in to comment.