salt.cloud.clouds.ec2

The EC2 Cloud Module

The EC2 cloud module is used to interact with the Amazon Elastic Cloud Computing. This driver is highly experimental! Use at your own risk!

To use the EC2 cloud module, set up the cloud configuration at
/etc/salt/cloud.providers or /etc/salt/cloud.providers.d/ec2.conf:
my-ec2-config:
  # The EC2 API authentication id
  id: GKTADJGHEIQSXMKKRBJ08H
  # The EC2 API authentication key
  key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs
  # The ssh keyname to use
  keyname: default
  # The amazon security group
  securitygroup: ssh_open
  # The location of the private key which corresponds to the keyname
  private_key: /root/default.pem

  # Be default, service_url is set to amazonaws.com. If you are using this
  # driver for something other than Amazon EC2, change it here:
  service_url: amazonaws.com

  # The endpoint that is ultimately used is usually formed using the region
  # and the service_url. If you would like to override that entirely, you
  # can explicitly define the endpoint:
  endpoint: myendpoint.example.com:1138/services/Cloud

  provider: ec2
salt.cloud.clouds.ec2.attach_volume(name=None, kwargs=None, instance_id=None, call=None)

Attach a volume to an instance

salt.cloud.clouds.ec2.avail_images(kwargs=None, call=None)

Return a dict of all available VM images on the cloud provider.

salt.cloud.clouds.ec2.avail_locations(call=None)

List all available locations

salt.cloud.clouds.ec2.avail_sizes(call=None)

Return a dict of all available VM sizes on the cloud provider with relevant data. Latest version can be found at:

http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instance-types.html

salt.cloud.clouds.ec2.block_device_mappings(vm_)

Return the block device mapping:

[{'DeviceName': '/dev/sdb', 'VirtualName': 'ephemeral0'},
  {'DeviceName': '/dev/sdc', 'VirtualName': 'ephemeral1'}]
salt.cloud.clouds.ec2.create(vm_=None, call=None)

Create a single VM from a data dict

salt.cloud.clouds.ec2.create_attach_volumes(name, kwargs, call=None)

Create and attach volumes to created node

salt.cloud.clouds.ec2.create_keypair(kwargs=None, call=None)

Create an SSH keypair

salt.cloud.clouds.ec2.create_volume(kwargs=None, call=None)

Create a volume

salt.cloud.clouds.ec2.del_tags(name, kwargs, call=None)

Delete tags for a node

CLI Example:

salt-cloud -a del_tags mymachine tag1,tag2,tag3
salt.cloud.clouds.ec2.delete_keypair(kwargs=None, call=None)

Delete an SSH keypair

salt.cloud.clouds.ec2.delete_volume(name=None, kwargs=None, instance_id=None, call=None)

Delete a volume

salt.cloud.clouds.ec2.delvol_on_destroy(name, kwargs=None, call=None)

Delete all/specified EBS volumes upon instance termination

CLI Example:

salt-cloud -a delvol_on_destroy mymachine
salt.cloud.clouds.ec2.destroy(name, call=None)

Destroy a node. Will check termination protection and warn if enabled.

CLI Example:

salt-cloud --destroy mymachine
salt.cloud.clouds.ec2.detach_volume(name=None, kwargs=None, instance_id=None, call=None)

Detach a volume from an instance

salt.cloud.clouds.ec2.disable_term_protect(name, call=None)

Disable termination protection on a node

CLI Example:

salt-cloud -a disable_term_protect mymachine
salt.cloud.clouds.ec2.enable_term_protect(name, call=None)

Enable termination protection on a node

CLI Example:

salt-cloud -a enable_term_protect mymachine
salt.cloud.clouds.ec2.get_availability_zone(vm_)

Return the availability zone to use

salt.cloud.clouds.ec2.get_configured_provider()

Return the first configured instance.

salt.cloud.clouds.ec2.get_location(vm_=None)
Return the EC2 region to use, in this order:
  • CLI parameter
  • VM parameter
  • Cloud profile setting
salt.cloud.clouds.ec2.get_spot_config(vm_)

Returns the spot instance configuration for the provided vm

salt.cloud.clouds.ec2.get_subnetid(vm_)

Returns the SubnetId to use

salt.cloud.clouds.ec2.get_tags(name=None, instance_id=None, call=None, location=None)

Retrieve tags for a node

salt.cloud.clouds.ec2.get_tenancy(vm_)

Returns the Tenancy to use.

Can be "dedicated" or "default". Cannot be present for spot instances.

salt.cloud.clouds.ec2.iam_profile(vm_)

Return the IAM profile.

The IAM instance profile to associate with the instances. This is either the Amazon Resource Name (ARN) of the instance profile or the name of the role.

Type: String

Default: None

Required: No

Example: arn:aws:iam::111111111111:instance-profile/s3access

Example: s3access

salt.cloud.clouds.ec2.keepvol_on_destroy(name, kwargs=None, call=None)

Do not delete all/specified EBS volumes upon instance termination

CLI Example:

salt-cloud -a keepvol_on_destroy mymachine
salt.cloud.clouds.ec2.keyname(vm_)

Return the keyname

salt.cloud.clouds.ec2.list_availability_zones()

List all availability zones in the current region

salt.cloud.clouds.ec2.list_nodes(call=None)

Return a list of the VMs that are on the provider

salt.cloud.clouds.ec2.list_nodes_full(location=None, call=None)

Return a list of the VMs that are on the provider

salt.cloud.clouds.ec2.list_nodes_select(call=None)

Return a list of the VMs that are on the provider, with select fields

salt.cloud.clouds.ec2.query(params=None, setname=None, requesturl=None, location=None, return_url=False, return_root=False)
salt.cloud.clouds.ec2.reboot(name, call=None)

Reboot a node.

CLI Example:

salt-cloud -a reboot mymachine
salt.cloud.clouds.ec2.rename(name, kwargs, call=None)

Properly rename a node. Pass in the new name as "new name".

CLI Example:

salt-cloud -a rename mymachine newname=yourmachine
salt.cloud.clouds.ec2.script(vm_)

Return the script deployment object

salt.cloud.clouds.ec2.securitygroup(vm_)

Return the security group

salt.cloud.clouds.ec2.securitygroupid(vm_)

Returns the SecurityGroupId

salt.cloud.clouds.ec2.set_tags(name, tags, call=None, location=None, instance_id=None)

Set tags for a node

CLI Example:

salt-cloud -a set_tags mymachine tag1=somestuff tag2='Other stuff'
salt.cloud.clouds.ec2.show_delvol_on_destroy(name, kwargs=None, call=None)

Do not delete all/specified EBS volumes upon instance termination

CLI Example:

salt-cloud -a show_delvol_on_destroy mymachine
salt.cloud.clouds.ec2.show_image(kwargs, call=None)

Show the details from EC2 concerning an AMI

salt.cloud.clouds.ec2.show_instance(name, call=None)

Show the details from EC2 concerning an AMI

salt.cloud.clouds.ec2.show_keypair(kwargs=None, call=None)

Show the details of an SSH keypair

salt.cloud.clouds.ec2.show_term_protect(name=None, instance_id=None, call=None, quiet=False)

Show the details from EC2 concerning an AMI

salt.cloud.clouds.ec2.show_volume(name=None, kwargs=None, instance_id=None, call=None)

Show volume details

salt.cloud.clouds.ec2.ssh_interface(vm_)

Return the ssh_interface type to connect to. Either 'public_ips' (default) or 'private_ips'.

salt.cloud.clouds.ec2.ssh_username(vm_)

Return the ssh_username. Defaults to a built-in list of users for trying.

salt.cloud.clouds.ec2.start(name, call=None)

Start a node

salt.cloud.clouds.ec2.stop(name, call=None)

Stop a node

Current Salt release: 2014.1.6

Docs for previous releases on salt.rtfd.org.

Table Of Contents

Previous topic

salt.cloud.clouds.digital_ocean

Next topic

salt.cloud.clouds.gce

Upcoming SaltStack Events