salt.states.boto_ec2

Manage EC2

New in version 2015.8.0.

This module provides an interface to the Elastic Compute Cloud (EC2) service from AWS.

The below code creates a key pair:

create-key-pair:
  boto_ec2.key_present:
    - name: mykeypair
    - save_private: /root/
    - region: eu-west-1
    - keyid: GKTADJGHEIQSXMKKRBJ08H
    - key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs
import-key-pair:
   boto_ec2.key_present:
    - name: mykeypair
    - upload_public: 'ssh-rsa AAAA'
    - keyid: GKTADJGHEIQSXMKKRBJ08H
    - key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs

You can also use salt:// in order to define the public key.

import-key-pair:
   boto_ec2.key_present:
    - name: mykeypair
    - upload_public: salt://mybase/public_key.pub
    - keyid: GKTADJGHEIQSXMKKRBJ08H
    - key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs

The below code deletes a key pair:

delete-key-pair:
  boto_ec2.key_absent:
    - name: mykeypair
    - region: eu-west-1
    - keyid: GKTADJGHEIQSXMKKRBJ08H
    - key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs
salt.states.boto_ec2.eni_absent(name, release_eip=False, region=None, key=None, keyid=None, profile=None)

Ensure the EC2 ENI is absent.

New in version 2016.3.0.

name
Name tag associated with the ENI.
release_eip
True/False - release any EIP associated with the ENI
region
Region to connect to.
key
Secret key to be used.
keyid
Access key to be used.
profile
A dict with region, key and keyid, or a pillar key (string) that contains a dict with region, key and keyid.
salt.states.boto_ec2.eni_present(name, subnet_id=None, subnet_name=None, private_ip_address=None, description=None, groups=None, source_dest_check=True, allocate_eip=False, arecords=None, region=None, key=None, keyid=None, profile=None)

Ensure the EC2 ENI exists.

New in version 2016.3.0.

name
Name tag associated with the ENI.
subnet_id
The VPC subnet ID the ENI will exist within.
subnet_name
The VPC subnet name the ENI will exist within.
private_ip_address
The private ip address to use for this ENI. If this is not specified AWS will automatically assign a private IP address to the ENI. Must be specified at creation time; will be ignored afterward.
description
Description of the key.
groups
A list of security groups to apply to the ENI.
source_dest_check
Boolean specifying whether source/destination checking is enabled on the ENI.
allocate_eip

True/False - allocate and associate an EIP to the ENI

New in version 2016.3.0.

arecords

A list of arecord dicts with attributes needed for the DNS add_record state. By default the boto_route53.add_record state will be used, which requires: name, zone, ttl, and identifier. See the boto_route53 state for information about these attributes. Other DNS modules can be called by specifying the provider keyword. By default, the private ENI IP address will be used, set 'public: True' in the arecord dict to use the ENI's public IP address

New in version 2016.3.0.

region
Region to connect to.
key
Secret key to be used.
keyid
Access key to be used.
profile
A dict with region, key and keyid, or a pillar key (string) that contains a dict with region, key and keyid.
salt.states.boto_ec2.instance_absent(name, instance_name=None, instance_id=None, region=None, key=None, keyid=None, profile=None)

Ensure an EC2 instance does not exist (is stopped and removed).

name
(string) - The name of the state definition.
instance_name
(string) - The name of the instance.
instance_id
(string) - The ID of the instance.
region
(string) - Region to connect to.
key
(string) - Secret key to be used.
keyid
(string) - Access key to be used.
profile
(variable) - A dict with region, key and keyid, or a pillar key (string) that contains a dict with region, key and keyid.

New in version 2016.3.0.

salt.states.boto_ec2.instance_present(name, instance_name=None, instance_id=None, image_id=None, image_name=None, tags=None, key_name=None, security_groups=None, user_data=None, instance_type=None, placement=None, kernel_id=None, ramdisk_id=None, vpc_id=None, vpc_name=None, monitoring_enabled=None, subnet_id=None, subnet_name=None, private_ip_address=None, block_device_map=None, disable_api_termination=None, instance_initiated_shutdown_behavior=None, placement_group=None, client_token=None, security_group_ids=None, security_group_names=None, additional_info=None, tenancy=None, instance_profile_arn=None, instance_profile_name=None, ebs_optimized=None, network_interfaces=None, attributes=None, target_state=None, region=None, key=None, keyid=None, profile=None)

Ensure an EC2 instance is running with the given attributes and state.

name
(string) - The name of the state definition. Recommended that this match the instance_name attribute (generally the FQDN of the instance).
instance_name
(string) - The name of the instance, generally its FQDN. Exclusive with 'instance_id'.
instance_id
(string) - The ID of the instance (if known). Exclusive with 'instance_name'.
image_id
(string) – The ID of the AMI image to run.
image_name
(string) – The name of the AMI image to run. NOT IMPLEMENTED.
tags
(dict) - Tags to apply to the instance.
key_name
(string) – The name of the key pair with which to launch instances.
security_groups
(list of strings) – The names of the EC2 classic security groups with which to associate instances
user_data
(string) – The Base64-encoded MIME user data to be made available to the instance(s) in this reservation.
instance_type
(string) – The EC2 instance size/type. Note that only certain types are compatible with HVM based AMIs.
placement
(string) – The Availability Zone to launch the instance into.
kernel_id
(string) – The ID of the kernel with which to launch the instances.
ramdisk_id
(string) – The ID of the RAM disk with which to launch the instances.
vpc_id
(string) - The ID of a VPC to attach the instance to.
vpc_name
(string) - The name of a VPC to attach the instance to.
monitoring_enabled
(bool) – Enable detailed CloudWatch monitoring on the instance.
subnet_id
(string) – The ID of the subnet within which to launch the instances for VPC.
subnet_name
(string) – The name of the subnet within which to launch the instances for VPC.
private_ip_address
(string) – If you’re using VPC, you can optionally use this parameter to assign the instance a specific available IP address from the subnet (e.g., 10.0.0.25).
block_device_map
(boto.ec2.blockdevicemapping.BlockDeviceMapping) – A BlockDeviceMapping data structure describing the EBS volumes associated with the Image.
disable_api_termination
(bool) – If True, the instances will be locked and will not be able to be terminated via the API.
instance_initiated_shutdown_behavior

(string) – Specifies whether the instance stops or terminates on instance-initiated shutdown. Valid values are:

  • 'stop'
  • 'terminate'
placement_group
(string) – If specified, this is the name of the placement group in which the instance(s) will be launched.
client_token
(string) – Unique, case-sensitive identifier you provide to ensure idempotency of the request. Maximum 64 ASCII characters.
security_group_ids
(list of strings) – The IDs of the VPC security groups with which to associate instances.
security_group_names
(list of strings) – The names of the VPC security groups with which to associate instances.
additional_info
(string) – Specifies additional information to make available to the instance(s).
tenancy
(string) – The tenancy of the instance you want to launch. An instance with a tenancy of ‘dedicated’ runs on single-tenant hardware and can only be launched into a VPC. Valid values are:”default” or “dedicated”. NOTE: To use dedicated tenancy you MUST specify a VPC subnet-ID as well.
instance_profile_arn
(string) – The Amazon resource name (ARN) of the IAM Instance Profile (IIP) to associate with the instances.
instance_profile_name
(string) – The name of the IAM Instance Profile (IIP) to associate with the instances.
ebs_optimized
(bool) – Whether the instance is optimized for EBS I/O. This optimization provides dedicated throughput to Amazon EBS and a tuned configuration stack to provide optimal EBS I/O performance. This optimization isn’t available with all instance types.
network_interfaces
(boto.ec2.networkinterface.NetworkInterfaceCollection) – A NetworkInterfaceCollection data structure containing the ENI specifications for the instance.
attributes

(dict) - Instance attributes and value to be applied to the instance. Available options are:

  • instanceType - A valid instance type (m1.small)
  • kernel - Kernel ID (None)
  • ramdisk - Ramdisk ID (None)
  • userData - Base64 encoded String (None)
  • disableApiTermination - Boolean (true)
  • instanceInitiatedShutdownBehavior - stop|terminate
  • blockDeviceMapping - List of strings - ie: [‘/dev/sda=false’]
  • sourceDestCheck - Boolean (true)
  • groupSet - Set of Security Groups or IDs
  • ebsOptimized - Boolean (false)
  • sriovNetSupport - String - ie: ‘simple’
target_state

(string) - The desired target state of the instance. Available options are:

  • running
  • stopped
region
(string) - Region to connect to.
key
(string) - Secret key to be used.
keyid
(string) - Access key to be used.
profile
(variable) - A dict with region, key and keyid, or a pillar key (string) that contains a dict with region, key and keyid.

New in version 2016.3.0.

salt.states.boto_ec2.key_absent(name, region=None, key=None, keyid=None, profile=None)

Deletes a key pair

salt.states.boto_ec2.key_present(name, save_private=None, upload_public=None, region=None, key=None, keyid=None, profile=None)

Ensure key pair is present.

salt.states.boto_ec2.snapshot_created(name, ami_name, instance_name, wait_until_available=True, wait_timeout_seconds=300, **kwargs)

Create a snapshot from the given instance

New in version 2016.3.0.