instance.py

class botoform.enriched.instance.EnrichedInstance(instance, evpc=None)

This class uses composition to enrich Boto3’s Instance resource class.

ec2.Instance(boto3.resources.base.ServiceResource)

Reference:

https://boto3.readthedocs.org/en/latest/reference/services/ec2.html#instance

allocate_and_associate_eip()

Allocate and Associate a new EIP with instance and return EIP.

Returns:New VpcAddress EIP object
allocate_eip()

Allocate a new EIP and return allocation_id

Returns:New allocation_id
associate_eip(**kw)

Associate EIP with instance and return EIP.

Returns:New VpcAddress EIP object
autoscale_group

Return autoscaling group name (AWS aws:autoscaling:groupName tag).

disassociate_eips(release=True)

Disassociate all EIPs associated with this instance.

Parameters:release – Also release allocations for EIPs. Default True.
Return type:None
eips

Return a list of VpcAddress objects associated to this instance. :rtype: list

hostname

Return hostname (AWS Name tag).

id_human

Return humanhash of id.

identifiers

Return a tuple of “unique” identifier strings for instance. :rtype: tuple

identity

Return hostname (AWS Name tag) or id.

is_autoscaled

Return True if this instance was autoscaled else False

is_spot

Return True is this instance is a spot instance else False

lock()

Lock this instance to prevent termination.

name

Return hostname (AWS Name tag).

reflect_attrs()

reflect all attributes of ec2.Instance into self.

reload()

run the reload method on the attached instance and reflect_attrs.

role

Return role from from ‘role’ or ‘Name’ tag: web, db, …

shortname

Return shortname from hostname: web-solarmaine, db-beerindia, …

source_dest_check_disable()

Disable source destination checking. Needed for NATs and Routers.

source_dest_check_enable()

Enable source destination checking. Default.

tag_dict

Return dictionary of tags.

unlock()

Unlock this instance to allow termination.

wait_until_status_ok()

Wait (block) until this instance state is ‘OK’.