mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
Improve error reporting at creation
Code borrowed from nearby subscription filter resource.
This commit is contained in:
parent
3939a7220d
commit
e4b4d2b563
@ -2,11 +2,13 @@ package aws
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"time"
|
||||||
"github.com/hashicorp/terraform/helper/schema"
|
|
||||||
|
|
||||||
"github.com/aws/aws-sdk-go/aws"
|
"github.com/aws/aws-sdk-go/aws"
|
||||||
|
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||||
"github.com/aws/aws-sdk-go/service/cloudwatchlogs"
|
"github.com/aws/aws-sdk-go/service/cloudwatchlogs"
|
||||||
|
"github.com/hashicorp/terraform/helper/resource"
|
||||||
|
"github.com/hashicorp/terraform/helper/schema"
|
||||||
)
|
)
|
||||||
|
|
||||||
func resourceAwsCloudWatchLogDestination() *schema.Resource {
|
func resourceAwsCloudWatchLogDestination() *schema.Resource {
|
||||||
@ -62,15 +64,25 @@ func resourceAwsCloudWatchLogDestinationPut(d *schema.ResourceData, meta interfa
|
|||||||
TargetArn: aws.String(target_arn),
|
TargetArn: aws.String(target_arn),
|
||||||
}
|
}
|
||||||
|
|
||||||
resp, err := conn.PutDestination(params)
|
return resource.Retry(30*time.Second, func() *resource.RetryError {
|
||||||
|
resp, err := conn.PutDestination(params)
|
||||||
|
|
||||||
if err != nil {
|
if err == nil {
|
||||||
return fmt.Errorf("Error creating Destination with name %s: %#v", name, err)
|
d.SetId(*resp.Destination.Arn)
|
||||||
}
|
d.Set("arn", *resp.Destination.Arn)
|
||||||
|
}
|
||||||
|
|
||||||
d.SetId(*resp.Destination.Arn)
|
awsErr, ok := err.(awserr.Error)
|
||||||
d.Set("arn", *resp.Destination.Arn)
|
if !ok {
|
||||||
return resourceAwsCloudWatchLogDestinationRead(d, meta)
|
return resource.RetryableError(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if awsErr.Code() == "InvalidParameterException" {
|
||||||
|
return resource.NonRetryableError(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return resource.NonRetryableError(err)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceAwsCloudWatchLogDestinationRead(d *schema.ResourceData, meta interface{}) error {
|
func resourceAwsCloudWatchLogDestinationRead(d *schema.ResourceData, meta interface{}) error {
|
||||||
|
Loading…
Reference in New Issue
Block a user