From 50556c58b8e25e5c2588928c7043601f2ca847c4 Mon Sep 17 00:00:00 2001 From: Paul Stack Date: Wed, 24 Aug 2016 13:02:48 +0100 Subject: [PATCH] provider/aws: Refresh `aws_cloudwatch_event_target` from state on `ResourceNotFoundException` (#8442) * provider/aws: Refresh `aws_cloudwatch_event_target` from state on `ResourceNotFoundException` Fixes #6928 @radeksimko FYI :) * Update resource_aws_cloudwatch_event_target.go --- .../providers/aws/resource_aws_cloudwatch_event_target.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/builtin/providers/aws/resource_aws_cloudwatch_event_target.go b/builtin/providers/aws/resource_aws_cloudwatch_event_target.go index 73d362fc8..767b94b16 100644 --- a/builtin/providers/aws/resource_aws_cloudwatch_event_target.go +++ b/builtin/providers/aws/resource_aws_cloudwatch_event_target.go @@ -112,6 +112,13 @@ func resourceAwsCloudWatchEventTargetRead(d *schema.ResourceData, meta interface d.SetId("") return nil } + + if awsErr.Code() == "ResourceNotFoundException" { + log.Printf("[WARN] CloudWatch Event Target (%q) not found. Removing it from state.", d.Id()) + d.SetId("") + return nil + } + } return err }