lib/terraforming/resource/ec2.rb in terraforming-0.3.0 vs lib/terraforming/resource/ec2.rb in terraforming-0.3.1
- old
+ new
@@ -31,10 +31,11 @@
"ebs_block_device.#"=> ebs_block_devices_in(block_devices, instance).length.to_s,
"ebs_optimized"=> instance.ebs_optimized.to_s,
"ephemeral_block_device.#" => "0", # Terraform 0.6.1 cannot fetch this field from AWS
"id"=> instance.instance_id,
"instance_type"=> instance.instance_type,
+ "monitoring" => monitoring_state(instance).to_s,
"private_dns"=> instance.private_dns_name,
"private_ip"=> instance.private_ip_address,
"public_dns"=> instance.public_dns_name,
"public_ip"=> instance.public_ip_address,
"root_block_device.#"=> root_block_devices_in(block_devices, instance).length.to_s,
@@ -88,9 +89,13 @@
# https://github.com/hashicorp/terraform/blob/281e4d3e67f66daab9cdb1f7c8b6f602d949e5ee/builtin/providers/aws/resource_aws_instance.go#L481-L501
#
def in_vpc?(instance)
vpc_security_groups_of(instance).length > 0 ||
(instance.subnet_id && instance.subnet_id != "" && instance.security_groups.length == 0)
+ end
+
+ def monitoring_state(instance)
+ %w(enabled pending).include?(instance.monitoring.state)
end
def instances
@client.describe_instances.reservations.map(&:instances).flatten.reject { |instance| instance.state.name == "terminated" }
end