Skip to content

Commit

Permalink
Merge pull request #2794 from hashicorp/b-aws-instance-monitoring
Browse files Browse the repository at this point in the history
provider/aws: Fix issue with toggling monitoring in AWS Instances
  • Loading branch information
catsby committed Jul 21, 2015
2 parents f7ab12c + db5d030 commit 81957f7
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions builtin/providers/aws/resource_aws_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,24 @@ func resourceAwsInstanceUpdate(d *schema.ResourceData, meta interface{}) error {
}
}

if d.HasChange("monitoring") {
var mErr error
if d.Get("monitoring").(bool) {
log.Printf("[DEBUG] Enabling monitoring for Instance (%s)", d.Id())
_, mErr = conn.MonitorInstances(&ec2.MonitorInstancesInput{
InstanceIDs: []*string{aws.String(d.Id())},
})
} else {
log.Printf("[DEBUG] Disabling monitoring for Instance (%s)", d.Id())
_, mErr = conn.UnmonitorInstances(&ec2.UnmonitorInstancesInput{
InstanceIDs: []*string{aws.String(d.Id())},
})
}
if mErr != nil {
return fmt.Errorf("[WARN] Error updating Instance monitoring: %s", mErr)
}
}

// TODO(mitchellh): wait for the attributes we modified to
// persist the change...

Expand Down

0 comments on commit 81957f7

Please sign in to comment.