// setTags is a helper to set the tags for a resource. It expects the // tags field to be named "tags" func setTagsELB(conn *elb.ELB, 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 := diffTagsELB(tagsFromMapELB(o), tagsFromMapELB(n)) // Set tags if len(remove) > 0 { log.Printf("[DEBUG] Removing tags: %#v", remove) k := make([]*elb.TagKeyOnly, 0, len(remove)) for _, t := range remove { k = append(k, &elb.TagKeyOnly{Key: t.Key}) } _, err := conn.RemoveTags(&elb.RemoveTagsInput{ LoadBalancerNames: []*string{aws.String(d.Get("name").(string))}, Tags: k, }) if err != nil { return err } } if len(create) > 0 { log.Printf("[DEBUG] Creating tags: %#v", create) _, err := conn.AddTags(&elb.AddTagsInput{ LoadBalancerNames: []*string{aws.String(d.Get("name").(string))}, Tags: create, }) if err != nil { return err } } } return nil }