// setTags is a helper to set the tags for a resource. It expects the // tags field to be named "tags" func setTagsCloudtrail(conn *cloudtrail.CloudTrail, d *schema.ResourceData) error { if d.HasChange("tags") { oraw, nraw := d.GetChange("tags") o := oraw.(map[string]interface{}) n := nraw.(map[string]interface{}) create, remove := diffTagsCloudtrail(tagsFromMapCloudtrail(o), tagsFromMapCloudtrail(n)) // Set tags if len(remove) > 0 { input := cloudtrail.RemoveTagsInput{ ResourceId: aws.String(d.Get("arn").(string)), TagsList: remove, } log.Printf("[DEBUG] Removing CloudTrail tags: %s", input) _, err := conn.RemoveTags(&input) if err != nil { return err } } if len(create) > 0 { input := cloudtrail.AddTagsInput{ ResourceId: aws.String(d.Get("arn").(string)), TagsList: create, } log.Printf("[DEBUG] Adding CloudTrail tags: %s", input) _, err := conn.AddTags(&input) if err != nil { return err } } } return nil }