Allow recovering from failed CW Event Target creation in state
This commit is contained in:
parent
5a786d52d9
commit
dc45f84a8f
|
@ -8,6 +8,7 @@ import (
|
||||||
"github.com/hashicorp/terraform/helper/schema"
|
"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"
|
||||||
events "github.com/aws/aws-sdk-go/service/cloudwatchevents"
|
events "github.com/aws/aws-sdk-go/service/cloudwatchevents"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -94,6 +95,15 @@ func resourceAwsCloudWatchEventTargetRead(d *schema.ResourceData, meta interface
|
||||||
d.SetId("")
|
d.SetId("")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
if awsErr, ok := err.(awserr.Error); ok {
|
||||||
|
// This should never happen, but it's useful
|
||||||
|
// for recovering from https://github.com/hashicorp/terraform/issues/5389
|
||||||
|
if awsErr.Code() == "ValidationException" {
|
||||||
|
log.Printf("[WARN] Removing CloudWatch Event Target %q because it never existed.", d.Id())
|
||||||
|
d.SetId("")
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
log.Printf("[DEBUG] Found Event Target: %s", t)
|
log.Printf("[DEBUG] Found Event Target: %s", t)
|
||||||
|
|
Loading…
Reference in New Issue