Class: Serverspec::Type::AWS::EC2::Instance
- Inherits:
-
Base
- Object
- Base
- Serverspec::Type::AWS::EC2::Instance
- Defined in:
- lib/resources/ec2/instance.rb
Overview
The Instance class exposes the EC2::Instance resources
Instance Attribute Summary collapse
-
#instance_id ⇒ Object
readonly
The ID of the Instance.
-
#instance_name ⇒ Object
readonly
The Name tag of the Instance (if available).
Instance Method Summary collapse
-
#architecture ⇒ String
The architecture of the image.
-
#block_device_mappings ⇒ Array(Hash)
Any block device mappings for the Instance.
-
#ebs_optimized? ⇒ Boolean
Specifies whether the Instance is optimized for EBS I/O.
-
#enhanced_networked? ⇒ Boolean
Specifies whether enhanced networking is enabled.
-
#hypervisor ⇒ String
The hypervisor type of the Instance.
-
#iam_instance_profile ⇒ Hash
The IAM Instance profile associtated with the Instance.
-
#image_id ⇒ String
The ID of the AMI used to launch the Instance.
-
#initialize(instance_id_name, instance = nil) ⇒ Instance
constructor
AWS SDK for Ruby v2 Aws::EC2::Client wrapper for initializing an Instance resource.
-
#instance_lifecycle ⇒ String
Indicates whether this is a spot Instance.
-
#instance_type ⇒ String
The Instance type.
-
#kernel_id ⇒ String
The kernel associtated to this Instance.
-
#key_name ⇒ String
The name of the key pair.
-
#monitoring_enabled? ⇒ Boolean
Indicates whether the monitoring is enabled for the Instance.
-
#network_interfaces ⇒ Array(Hash)
One or more NetworkInterfaces for the Instance.
-
#on_windows? ⇒ Boolean
Returns true if the platform is Windows.
-
#placement ⇒ Hash
The location where the Instance launched.
-
#private_dns_name ⇒ String
The private DNS name assigned to the Instance.
-
#private_ip_address ⇒ String
The private IP address assigned to the Instance.
-
#public_dns_name ⇒ String
The public DNS name assigned to the Instance.
-
#public_ip_address ⇒ String
The public IP address assigned to the Instance.
-
#ramdisk_id ⇒ String
The RAM disk associtated to this Instance.
-
#root_device_name ⇒ String
The root device name (eg: /dev/sda1, /dev/xvda1).
-
#root_device_type ⇒ String
The root device type used by the AMI.
-
#running? ⇒ Boolean
Returns true if the Instance state is 'running'.
-
#security_groups ⇒ Array(Hash)
One or more SecurityGroups for the Instance.
-
#source_dest_checked? ⇒ Boolean
Specifies whether the Instance launched in a VPC is able to perform NAT.
-
#subnet_id ⇒ String
The ID of the subnet in which the Instance is running.
-
#tags ⇒ Array(Hash)
Any tags assigned to the Instance.
-
#to_s ⇒ String
Returns the string representation of EC2::Instance.
-
#virtualization_type ⇒ String
The virtualization type of the Instance, whether is HVM or PV.
-
#vpc_id ⇒ String
The ID of the VPC in which the Instance is running.
Constructor Details
#initialize(instance_id_name, instance = nil) ⇒ Instance
AWS SDK for Ruby v2 Aws::EC2::Client wrapper for initializing an Instance resource
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/resources/ec2/instance.rb', line 20 def initialize(instance_id_name, instance = nil) check_init_arg 'instance_id_name', 'EC2::instance', instance_id_name @aws = instance.nil? ? Aws::EC2::Client.new : instance if instance_id_name.match(/^i-[A-Fa-f0-9]{8}$/).nil? @instance_name = instance_id_name get_instance_by_name instance_id_name else @instance_id = instance_id_name get_instance_by_id instance_id_name end end |
Instance Attribute Details
#instance_id ⇒ Object (readonly)
The ID of the Instance
9 10 11 |
# File 'lib/resources/ec2/instance.rb', line 9 def instance_id @instance_id end |
#instance_name ⇒ Object (readonly)
The Name tag of the Instance (if available)
11 12 13 |
# File 'lib/resources/ec2/instance.rb', line 11 def instance_name @instance_name end |
Instance Method Details
#architecture ⇒ String
The architecture of the image
145 146 147 |
# File 'lib/resources/ec2/instance.rb', line 145 def architecture @instance.architecture end |
#block_device_mappings ⇒ Array(Hash)
Any block device mappings for the Instance
164 165 166 |
# File 'lib/resources/ec2/instance.rb', line 164 def block_device_mappings @instance.block_device_mappings end |
#ebs_optimized? ⇒ Boolean
Specifies whether the Instance is optimized for EBS I/O
61 62 63 |
# File 'lib/resources/ec2/instance.rb', line 61 def ebs_optimized? @instance.ebs_optimized end |
#enhanced_networked? ⇒ Boolean
Specifies whether enhanced networking is enabled
66 67 68 |
# File 'lib/resources/ec2/instance.rb', line 66 def enhanced_networked? @instance.sriov_net_support == 'simple' end |
#hypervisor ⇒ String
The hypervisor type of the Instance
194 195 196 |
# File 'lib/resources/ec2/instance.rb', line 194 def hypervisor @instance.hypervisor end |
#iam_instance_profile ⇒ Hash
The IAM Instance profile associtated with the Instance
206 207 208 |
# File 'lib/resources/ec2/instance.rb', line 206 def iam_instance_profile @instance.iam_instance_profile end |
#image_id ⇒ String
The ID of the AMI used to launch the Instance
72 73 74 |
# File 'lib/resources/ec2/instance.rb', line 72 def image_id @instance.image_id end |
#instance_lifecycle ⇒ String
Indicates whether this is a spot Instance
176 177 178 |
# File 'lib/resources/ec2/instance.rb', line 176 def instance_lifecycle @instance.instance_lifecycle end |
#instance_type ⇒ String
The Instance type
96 97 98 |
# File 'lib/resources/ec2/instance.rb', line 96 def instance_type @instance.instance_type end |
#kernel_id ⇒ String
The kernel associtated to this Instance
109 110 111 |
# File 'lib/resources/ec2/instance.rb', line 109 def kernel_id @instance.kernel_id end |
#key_name ⇒ String
The name of the key pair
90 91 92 |
# File 'lib/resources/ec2/instance.rb', line 90 def key_name @instance.key_name end |
#monitoring_enabled? ⇒ Boolean
Indicates whether the monitoring is enabled for the Instance
45 46 47 |
# File 'lib/resources/ec2/instance.rb', line 45 def monitoring_enabled? @instance.monitoring.state == 'enabled' end |
#network_interfaces ⇒ Array(Hash)
One or more NetworkInterfaces for the Instance
200 201 202 |
# File 'lib/resources/ec2/instance.rb', line 200 def network_interfaces @instance.network_interfaces end |
#on_windows? ⇒ Boolean
Returns true if the platform is Windows
50 51 52 |
# File 'lib/resources/ec2/instance.rb', line 50 def on_windows? @instance.platform.casecmp('windows').zero? end |
#placement ⇒ Hash
The location where the Instance launched. Indicates the availability zone, the placement group, and the Instance tenancy
103 104 105 |
# File 'lib/resources/ec2/instance.rb', line 103 def placement @instance.placement end |
#private_dns_name ⇒ String
The private DNS name assigned to the Instance
78 79 80 |
# File 'lib/resources/ec2/instance.rb', line 78 def private_dns_name @instance.private_dns_name end |
#private_ip_address ⇒ String
The private IP address assigned to the Instance
133 134 135 |
# File 'lib/resources/ec2/instance.rb', line 133 def private_ip_address @instance.private_ip_address end |
#public_dns_name ⇒ String
The public DNS name assigned to the Instance
84 85 86 |
# File 'lib/resources/ec2/instance.rb', line 84 def public_dns_name @instance.public_dns_name end |
#public_ip_address ⇒ String
The public IP address assigned to the Instance
139 140 141 |
# File 'lib/resources/ec2/instance.rb', line 139 def public_ip_address @instance.public_ip_address end |
#ramdisk_id ⇒ String
The RAM disk associtated to this Instance
115 116 117 |
# File 'lib/resources/ec2/instance.rb', line 115 def ramdisk_id @instance.ramdisk_id end |
#root_device_name ⇒ String
The root device name (eg: /dev/sda1, /dev/xvda1)
158 159 160 |
# File 'lib/resources/ec2/instance.rb', line 158 def root_device_name @instance.root_device_name end |
#root_device_type ⇒ String
The root device type used by the AMI. It can be an EBS volume or Instance store
152 153 154 |
# File 'lib/resources/ec2/instance.rb', line 152 def root_device_type @instance.root_device_type end |
#running? ⇒ Boolean
Returns true if the Instance state is 'running'
40 41 42 |
# File 'lib/resources/ec2/instance.rb', line 40 def running? @instance.state.name == 'running' end |
#security_groups ⇒ Array(Hash)
One or more SecurityGroups for the Instance
188 189 190 |
# File 'lib/resources/ec2/instance.rb', line 188 def security_groups @instance.security_groups end |
#source_dest_checked? ⇒ Boolean
Specifies whether the Instance launched in a VPC is able to perform NAT. The value must be false for the Instance to perform NAT
56 57 58 |
# File 'lib/resources/ec2/instance.rb', line 56 def source_dest_checked? @instance.source_dest_check end |
#subnet_id ⇒ String
The ID of the subnet in which the Instance is running
121 122 123 |
# File 'lib/resources/ec2/instance.rb', line 121 def subnet_id @instance.subnet_id end |
#tags ⇒ Array(Hash)
Any tags assigned to the Instance
182 183 184 |
# File 'lib/resources/ec2/instance.rb', line 182 def @instance. end |
#to_s ⇒ String
Returns the string representation of EC2::Instance
34 35 36 37 |
# File 'lib/resources/ec2/instance.rb', line 34 def to_s return "EC2 Instance ID: #{@instance_id}" if @instance_name.nil? "EC2 Instance ID: #{@instance_id}; Name: #{@instance_name}" end |
#virtualization_type ⇒ String
The virtualization type of the Instance, whether is HVM or PV
170 171 172 |
# File 'lib/resources/ec2/instance.rb', line 170 def virtualization_type @instance.virtualization_type end |
#vpc_id ⇒ String
The ID of the VPC in which the Instance is running
127 128 129 |
# File 'lib/resources/ec2/instance.rb', line 127 def vpc_id @instance.vpc_id end |