mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
Merge pull request #2794 from hashicorp/b-aws-instance-monitoring
provider/aws: Fix issue with toggling monitoring in AWS Instances
This commit is contained in:
commit
81957f7453
@ -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...
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user