Fix: Do not store ID of CW Event Target if creation fails

This commit is contained in:
Radek Simko 2016-03-01 12:35:15 +00:00
parent 1448b84b37
commit 5a786d52d9
1 changed files with 3 additions and 3 deletions

View File

@ -61,9 +61,6 @@ func resourceAwsCloudWatchEventTargetCreate(d *schema.ResourceData, meta interfa
rule := d.Get("rule").(string)
targetId := d.Get("target_id").(string)
id := rule + "-" + targetId
d.SetId(id)
input := buildPutTargetInputStruct(d)
log.Printf("[DEBUG] Creating CloudWatch Event Target: %s", input)
out, err := conn.PutTargets(input)
@ -76,6 +73,9 @@ func resourceAwsCloudWatchEventTargetCreate(d *schema.ResourceData, meta interfa
out.FailedEntries)
}
id := rule + "-" + targetId
d.SetId(id)
log.Printf("[INFO] CloudWatch Event Target %q created", d.Id())
return resourceAwsCloudWatchEventTargetRead(d, meta)