-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20463 from hashicorp/t-aws_synthetics_canary-test…
…-failures r/aws_synthetics_canary: Correctly report creation errors
- Loading branch information
Showing
6 changed files
with
197 additions
and
168 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
```release-note:bug | ||
resource/aws_synthetics_canary: Correctly report any resource creation errors | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,25 @@ | ||
package waiter | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/aws/aws-sdk-go/aws" | ||
"github.com/aws/aws-sdk-go/service/synthetics" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
"github.com/terraform-providers/terraform-provider-aws/aws/internal/service/synthetics/finder" | ||
"github.com/terraform-providers/terraform-provider-aws/aws/internal/tfresource" | ||
) | ||
|
||
func CanaryStatus(conn *synthetics.Synthetics, name string) resource.StateRefreshFunc { | ||
func CanaryState(conn *synthetics.Synthetics, name string) resource.StateRefreshFunc { | ||
return func() (interface{}, string, error) { | ||
output, err := finder.CanaryByName(conn, name) | ||
|
||
if err != nil { | ||
return nil, synthetics.CanaryStateError, err | ||
if tfresource.NotFound(err) { | ||
return nil, "", nil | ||
} | ||
|
||
if aws.StringValue(output.Canary.Status.State) == synthetics.CanaryStateError { | ||
return output, synthetics.CanaryStateError, fmt.Errorf("%s: %s", aws.StringValue(output.Canary.Status.StateReasonCode), aws.StringValue(output.Canary.Status.StateReason)) | ||
if err != nil { | ||
return nil, "", err | ||
} | ||
|
||
return output, aws.StringValue(output.Canary.Status.State), nil | ||
return output, aws.StringValue(output.Status.State), nil | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.