Adding support for detailed monitoring of instances
This commit is contained in:
parent
2423d104e6
commit
d23f534d26
|
@ -148,6 +148,11 @@ func resourceAwsInstance() *schema.Resource {
|
|||
Optional: true,
|
||||
},
|
||||
|
||||
"monitoring": &schema.Schema{
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
},
|
||||
|
||||
"iam_instance_profile": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
ForceNew: true,
|
||||
|
@ -324,6 +329,7 @@ func resourceAwsInstanceCreate(d *schema.ResourceData, meta interface{}) error {
|
|||
BlockDeviceMappings: instanceOpts.BlockDeviceMappings,
|
||||
DisableAPITermination: instanceOpts.DisableAPITermination,
|
||||
EBSOptimized: instanceOpts.EBSOptimized,
|
||||
Monitoring: instanceOpts.Monitoring,
|
||||
IAMInstanceProfile: instanceOpts.IAMInstanceProfile,
|
||||
ImageID: instanceOpts.ImageID,
|
||||
InstanceType: instanceOpts.InstanceType,
|
||||
|
@ -463,6 +469,12 @@ func resourceAwsInstanceRead(d *schema.ResourceData, meta interface{}) error {
|
|||
d.Set("subnet_id", instance.SubnetID)
|
||||
}
|
||||
d.Set("ebs_optimized", instance.EBSOptimized)
|
||||
|
||||
if instance.Monitoring != nil && instance.Monitoring.State != nil {
|
||||
monitoring_state := *instance.Monitoring.State
|
||||
d.Set("monitoring", monitoring_state == "enabled" || monitoring_state == "pending")
|
||||
}
|
||||
|
||||
d.Set("tags", tagsToMap(instance.Tags))
|
||||
|
||||
// Determine whether we're referring to security groups with
|
||||
|
@ -847,6 +859,7 @@ type awsInstanceOpts struct {
|
|||
BlockDeviceMappings []*ec2.BlockDeviceMapping
|
||||
DisableAPITermination *bool
|
||||
EBSOptimized *bool
|
||||
Monitoring *ec2.RunInstancesMonitoringEnabled
|
||||
IAMInstanceProfile *ec2.IAMInstanceProfileSpecification
|
||||
ImageID *string
|
||||
InstanceType *string
|
||||
|
@ -872,6 +885,10 @@ func buildAwsInstanceOpts(
|
|||
InstanceType: aws.String(d.Get("instance_type").(string)),
|
||||
}
|
||||
|
||||
opts.Monitoring = &ec2.RunInstancesMonitoringEnabled{
|
||||
Enabled: aws.Boolean(d.Get("monitoring").(bool)),
|
||||
}
|
||||
|
||||
opts.IAMInstanceProfile = &ec2.IAMInstanceProfileSpecification{
|
||||
Name: aws.String(d.Get("iam_instance_profile").(string)),
|
||||
}
|
||||
|
|
|
@ -83,6 +83,7 @@ func resourceAwsSpotInstanceRequestCreate(d *schema.ResourceData, meta interface
|
|||
LaunchSpecification: &ec2.RequestSpotLaunchSpecification{
|
||||
BlockDeviceMappings: instanceOpts.BlockDeviceMappings,
|
||||
EBSOptimized: instanceOpts.EBSOptimized,
|
||||
Monitoring: instanceOpts.Monitoring,
|
||||
IAMInstanceProfile: instanceOpts.IAMInstanceProfile,
|
||||
ImageID: instanceOpts.ImageID,
|
||||
InstanceType: instanceOpts.InstanceType,
|
||||
|
|
|
@ -34,6 +34,7 @@ The following arguments are supported:
|
|||
* `placement_group` - (Optional) The Placement Group to start the instance in.
|
||||
* `ebs_optimized` - (Optional) If true, the launched EC2 instance will be
|
||||
EBS-optimized.
|
||||
* `monitoring` - (Optional) If true, the launched EC2 instance will have detailed monitoring enabled.
|
||||
* `disable_api_termination` - (Optional) If true, enables [EC2 Instance
|
||||
Termination Protection](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/terminating-instances.html#Using_ChangingDisableAPITermination)
|
||||
* `instance_type` - (Required) The type of instance to start
|
||||
|
|
Loading…
Reference in New Issue