Skip to content

Commit

Permalink
r/servicecatalog_provisioned_product: return error when in the 'TAINT…
Browse files Browse the repository at this point in the history
…ED' state; add error message in waiter
  • Loading branch information
anGie44 committed Jun 1, 2022
1 parent ff4d9c5 commit 5a87cd3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
13 changes: 9 additions & 4 deletions internal/service/servicecatalog/wait.go
Original file line number Diff line number Diff line change
Expand Up @@ -502,10 +502,8 @@ func WaitLaunchPathsReady(conn *servicecatalog.ServiceCatalog, acceptLanguage, p

func WaitProvisionedProductReady(conn *servicecatalog.ServiceCatalog, acceptLanguage, id, name string, timeout time.Duration) (*servicecatalog.DescribeProvisionedProductOutput, error) {
stateConf := &resource.StateChangeConf{
// "TAINTED" is a valid target state as its described as a stable state per API docs, though can result from a failed update
// such that the stack rolls back to a previous version.
Pending: []string{StatusNotFound, StatusUnavailable, servicecatalog.ProvisionedProductStatusUnderChange, servicecatalog.ProvisionedProductStatusPlanInProgress},
Target: []string{servicecatalog.StatusAvailable, servicecatalog.ProvisionedProductStatusTainted},
Target: []string{servicecatalog.StatusAvailable},
Refresh: StatusProvisionedProduct(conn, acceptLanguage, id, name),
Timeout: timeout,
ContinuousTargetOccurence: ContinuousTargetOccurrence,
Expand All @@ -516,7 +514,14 @@ func WaitProvisionedProductReady(conn *servicecatalog.ServiceCatalog, acceptLang
outputRaw, err := stateConf.WaitForState()

if output, ok := outputRaw.(*servicecatalog.DescribeProvisionedProductOutput); ok {
tfresource.SetLastError(err, errors.New(aws.StringValue(output.ProvisionedProductDetail.StatusMessage)))
if detail := output.ProvisionedProductDetail; detail != nil {
status := aws.StringValue(detail.Status)
// Note: "TAINTED" is described as a stable state per API docs, though can result from a failed update
// such that the stack rolls back to a previous version
if status == servicecatalog.ProvisionedProductStatusError || status == servicecatalog.ProvisionedProductStatusTainted {
tfresource.SetLastError(err, errors.New(aws.StringValue(detail.StatusMessage)))
}
}
return output, err
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ In addition to all arguments above, the following attributes are exported:

### status Meanings

~> **NOTE:** [Enable logging](https://www.terraform.io/plugin/log/managing) to `WARN` verbosity to further investigate error messages associated with a provisioned product in the `ERROR` or `TAINTED` state which can occur during resource creation or update.

* `AVAILABLE` - Stable state, ready to perform any operation. The most recent operation succeeded and completed.
* `UNDER_CHANGE` - Transitive state. Operations performed might not have
valid results. Wait for an `AVAILABLE` status before performing operations.
Expand Down

0 comments on commit 5a87cd3

Please sign in to comment.