2013-07-08 14:39:09 +00:00
|
|
|
============================
|
|
|
|
Getting Started With AWS EC2
|
|
|
|
============================
|
2012-07-13 07:53:14 +00:00
|
|
|
|
2013-07-08 14:39:09 +00:00
|
|
|
Amazon EC2 is a very widely used public cloud platform and one of the core
|
2012-07-13 07:53:14 +00:00
|
|
|
platforms Salt Cloud has been built to support.
|
|
|
|
|
2014-02-04 04:11:56 +00:00
|
|
|
Previously, the suggested provider for AWS EC2 was the ``aws`` provider. This
|
|
|
|
has been deprecated in favor of the ``ec2`` provider. Configuration using the
|
|
|
|
old ``aws`` provider will still function, but that driver is no longer in
|
|
|
|
active development.
|
2013-07-08 14:39:09 +00:00
|
|
|
|
2014-04-01 18:23:50 +00:00
|
|
|
|
|
|
|
Dependencies
|
|
|
|
============
|
|
|
|
This driver requires the Python ``requests`` library to be installed.
|
|
|
|
|
|
|
|
|
|
|
|
Configuration
|
|
|
|
=============
|
|
|
|
The following example illustrates some of the options that can be set. These
|
|
|
|
parameters are discussed in more detail below.
|
|
|
|
|
2013-04-02 18:25:45 +00:00
|
|
|
.. code-block:: yaml
|
|
|
|
|
2013-11-23 03:25:33 +00:00
|
|
|
# Note: This example is for /etc/salt/cloud.providers or any file in the
|
|
|
|
# /etc/salt/cloud.providers.d/ directory.
|
|
|
|
|
|
|
|
my-ec2-southeast-public-ips:
|
|
|
|
# Set up the location of the salt master
|
|
|
|
#
|
|
|
|
minion:
|
|
|
|
master: saltmaster.example.com
|
|
|
|
|
|
|
|
# Set up grains information, which will be common for all nodes
|
|
|
|
# using this provider
|
|
|
|
grains:
|
|
|
|
node_type: broker
|
|
|
|
release: 1.0.1
|
|
|
|
|
|
|
|
# Specify whether to use public or private IP for deploy script.
|
|
|
|
#
|
|
|
|
# Valid options are:
|
2014-11-19 18:32:07 +00:00
|
|
|
# private_ips - The salt-cloud command is run inside the EC2
|
|
|
|
# public_ips - The salt-cloud command is run outside of EC2
|
2013-11-23 03:25:33 +00:00
|
|
|
#
|
|
|
|
ssh_interface: public_ips
|
|
|
|
|
2015-03-02 02:54:22 +00:00
|
|
|
# Optionally configure the Windows credential validation number of
|
|
|
|
# retries and delay between retries. This defaults to 10 retries
|
|
|
|
# with a one second delay betwee retries
|
|
|
|
win_deploy_auth_retries: 10
|
|
|
|
win_deploy_auth_retry_delay: 1
|
|
|
|
|
2013-11-23 03:25:33 +00:00
|
|
|
# Set the EC2 access credentials (see below)
|
|
|
|
#
|
2015-02-26 03:51:45 +00:00
|
|
|
id: 'use-instance-role-credentials'
|
|
|
|
key: 'use-instance-role-credentials'
|
2013-11-23 03:25:33 +00:00
|
|
|
|
|
|
|
# Make sure this key is owned by root with permissions 0400.
|
|
|
|
#
|
|
|
|
private_key: /etc/salt/my_test_key.pem
|
|
|
|
keyname: my_test_key
|
|
|
|
securitygroup: default
|
|
|
|
|
|
|
|
# Optionally configure default region
|
2014-09-17 22:16:35 +00:00
|
|
|
# Use salt-cloud --list-locations <provider> to obtain valid regions
|
2013-11-23 03:25:33 +00:00
|
|
|
#
|
|
|
|
location: ap-southeast-1
|
|
|
|
availability_zone: ap-southeast-1b
|
|
|
|
|
|
|
|
# Configure which user to use to run the deploy script. This setting is
|
|
|
|
# dependent upon the AMI that is used to deploy. It is usually safer to
|
|
|
|
# configure this individually in a profile, than globally. Typical users
|
|
|
|
# are:
|
|
|
|
#
|
|
|
|
# Amazon Linux -> ec2-user
|
|
|
|
# RHEL -> ec2-user
|
|
|
|
# CentOS -> ec2-user
|
|
|
|
# Ubuntu -> ubuntu
|
|
|
|
#
|
|
|
|
ssh_username: ec2-user
|
|
|
|
|
|
|
|
# Optionally add an IAM profile
|
|
|
|
iam_profile: 'arn:aws:iam::123456789012:instance-profile/ExampleInstanceProfile'
|
|
|
|
|
2015-06-17 22:41:03 +00:00
|
|
|
driver: ec2
|
2013-11-23 03:25:33 +00:00
|
|
|
|
|
|
|
|
|
|
|
my-ec2-southeast-private-ips:
|
|
|
|
# Set up the location of the salt master
|
|
|
|
#
|
|
|
|
minion:
|
|
|
|
master: saltmaster.example.com
|
|
|
|
|
|
|
|
# Specify whether to use public or private IP for deploy script.
|
|
|
|
#
|
|
|
|
# Valid options are:
|
|
|
|
# private_ips - The salt-master is also hosted with EC2
|
|
|
|
# public_ips - The salt-master is hosted outside of EC2
|
|
|
|
#
|
|
|
|
ssh_interface: private_ips
|
|
|
|
|
2015-03-02 02:54:22 +00:00
|
|
|
# Optionally configure the Windows credential validation number of
|
|
|
|
# retries and delay between retries. This defaults to 10 retries
|
|
|
|
# with a one second delay betwee retries
|
|
|
|
win_deploy_auth_retries: 10
|
|
|
|
win_deploy_auth_retry_delay: 1
|
|
|
|
|
2013-11-23 03:25:33 +00:00
|
|
|
# Set the EC2 access credentials (see below)
|
|
|
|
#
|
2015-02-26 03:51:45 +00:00
|
|
|
id: 'use-instance-role-credentials'
|
|
|
|
key: 'use-instance-role-credentials'
|
2013-11-23 03:25:33 +00:00
|
|
|
|
|
|
|
# Make sure this key is owned by root with permissions 0400.
|
|
|
|
#
|
|
|
|
private_key: /etc/salt/my_test_key.pem
|
|
|
|
keyname: my_test_key
|
2015-05-08 14:50:24 +00:00
|
|
|
|
|
|
|
# This one should NOT be specified if VPC was not configured in AWS to be
|
|
|
|
# the default. It might cause an error message which sais that network
|
|
|
|
# interfaces and an instance-level security groups may not be specified
|
|
|
|
# on the same request.
|
|
|
|
#
|
2013-11-23 03:25:33 +00:00
|
|
|
securitygroup: default
|
|
|
|
|
|
|
|
# Optionally configure default region
|
|
|
|
#
|
|
|
|
location: ap-southeast-1
|
|
|
|
availability_zone: ap-southeast-1b
|
|
|
|
|
|
|
|
# Configure which user to use to run the deploy script. This setting is
|
|
|
|
# dependent upon the AMI that is used to deploy. It is usually safer to
|
|
|
|
# configure this individually in a profile, than globally. Typical users
|
|
|
|
# are:
|
|
|
|
#
|
|
|
|
# Amazon Linux -> ec2-user
|
|
|
|
# RHEL -> ec2-user
|
|
|
|
# CentOS -> ec2-user
|
|
|
|
# Ubuntu -> ubuntu
|
|
|
|
#
|
|
|
|
ssh_username: ec2-user
|
|
|
|
|
|
|
|
# Optionally add an IAM profile
|
|
|
|
iam_profile: 'my other profile name'
|
|
|
|
|
2015-06-17 22:41:03 +00:00
|
|
|
driver: ec2
|
2013-04-04 23:06:55 +00:00
|
|
|
|
2013-04-02 18:25:45 +00:00
|
|
|
|
2013-03-07 21:07:47 +00:00
|
|
|
Access Credentials
|
|
|
|
==================
|
2013-09-24 15:58:22 +00:00
|
|
|
The ``id`` and ``key`` settings may be found in the Security Credentials area
|
2013-03-07 21:07:47 +00:00
|
|
|
of the AWS Account page:
|
|
|
|
|
|
|
|
https://portal.aws.amazon.com/gp/aws/securityCredentials
|
|
|
|
|
2013-09-24 15:58:22 +00:00
|
|
|
Both are located in the Access Credentials area of the page, under the Access
|
|
|
|
Keys tab. The ``id`` setting is labeled Access Key ID, and the ``key`` setting
|
2013-03-07 21:07:47 +00:00
|
|
|
is labeled Secret Access Key.
|
|
|
|
|
2015-02-26 03:51:45 +00:00
|
|
|
Note: if either ``id`` or ``key`` is set to 'use-instance-role-credentials' it is
|
|
|
|
assumed that Salt is running on an AWS instance, and the instance role
|
|
|
|
credentials will be retrieved and used. Since both the ``id`` and ``key`` are
|
|
|
|
required parameters for the AWS ec2 provider, it is recommended to set both
|
2015-02-26 03:57:05 +00:00
|
|
|
to 'use-instance-role-credentials' for this functionality.
|
2015-02-26 03:51:45 +00:00
|
|
|
|
|
|
|
A "static" and "permanent" Access Key ID and Secret Key can be specified,
|
|
|
|
but this is not recommended. Instance role keys are rotated on a regular
|
|
|
|
basis, and are the recommended method of specifying AWS credentials.
|
2013-03-07 21:07:47 +00:00
|
|
|
|
2015-03-02 02:54:22 +00:00
|
|
|
Windows Deploy Timeouts
|
|
|
|
=======================
|
|
|
|
For Windows instances, it may take longer than normal for the instance to be
|
|
|
|
ready. In these circumstances, the provider configuration can be configured
|
|
|
|
with a ``win_deploy_auth_retries`` and/or a ``win_deploy_auth_retry_delay``
|
|
|
|
setting, which default to 10 retries and a one second delay between retries.
|
|
|
|
These retries and timeouts relate to validating the Administrator password
|
|
|
|
once AWS provides the credentials via the AWS API.
|
|
|
|
|
|
|
|
|
2015-02-28 22:08:44 +00:00
|
|
|
Windows Deploy Timeouts
|
|
|
|
=======================
|
|
|
|
For Windows instances, it may take longer than normal for the instance to be
|
|
|
|
ready. In these circumstances, the provider configuration can be configured
|
|
|
|
with a ``win_deploy_auth_retries`` and/or a ``win_deploy_auth_retry_delay``
|
|
|
|
setting, which default to 10 retries and a one second delay between retries.
|
|
|
|
These retries and timeouts relate to validating the Administrator password
|
|
|
|
once AWS provides the credentials via the AWS API.
|
|
|
|
|
2013-03-07 21:07:47 +00:00
|
|
|
|
|
|
|
Key Pairs
|
|
|
|
=========
|
2013-09-24 15:58:22 +00:00
|
|
|
In order to create an instance with Salt installed and configured, a key pair
|
|
|
|
will need to be created. This can be done in the EC2 Management Console, in the
|
|
|
|
Key Pairs area. These key pairs are unique to a specific region. Keys in the
|
2013-03-07 21:07:47 +00:00
|
|
|
us-east-1 region can be configured at:
|
|
|
|
|
|
|
|
https://console.aws.amazon.com/ec2/home?region=us-east-1#s=KeyPairs
|
|
|
|
|
|
|
|
Keys in the us-west-1 region can be configured at
|
|
|
|
|
|
|
|
https://console.aws.amazon.com/ec2/home?region=us-west-1#s=KeyPairs
|
|
|
|
|
2013-09-24 15:58:22 +00:00
|
|
|
...and so on. When creating a key pair, the browser will prompt to download a
|
2014-01-10 20:43:08 +00:00
|
|
|
pem file. This file must be placed in a directory accessible by Salt Cloud,
|
2013-03-07 21:07:47 +00:00
|
|
|
with permissions set to either 0400 or 0600.
|
|
|
|
|
|
|
|
|
|
|
|
Security Groups
|
|
|
|
===============
|
2013-09-24 15:58:22 +00:00
|
|
|
An instance on EC2 needs to belong to a security group. Like key pairs, these
|
|
|
|
are unique to a specific region. These are also configured in the EC2
|
|
|
|
Management Console. Security groups for the us-east-1 region can be configured
|
2013-04-02 18:25:45 +00:00
|
|
|
at:
|
2013-03-07 21:07:47 +00:00
|
|
|
|
|
|
|
https://console.aws.amazon.com/ec2/home?region=us-east-1#s=SecurityGroups
|
|
|
|
|
|
|
|
...and so on.
|
2013-03-03 01:48:05 +00:00
|
|
|
|
2013-09-24 15:58:22 +00:00
|
|
|
A security group defines firewall rules which an instance will adhere to. If
|
|
|
|
the salt-master is configured outside of EC2, the security group must open the
|
2013-03-07 21:07:47 +00:00
|
|
|
SSH port (usually port 22) in order for Salt Cloud to install Salt.
|
2013-03-03 01:48:05 +00:00
|
|
|
|
2013-03-07 21:07:47 +00:00
|
|
|
|
2013-09-24 15:58:22 +00:00
|
|
|
IAM Profile
|
|
|
|
===========
|
|
|
|
Amazon EC2 instances support the concept of an `instance profile`_, which
|
|
|
|
is a logical container for the IAM role. At the time that you launch an EC2
|
|
|
|
instance, you can associate the instance with an instance profile, which in
|
|
|
|
turn corresponds to the IAM role. Any software that runs on the EC2 instance
|
|
|
|
is able to access AWS using the permissions associated with the IAM role.
|
|
|
|
|
2014-01-10 20:43:08 +00:00
|
|
|
Scaffolding the profile is a 2-step configuration process:
|
2013-09-24 15:58:22 +00:00
|
|
|
|
2014-02-04 04:11:56 +00:00
|
|
|
1. Configure an IAM Role from the `IAM Management Console`_.
|
|
|
|
2. Attach this role to a new profile. It can be done with the `AWS CLI`_:
|
2013-09-24 15:58:22 +00:00
|
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
|
2014-02-04 04:11:56 +00:00
|
|
|
> aws iam create-instance-profile --instance-profile-name PROFILE_NAME
|
|
|
|
> aws iam add-role-to-instance-profile --instance-profile-name PROFILE_NAME --role-name ROLE_NAME
|
2013-09-24 15:58:22 +00:00
|
|
|
|
|
|
|
Once the profile is created, you can use the **PROFILE_NAME** to configure
|
|
|
|
your cloud profiles.
|
|
|
|
|
|
|
|
.. _`IAM Management Console`: https://console.aws.amazon.com/iam/home?#roles
|
|
|
|
.. _`AWS CLI`: http://docs.aws.amazon.com/cli/latest/index.html
|
|
|
|
.. _`instance profile`: http://docs.aws.amazon.com/IAM/latest/UserGuide/instance-profiles.html
|
|
|
|
|
|
|
|
|
2013-03-07 21:07:47 +00:00
|
|
|
Cloud Profiles
|
|
|
|
==============
|
2012-07-13 07:53:14 +00:00
|
|
|
Set up an initial profile at ``/etc/salt/cloud.profiles``:
|
|
|
|
|
2013-04-02 18:25:45 +00:00
|
|
|
.. code-block:: yaml
|
|
|
|
|
2013-07-08 14:39:09 +00:00
|
|
|
base_ec2_private:
|
|
|
|
provider: my-ec2-southeast-private-ips
|
2013-04-02 18:25:45 +00:00
|
|
|
image: ami-e565ba8c
|
2014-09-27 17:09:08 +00:00
|
|
|
size: t1.micro
|
2013-07-08 14:39:09 +00:00
|
|
|
ssh_username: ec2-user
|
2013-04-02 18:25:45 +00:00
|
|
|
|
2013-07-08 14:39:09 +00:00
|
|
|
base_ec2_public:
|
|
|
|
provider: my-ec2-southeast-public-ips
|
2013-04-02 18:25:45 +00:00
|
|
|
image: ami-e565ba8c
|
2014-09-27 17:09:08 +00:00
|
|
|
size: t1.micro
|
2013-07-08 14:39:09 +00:00
|
|
|
ssh_username: ec2-user
|
2013-04-02 18:25:45 +00:00
|
|
|
|
2013-08-10 08:41:41 +00:00
|
|
|
base_ec2_db:
|
|
|
|
provider: my-ec2-southeast-public-ips
|
|
|
|
image: ami-e565ba8c
|
|
|
|
size: m1.xlarge
|
|
|
|
ssh_username: ec2-user
|
|
|
|
volumes:
|
|
|
|
- { size: 10, device: /dev/sdf }
|
|
|
|
- { size: 10, device: /dev/sdg, type: io1, iops: 1000 }
|
|
|
|
- { size: 10, device: /dev/sdh, type: io1, iops: 1000 }
|
2014-03-12 20:32:47 +00:00
|
|
|
# optionally add tags to profile:
|
|
|
|
tag: {'Environment': 'production', 'Role': 'database'}
|
|
|
|
# force grains to sync after install
|
|
|
|
sync_after_install: grains
|
|
|
|
|
|
|
|
base_ec2_vpc:
|
|
|
|
provider: my-ec2-southeast-public-ips
|
|
|
|
image: ami-a73264ce
|
|
|
|
size: m1.xlarge
|
|
|
|
ssh_username: ec2-user
|
|
|
|
script: /etc/salt/cloud.deploy.d/user_data.sh
|
|
|
|
network_interfaces:
|
|
|
|
- DeviceIndex: 0
|
|
|
|
PrivateIpAddresses:
|
|
|
|
- Primary: True
|
|
|
|
#auto assign public ip (not EIP)
|
|
|
|
AssociatePublicIpAddress: True
|
|
|
|
SubnetId: subnet-813d4bbf
|
|
|
|
SecurityGroupId:
|
|
|
|
- sg-750af413
|
|
|
|
volumes:
|
|
|
|
- { size: 10, device: /dev/sdf }
|
|
|
|
- { size: 10, device: /dev/sdg, type: io1, iops: 1000 }
|
|
|
|
- { size: 10, device: /dev/sdh, type: io1, iops: 1000 }
|
|
|
|
del_root_vol_on_destroy: True
|
|
|
|
del_all_vol_on_destroy: True
|
|
|
|
tag: {'Environment': 'production', 'Role': 'database'}
|
|
|
|
sync_after_install: grains
|
2013-08-10 08:41:41 +00:00
|
|
|
|
2012-07-13 07:53:14 +00:00
|
|
|
|
2014-01-10 20:43:08 +00:00
|
|
|
The profile can now be realized with a salt command:
|
2012-07-13 07:53:14 +00:00
|
|
|
|
2013-02-28 07:57:17 +00:00
|
|
|
.. code-block:: bash
|
2012-07-13 07:53:14 +00:00
|
|
|
|
2013-07-08 14:39:09 +00:00
|
|
|
# salt-cloud -p base_ec2 ami.example.com
|
|
|
|
# salt-cloud -p base_ec2_public ami.example.com
|
|
|
|
# salt-cloud -p base_ec2_private ami.example.com
|
2012-07-13 07:53:14 +00:00
|
|
|
|
2013-04-04 23:06:55 +00:00
|
|
|
|
2013-09-24 15:58:22 +00:00
|
|
|
This will create an instance named ``ami.example.com`` in EC2. The minion that
|
|
|
|
is installed on this instance will have an ``id`` of ``ami.example.com``. If
|
|
|
|
the command was executed on the salt-master, its Salt key will automatically be
|
2013-03-07 21:07:47 +00:00
|
|
|
signed on the master.
|
|
|
|
|
2013-09-24 15:58:22 +00:00
|
|
|
Once the instance has been created with salt-minion installed, connectivity to
|
2013-03-07 21:07:47 +00:00
|
|
|
it can be verified with Salt:
|
2012-07-13 07:53:14 +00:00
|
|
|
|
2013-03-07 21:07:47 +00:00
|
|
|
.. code-block:: bash
|
2013-03-03 01:48:05 +00:00
|
|
|
|
2013-03-07 21:07:47 +00:00
|
|
|
# salt 'ami.example.com' test.ping
|
2013-03-03 01:48:05 +00:00
|
|
|
|
2012-10-12 17:58:50 +00:00
|
|
|
|
|
|
|
Required Settings
|
|
|
|
=================
|
2013-07-08 14:39:09 +00:00
|
|
|
The following settings are always required for EC2:
|
2012-10-12 17:58:50 +00:00
|
|
|
|
2013-04-02 18:25:45 +00:00
|
|
|
.. code-block:: yaml
|
|
|
|
|
2013-07-08 14:39:09 +00:00
|
|
|
# Set the EC2 login data
|
|
|
|
my-ec2-config:
|
2013-04-02 18:25:45 +00:00
|
|
|
id: HJGRYCILJLKJYG
|
|
|
|
key: 'kdjgfsgm;woormgl/aserigjksjdhasdfgn'
|
|
|
|
keyname: test
|
|
|
|
securitygroup: quick-start
|
|
|
|
private_key: /root/test.pem
|
2015-06-17 22:41:03 +00:00
|
|
|
driver: ec2
|
2013-04-02 18:25:45 +00:00
|
|
|
|
|
|
|
|
2012-10-12 17:58:50 +00:00
|
|
|
Optional Settings
|
|
|
|
=================
|
2013-04-02 18:25:45 +00:00
|
|
|
|
2013-09-24 15:58:22 +00:00
|
|
|
EC2 allows a location to be set for servers to be deployed in. Availability
|
2012-10-12 17:58:50 +00:00
|
|
|
zones exist inside regions, and may be added to increase specificity.
|
|
|
|
|
2013-04-02 18:25:45 +00:00
|
|
|
.. code-block:: yaml
|
|
|
|
|
2013-07-08 14:39:09 +00:00
|
|
|
my-ec2-config:
|
2013-04-02 18:25:45 +00:00
|
|
|
# Optionally configure default region
|
|
|
|
location: ap-southeast-1
|
|
|
|
availability_zone: ap-southeast-1b
|
|
|
|
|
|
|
|
|
2013-09-24 15:58:22 +00:00
|
|
|
EC2 instances can have a public or private IP, or both. When an instance is
|
2012-10-12 17:58:50 +00:00
|
|
|
deployed, Salt Cloud needs to log into it via SSH to run the deploy script.
|
2013-09-24 15:58:22 +00:00
|
|
|
By default, the public IP will be used for this. If the salt-cloud command is
|
2013-07-08 14:39:09 +00:00
|
|
|
run from another EC2 instance, the private IP should be used.
|
2013-04-02 18:25:45 +00:00
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
2013-07-08 14:39:09 +00:00
|
|
|
my-ec2-config:
|
2013-04-02 18:25:45 +00:00
|
|
|
# Specify whether to use public or private IP for deploy script
|
|
|
|
# private_ips or public_ips
|
|
|
|
ssh_interface: public_ips
|
|
|
|
|
|
|
|
|
2013-07-08 14:39:09 +00:00
|
|
|
Many EC2 instances do not allow remote access to the root user by default.
|
2013-09-24 15:58:22 +00:00
|
|
|
Instead, another user must be used to run the deploy script using sudo. Some
|
|
|
|
common usernames include ec2-user (for Amazon Linux), ubuntu (for Ubuntu
|
|
|
|
instances), admin (official Debian) and bitnami (for images provided by
|
2013-03-07 21:07:47 +00:00
|
|
|
Bitnami).
|
2012-10-12 17:58:50 +00:00
|
|
|
|
2013-04-02 18:25:45 +00:00
|
|
|
.. code-block:: yaml
|
|
|
|
|
2013-07-08 14:39:09 +00:00
|
|
|
my-ec2-config:
|
2013-04-02 18:25:45 +00:00
|
|
|
# Configure which user to use to run the deploy script
|
|
|
|
ssh_username: ec2-user
|
|
|
|
|
|
|
|
|
2013-09-24 15:58:22 +00:00
|
|
|
Multiple usernames can be provided, in which case Salt Cloud will attempt to
|
|
|
|
guess the correct username. This is mostly useful in the main configuration
|
2012-10-12 17:58:50 +00:00
|
|
|
file:
|
|
|
|
|
2013-04-02 18:25:45 +00:00
|
|
|
.. code-block:: yaml
|
|
|
|
|
2013-07-08 14:39:09 +00:00
|
|
|
my-ec2-config:
|
2013-04-02 18:25:45 +00:00
|
|
|
ssh_username:
|
|
|
|
- ec2-user
|
|
|
|
- ubuntu
|
|
|
|
- admin
|
|
|
|
- bitnami
|
|
|
|
|
|
|
|
|
2012-10-12 17:58:50 +00:00
|
|
|
Multiple security groups can also be specified in the same fashion:
|
|
|
|
|
2013-04-06 14:08:24 +00:00
|
|
|
.. code-block:: yaml
|
|
|
|
|
2013-07-08 14:39:09 +00:00
|
|
|
my-ec2-config:
|
2013-04-06 14:08:24 +00:00
|
|
|
securitygroup:
|
|
|
|
- default
|
|
|
|
- extra
|
|
|
|
|
2014-01-10 20:43:08 +00:00
|
|
|
Your instances may optionally make use of EC2 Spot Instances. The
|
2014-01-10 18:16:51 +00:00
|
|
|
following example will request that spot instances be used and your
|
|
|
|
maximum bid will be $0.10. Keep in mind that different spot prices
|
|
|
|
may be needed based on the current value of the various EC2 instance
|
|
|
|
sizes. You can check current and past spot instance pricing via the
|
|
|
|
EC2 API or AWS Console.
|
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
my-ec2-config:
|
|
|
|
spot_config:
|
|
|
|
spot_price: 0.10
|
|
|
|
|
|
|
|
By default, the spot instance type is set to 'one-time', meaning it will
|
|
|
|
be launched and, if it's ever terminated for whatever reason, it will not
|
|
|
|
be recreated. If you would like your spot instances to be relaunched after
|
|
|
|
a termination (by your or AWS), set the ``type`` to 'persistent'.
|
|
|
|
|
|
|
|
NOTE: Spot instances are a great way to save a bit of money, but you do
|
|
|
|
run the risk of losing your spot instances if the current price for the
|
|
|
|
instance size goes above your maximum bid.
|
|
|
|
|
|
|
|
The following parameters may be set in the cloud configuration file to
|
|
|
|
control various aspects of the spot instance launching:
|
|
|
|
|
2014-02-04 04:11:56 +00:00
|
|
|
* ``wait_for_spot_timeout``: seconds to wait before giving up on spot instance
|
|
|
|
launch (default=600)
|
|
|
|
* ``wait_for_spot_interval``: seconds to wait in between polling requests to
|
|
|
|
determine if a spot instance is available (default=30)
|
|
|
|
* ``wait_for_spot_interval_multiplier``: a multiplier to add to the interval in
|
|
|
|
between requests, which is useful if AWS is throttling your requests
|
|
|
|
(default=1)
|
|
|
|
* ``wait_for_spot_max_failures``: maximum number of failures before giving up
|
|
|
|
on launching your spot instance (default=10)
|
2014-01-10 18:16:51 +00:00
|
|
|
|
2014-01-10 18:46:51 +00:00
|
|
|
If you find that you're being throttled by AWS while polling for spot
|
|
|
|
instances, you can set the following in your core cloud configuration
|
|
|
|
file that will double the polling interval after each request to AWS.
|
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
wait_for_spot_interval: 1
|
|
|
|
wait_for_spot_interval_multiplier: 2
|
|
|
|
|
2014-01-10 18:16:51 +00:00
|
|
|
See the `AWS Spot Instances`_ documentation for more information.
|
|
|
|
|
2013-04-06 14:08:24 +00:00
|
|
|
|
2013-04-04 19:32:17 +00:00
|
|
|
Block device mappings enable you to specify additional EBS volumes or instance
|
|
|
|
store volumes when the instance is launched. This setting is also available on
|
2014-02-04 04:11:56 +00:00
|
|
|
each cloud profile. Note that the number of instance stores varies by instance
|
|
|
|
type. If more mappings are provided than are supported by the instance type,
|
|
|
|
mappings will be created in the order provided and additional mappings will be
|
|
|
|
ignored. Consult the `AWS documentation`_ for a listing of the available
|
2015-06-02 22:32:26 +00:00
|
|
|
instance stores, and device names.
|
2013-04-02 18:25:45 +00:00
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
2013-07-08 14:39:09 +00:00
|
|
|
my-ec2-config:
|
2013-04-06 14:08:24 +00:00
|
|
|
block_device_mappings:
|
|
|
|
- DeviceName: /dev/sdb
|
|
|
|
VirtualName: ephemeral0
|
|
|
|
- DeviceName: /dev/sdc
|
|
|
|
VirtualName: ephemeral1
|
2013-04-02 18:25:45 +00:00
|
|
|
|
2014-01-10 20:43:08 +00:00
|
|
|
You can also use block device mappings to change the size of the root device at the
|
|
|
|
provisioning time. For example, assuming the root device is '/dev/sda', you can set
|
2013-10-31 16:22:44 +00:00
|
|
|
its size to 100G by using the following configuration.
|
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
my-ec2-config:
|
|
|
|
block_device_mappings:
|
|
|
|
- DeviceName: /dev/sda
|
2014-01-10 20:43:08 +00:00
|
|
|
Ebs.VolumeSize: 100
|
2014-10-21 05:18:31 +00:00
|
|
|
Ebs.VolumeType: gp2
|
2014-10-21 04:59:02 +00:00
|
|
|
Ebs.SnapshotId: dummy0
|
2013-10-31 16:22:44 +00:00
|
|
|
|
2014-01-10 18:16:51 +00:00
|
|
|
Existing EBS volumes may also be attached (not created) to your instances or
|
|
|
|
you can create new EBS volumes based on EBS snapshots. To simply attach an
|
|
|
|
existing volume use the ``volume_id`` parameter.
|
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
device: /dev/xvdj
|
|
|
|
volume_id: vol-12345abcd
|
|
|
|
|
|
|
|
Or, to create a volume from an EBS snapshot, use the ``snapshot`` parameter.
|
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
device: /dev/xvdj
|
|
|
|
snapshot: snap-abcd12345
|
|
|
|
|
|
|
|
Note that ``volume_id`` will take precedence over the ``snapshot`` parameter.
|
2013-04-02 18:25:45 +00:00
|
|
|
|
2013-08-16 23:59:54 +00:00
|
|
|
Tags can be set once an instance has been launched.
|
|
|
|
|
2013-11-08 21:51:01 +00:00
|
|
|
.. code-block:: yaml
|
2013-08-16 23:59:54 +00:00
|
|
|
|
|
|
|
my-ec2-config:
|
|
|
|
tag:
|
|
|
|
tag0: value
|
2014-04-16 14:49:19 +00:00
|
|
|
tag1: value
|
2013-08-16 23:59:54 +00:00
|
|
|
|
2013-10-04 17:10:48 +00:00
|
|
|
.. _`AWS documentation`: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/InstanceStorage.html
|
2014-02-20 23:16:59 +00:00
|
|
|
.. _`AWS Spot Instances`: http://aws.amazon.com/ec2/purchasing-options/spot-instances/
|
2013-08-16 23:59:54 +00:00
|
|
|
|
2013-07-08 14:39:09 +00:00
|
|
|
Modify EC2 Tags
|
2013-02-14 22:03:46 +00:00
|
|
|
===============
|
2013-09-24 15:58:22 +00:00
|
|
|
One of the features of EC2 is the ability to tag resources. In fact, under the
|
|
|
|
hood, the names given to EC2 instances by salt-cloud are actually just stored
|
2013-02-14 22:03:46 +00:00
|
|
|
as a tag called Name. Salt Cloud has the ability to manage these tags:
|
|
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
|
|
|
|
salt-cloud -a get_tags mymachine
|
|
|
|
salt-cloud -a set_tags mymachine tag1=somestuff tag2='Other stuff'
|
|
|
|
salt-cloud -a del_tags mymachine tag1,tag2,tag3
|
|
|
|
|
2014-04-16 14:49:19 +00:00
|
|
|
It is possible to manage tags on any resource in EC2 with a Resource ID, not
|
|
|
|
just instances:
|
|
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
|
|
|
|
salt-cloud -f get_tags my_ec2 resource_id=af5467ba
|
|
|
|
salt-cloud -f set_tags my_ec2 resource_id=af5467ba tag1=somestuff
|
|
|
|
salt-cloud -f del_tags my_ec2 resource_id=af5467ba tag1,tag2,tag3
|
|
|
|
|
2013-03-07 21:07:47 +00:00
|
|
|
|
2013-07-08 14:39:09 +00:00
|
|
|
Rename EC2 Instances
|
2013-02-14 22:03:46 +00:00
|
|
|
====================
|
2013-09-24 15:58:22 +00:00
|
|
|
As mentioned above, EC2 instances are named via a tag. However, renaming an
|
|
|
|
instance by renaming its tag will cause the salt keys to mismatch. A rename
|
2013-02-14 22:03:46 +00:00
|
|
|
function exists which renames both the instance, and the salt keys.
|
|
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
|
|
|
|
salt-cloud -a rename mymachine newname=yourmachine
|
|
|
|
|
2013-03-07 21:07:47 +00:00
|
|
|
|
2013-07-08 14:39:09 +00:00
|
|
|
EC2 Termination Protection
|
2013-02-14 22:03:46 +00:00
|
|
|
==========================
|
2013-09-24 15:58:22 +00:00
|
|
|
EC2 allows the user to enable and disable termination protection on a specific
|
2013-02-14 22:03:46 +00:00
|
|
|
instance. An instance with this protection enabled cannot be destroyed.
|
|
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
|
|
|
|
salt-cloud -a enable_term_protect mymachine
|
|
|
|
salt-cloud -a disable_term_protect mymachine
|
|
|
|
|
2013-03-07 21:07:47 +00:00
|
|
|
|
2013-03-07 18:58:27 +00:00
|
|
|
Rename on Destroy
|
|
|
|
=================
|
2013-09-24 15:58:22 +00:00
|
|
|
When instances on EC2 are destroyed, there will be a lag between the time that
|
|
|
|
the action is sent, and the time that Amazon cleans up the instance. During
|
|
|
|
this time, the instance still retails a Name tag, which will cause a collision
|
|
|
|
if the creation of an instance with the same name is attempted before the
|
|
|
|
cleanup occurs. In order to avoid such collisions, Salt Cloud can be configured
|
|
|
|
to rename instances when they are destroyed. The new name will look something
|
2013-04-02 18:25:45 +00:00
|
|
|
like:
|
2013-03-07 18:58:27 +00:00
|
|
|
|
2013-03-13 23:31:57 +00:00
|
|
|
.. code-block:: bash
|
2013-03-07 18:58:27 +00:00
|
|
|
|
|
|
|
myinstance-DEL20f5b8ad4eb64ed88f2c428df80a1a0c
|
|
|
|
|
2013-04-02 18:25:45 +00:00
|
|
|
|
2013-09-24 15:58:22 +00:00
|
|
|
In order to enable this, add rename_on_destroy line to the main
|
2013-03-07 18:58:27 +00:00
|
|
|
configuration file:
|
|
|
|
|
2013-04-02 18:25:45 +00:00
|
|
|
.. code-block:: yaml
|
|
|
|
|
2013-07-08 14:39:09 +00:00
|
|
|
my-ec2-config:
|
2013-04-02 18:25:45 +00:00
|
|
|
rename_on_destroy: True
|
|
|
|
|
|
|
|
|
2013-12-14 02:46:38 +00:00
|
|
|
Listing Images
|
|
|
|
==============
|
|
|
|
Normally, images can be queried on a cloud provider by passing the
|
|
|
|
``--list-images`` argument to Salt Cloud. This still holds true for EC2:
|
|
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
|
|
|
|
salt-cloud --list-images my-ec2-config
|
|
|
|
|
|
|
|
However, the full list of images on EC2 is extremely large, and querying all of
|
|
|
|
the available images may cause Salt Cloud to behave as if frozen. Therefore,
|
|
|
|
the default behavior of this option may be modified, by adding an ``owner``
|
|
|
|
argument to the provider configuration:
|
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
owner: aws-marketplace
|
|
|
|
|
|
|
|
The possible values for this setting are ``amazon``, ``aws-marketplace``,
|
|
|
|
``self``, ``<AWS account ID>`` or ``all``. The default setting is ``amazon``.
|
2013-12-14 02:52:38 +00:00
|
|
|
Take note that ``all`` and ``aws-marketplace`` may cause Salt Cloud to appear
|
|
|
|
as if it is freezing, as it tries to handle the large amount of data.
|
2013-12-14 02:46:38 +00:00
|
|
|
|
|
|
|
It is also possible to perform this query using different settings without
|
|
|
|
modifying the configuration files. To do this, call the ``avail_images``
|
|
|
|
function directly:
|
|
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
|
|
|
|
salt-cloud -f avail_images my-ec2-config owner=aws-marketplace
|
|
|
|
|
|
|
|
|
2013-01-22 18:20:58 +00:00
|
|
|
EC2 Images
|
|
|
|
==========
|
2013-09-24 15:58:22 +00:00
|
|
|
The following are lists of available AMI images, generally sorted by OS. These
|
|
|
|
lists are on 3rd-party websites, are not managed by Salt Stack in any way. They
|
|
|
|
are provided here as a reference for those who are interested, and contain no
|
|
|
|
warranty (express or implied) from anyone affiliated with Salt Stack. Most of
|
2013-01-22 18:20:58 +00:00
|
|
|
them have never been used, much less tested, by the Salt Stack team.
|
|
|
|
|
2013-11-11 07:20:14 +00:00
|
|
|
* `Arch Linux`__
|
2013-01-22 18:20:58 +00:00
|
|
|
|
2014-02-04 04:11:56 +00:00
|
|
|
.. __: https://wiki.archlinux.org/index.php/Arch_Linux_AMIs_for_Amazon_Web_Services
|
2013-01-22 18:20:58 +00:00
|
|
|
|
2013-11-11 07:20:14 +00:00
|
|
|
* `FreeBSD`__
|
2013-01-22 18:20:58 +00:00
|
|
|
|
2014-02-04 04:11:56 +00:00
|
|
|
.. __: http://www.daemonology.net/freebsd-on-ec2/
|
2013-01-22 18:20:58 +00:00
|
|
|
|
2013-11-11 07:20:14 +00:00
|
|
|
* `Fedora`__
|
2013-01-22 18:20:58 +00:00
|
|
|
|
2014-02-04 04:11:56 +00:00
|
|
|
.. __: https://fedoraproject.org/wiki/Cloud_images
|
2013-01-22 18:20:58 +00:00
|
|
|
|
2013-11-11 07:20:14 +00:00
|
|
|
* `CentOS`__
|
2013-06-20 01:50:40 +00:00
|
|
|
|
2014-02-04 04:11:56 +00:00
|
|
|
.. __: http://wiki.centos.org/Cloud/AWS
|
2013-11-11 07:20:14 +00:00
|
|
|
|
|
|
|
* `Ubuntu`__
|
|
|
|
|
2014-02-04 04:11:56 +00:00
|
|
|
.. __: http://cloud-images.ubuntu.com/locator/ec2/
|
2013-11-11 07:20:14 +00:00
|
|
|
|
|
|
|
* `Debian`__
|
|
|
|
|
2014-02-20 23:16:59 +00:00
|
|
|
.. __: https://wiki.debian.org/Cloud/AmazonEC2Image
|
2013-11-11 07:20:14 +00:00
|
|
|
|
|
|
|
* `OmniOS`__
|
|
|
|
|
2014-02-04 04:11:56 +00:00
|
|
|
.. __: http://omnios.omniti.com/wiki.php/Installation#IntheCloud
|
2013-11-11 07:20:14 +00:00
|
|
|
|
|
|
|
* `All Images on Amazon`__
|
|
|
|
|
2014-02-20 23:16:59 +00:00
|
|
|
.. __: https://aws.amazon.com/marketplace
|
2013-02-22 16:37:09 +00:00
|
|
|
|
2013-03-07 21:07:47 +00:00
|
|
|
|
2013-02-22 17:11:25 +00:00
|
|
|
show_image
|
|
|
|
==========
|
2013-09-24 15:58:22 +00:00
|
|
|
This is a function that describes an AMI on EC2. This will give insight as to
|
2013-02-22 17:11:25 +00:00
|
|
|
the defaults that will be applied to an instance using a particular AMI.
|
|
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
|
2013-03-07 16:55:44 +00:00
|
|
|
$ salt-cloud -f show_image ec2 image=ami-fd20ad94
|
2013-02-22 17:11:25 +00:00
|
|
|
|
2013-03-07 21:07:47 +00:00
|
|
|
|
2013-02-22 17:11:25 +00:00
|
|
|
show_instance
|
|
|
|
=============
|
2014-01-10 20:43:08 +00:00
|
|
|
This action is a thin wrapper around ``--full-query``, which displays details on a
|
2013-09-24 15:58:22 +00:00
|
|
|
single instance only. In an environment with several machines, this will save a
|
|
|
|
user from having to sort through all instance data, just to examine a single
|
2013-03-07 21:07:47 +00:00
|
|
|
instance.
|
2013-02-22 17:11:25 +00:00
|
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
|
|
|
|
$ salt-cloud -a show_instance myinstance
|
|
|
|
|
2013-03-07 21:07:47 +00:00
|
|
|
|
2013-12-16 00:48:27 +00:00
|
|
|
ebs_optimized
|
|
|
|
=============
|
|
|
|
This argument enables switching of the EbsOptimized setting which default
|
|
|
|
to 'false'. Indicates whether the instance is optimized for EBS I/O. This
|
|
|
|
optimization provides dedicated throughput to Amazon EBS and an optimized
|
|
|
|
configuration stack to provide optimal Amazon EBS I/O performance. This
|
|
|
|
optimization isn't available with all instance types. Additional usage
|
|
|
|
charges apply when using an EBS-optimized instance.
|
|
|
|
|
|
|
|
This setting can be added to the profile or map file for an instance.
|
|
|
|
|
|
|
|
If set to True, this setting will enable an instance to be EbsOptimized
|
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
ebs_optimized: True
|
|
|
|
|
|
|
|
This can also be set as a cloud provider setting in the EC2 cloud
|
|
|
|
configuration:
|
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
my-ec2-config:
|
|
|
|
ebs_optimized: True
|
|
|
|
|
|
|
|
|
2013-08-16 12:06:00 +00:00
|
|
|
del_root_vol_on_destroy
|
|
|
|
=======================
|
2013-09-24 15:58:22 +00:00
|
|
|
This argument overrides the default DeleteOnTermination setting in the AMI for
|
2013-08-16 12:06:00 +00:00
|
|
|
the EBS root volumes for an instance. Many AMIs contain 'false' as a default,
|
2013-09-24 15:58:22 +00:00
|
|
|
resulting in orphaned volumes in the EC2 account, which may unknowingly be
|
|
|
|
charged to the account. This setting can be added to the profile or map file
|
2013-02-22 16:37:09 +00:00
|
|
|
for an instance.
|
|
|
|
|
2013-08-16 12:06:00 +00:00
|
|
|
If set, this setting will apply to the root EBS volume
|
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
del_root_vol_on_destroy: True
|
|
|
|
|
|
|
|
|
|
|
|
This can also be set as a cloud provider setting in the EC2 cloud
|
|
|
|
configuration:
|
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
my-ec2-config:
|
|
|
|
del_root_vol_on_destroy: True
|
|
|
|
|
|
|
|
|
|
|
|
del_all_vols_on_destroy
|
|
|
|
=======================
|
2013-09-24 15:58:22 +00:00
|
|
|
This argument overrides the default DeleteOnTermination setting in the AMI for
|
2013-08-16 12:06:00 +00:00
|
|
|
the not-root EBS volumes for an instance. Many AMIs contain 'false' as a
|
|
|
|
default, resulting in orphaned volumes in the EC2 account, which may
|
|
|
|
unknowingly be charged to the account. This setting can be added to the profile
|
|
|
|
or map file for an instance.
|
|
|
|
|
|
|
|
If set, this setting will apply to any (non-root) volumes that were created
|
|
|
|
by salt-cloud using the 'volumes' setting.
|
|
|
|
|
|
|
|
The volumes will not be deleted under the following conditions
|
|
|
|
* If a volume is detached before terminating the instance
|
|
|
|
* If a volume is created without this setting and attached to the instance
|
2013-08-12 05:44:47 +00:00
|
|
|
|
2013-02-22 16:37:09 +00:00
|
|
|
.. code-block:: yaml
|
|
|
|
|
2013-08-16 12:06:00 +00:00
|
|
|
del_all_vols_on_destroy: True
|
2013-02-22 16:37:09 +00:00
|
|
|
|
2013-03-05 15:08:59 +00:00
|
|
|
|
2013-08-16 12:06:00 +00:00
|
|
|
This can also be set as a cloud provider setting in the EC2 cloud
|
2013-04-02 18:25:45 +00:00
|
|
|
configuration:
|
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
2013-04-06 14:08:24 +00:00
|
|
|
my-ec2-config:
|
2013-08-16 12:06:00 +00:00
|
|
|
del_all_vols_on_destroy: True
|
2013-03-05 15:08:59 +00:00
|
|
|
|
2013-04-02 18:25:45 +00:00
|
|
|
|
2013-08-16 12:06:00 +00:00
|
|
|
The setting for this may be changed on all volumes of an existing instance
|
|
|
|
using one of the following commands:
|
2013-02-22 16:37:09 +00:00
|
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
|
|
|
|
salt-cloud -a delvol_on_destroy myinstance
|
|
|
|
salt-cloud -a keepvol_on_destroy myinstance
|
2013-09-02 10:52:26 +00:00
|
|
|
salt-cloud -a show_delvol_on_destroy myinstance
|
2013-02-22 16:37:09 +00:00
|
|
|
|
2013-08-12 05:44:47 +00:00
|
|
|
The setting for this may be changed on a volume on an existing instance
|
|
|
|
using one of the following commands:
|
|
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
|
|
|
|
salt-cloud -a delvol_on_destroy myinstance device=/dev/sda1
|
|
|
|
salt-cloud -a delvol_on_destroy myinstance volume_id=vol-1a2b3c4d
|
|
|
|
salt-cloud -a keepvol_on_destroy myinstance device=/dev/sda1
|
|
|
|
salt-cloud -a keepvol_on_destroy myinstance volume_id=vol-1a2b3c4d
|
2013-09-02 10:52:26 +00:00
|
|
|
salt-cloud -a show_delvol_on_destroy myinstance device=/dev/sda1
|
|
|
|
salt-cloud -a show_delvol_on_destroy myinstance volume_id=vol-1a2b3c4d
|
2013-08-12 05:44:47 +00:00
|
|
|
|
2013-03-05 15:08:59 +00:00
|
|
|
|
2013-02-22 17:11:25 +00:00
|
|
|
EC2 Termination Protection
|
|
|
|
==========================
|
2013-04-02 18:25:45 +00:00
|
|
|
|
2013-09-24 15:58:22 +00:00
|
|
|
EC2 allows the user to enable and disable termination protection on a specific
|
|
|
|
instance. An instance with this protection enabled cannot be destroyed. The EC2
|
2013-07-08 14:39:09 +00:00
|
|
|
driver adds a show_term_protect action to the regular EC2 functionality.
|
2013-02-22 17:11:25 +00:00
|
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
|
|
|
|
salt-cloud -a show_term_protect mymachine
|
|
|
|
salt-cloud -a enable_term_protect mymachine
|
|
|
|
salt-cloud -a disable_term_protect mymachine
|
|
|
|
|
2013-03-07 17:36:14 +00:00
|
|
|
|
|
|
|
Alternate Endpoint
|
|
|
|
==================
|
2013-09-24 15:58:22 +00:00
|
|
|
Normally, EC2 endpoints are build using the region and the service_url. The
|
2013-03-07 17:36:14 +00:00
|
|
|
resulting endpoint would follow this pattern:
|
|
|
|
|
2013-06-21 00:58:36 +00:00
|
|
|
.. code-block:: bash
|
2013-03-07 17:36:14 +00:00
|
|
|
|
|
|
|
ec2.<region>.<service_url>
|
|
|
|
|
2013-04-02 18:25:45 +00:00
|
|
|
|
2013-03-07 17:36:14 +00:00
|
|
|
This results in an endpoint that looks like:
|
|
|
|
|
2013-06-21 00:58:36 +00:00
|
|
|
.. code-block:: bash
|
2013-03-07 17:36:14 +00:00
|
|
|
|
|
|
|
ec2.us-east-1.amazonaws.com
|
|
|
|
|
2013-04-02 18:25:45 +00:00
|
|
|
|
2013-09-24 15:58:22 +00:00
|
|
|
There are other projects that support an EC2 compatibility layer, which this
|
|
|
|
scheme does not account for. This can be overridden by specifying the endpoint
|
2013-03-07 17:36:14 +00:00
|
|
|
directly in the main cloud configuration file:
|
|
|
|
|
2013-04-06 14:08:24 +00:00
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
my-ec2-config:
|
|
|
|
endpoint: myendpoint.example.com:1138/services/Cloud
|
|
|
|
|
|
|
|
|
2013-03-07 22:50:58 +00:00
|
|
|
Volume Management
|
|
|
|
=================
|
|
|
|
The EC2 driver has several functions and actions for management of EBS volumes.
|
|
|
|
|
|
|
|
|
|
|
|
Creating Volumes
|
|
|
|
----------------
|
|
|
|
A volume may be created, independent of an instance. A zone must be specified.
|
2013-09-24 15:58:22 +00:00
|
|
|
A size or a snapshot may be specified (in GiB). If neither is given, a default
|
|
|
|
size of 10 GiB will be used. If a snapshot is given, the size of the snapshot
|
2013-03-07 22:50:58 +00:00
|
|
|
will be used.
|
|
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
|
|
|
|
salt-cloud -f create_volume ec2 zone=us-east-1b
|
|
|
|
salt-cloud -f create_volume ec2 zone=us-east-1b size=10
|
|
|
|
salt-cloud -f create_volume ec2 zone=us-east-1b snapshot=snap12345678
|
2013-08-10 08:41:41 +00:00
|
|
|
salt-cloud -f create_volume ec2 size=10 type=standard
|
|
|
|
salt-cloud -f create_volume ec2 size=10 type=io1 iops=1000
|
2013-03-07 22:50:58 +00:00
|
|
|
|
|
|
|
|
|
|
|
Attaching Volumes
|
|
|
|
-----------------
|
2013-09-24 15:58:22 +00:00
|
|
|
Unattached volumes may be attached to an instance. The following values are
|
2014-12-12 19:32:16 +00:00
|
|
|
required; name or instance_id, volume_id, and device.
|
2013-03-07 22:50:58 +00:00
|
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
|
|
|
|
salt-cloud -a attach_volume myinstance volume_id=vol-12345 device=/dev/sdb1
|
|
|
|
|
|
|
|
|
|
|
|
Show a Volume
|
|
|
|
-------------
|
2013-04-02 18:25:45 +00:00
|
|
|
The details about an existing volume may be retrieved.
|
2013-03-07 22:50:58 +00:00
|
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
|
|
|
|
salt-cloud -a show_volume myinstance volume_id=vol-12345
|
|
|
|
salt-cloud -f show_volume ec2 volume_id=vol-12345
|
|
|
|
|
|
|
|
|
|
|
|
Detaching Volumes
|
|
|
|
-----------------
|
|
|
|
An existing volume may be detached from an instance.
|
|
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
|
|
|
|
salt-cloud -a detach_volume myinstance volume_id=vol-12345
|
|
|
|
|
|
|
|
|
|
|
|
Deleting Volumes
|
|
|
|
----------------
|
|
|
|
A volume that is not attached to an instance may be deleted.
|
|
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
|
|
|
|
salt-cloud -f delete_volume ec2 volume_id=vol-12345
|
|
|
|
|
|
|
|
|
|
|
|
Managing Key Pairs
|
|
|
|
==================
|
|
|
|
The EC2 driver has the ability to manage key pairs.
|
|
|
|
|
|
|
|
|
|
|
|
Creating a Key Pair
|
|
|
|
-------------------
|
2013-09-24 15:58:22 +00:00
|
|
|
A key pair is required in order to create an instance. When creating a key pair
|
2013-03-07 22:50:58 +00:00
|
|
|
with this function, the return data will contain a copy of the private key.
|
2014-01-10 20:43:08 +00:00
|
|
|
This private key is not stored by Amazon, will not be obtainable past this
|
2013-03-07 22:50:58 +00:00
|
|
|
point, and should be stored immediately.
|
|
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
|
|
|
|
salt-cloud -f create_keypair ec2 keyname=mykeypair
|
|
|
|
|
|
|
|
|
|
|
|
Show a Key Pair
|
|
|
|
---------------
|
2013-09-24 15:58:22 +00:00
|
|
|
This function will show the details related to a key pair, not including the
|
2013-03-07 22:50:58 +00:00
|
|
|
private key itself (which is not stored by Amazon).
|
|
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
|
2013-03-26 11:39:53 +00:00
|
|
|
salt-cloud -f show_keypair ec2 keyname=mykeypair
|
2013-03-07 22:50:58 +00:00
|
|
|
|
|
|
|
|
|
|
|
Delete a Key Pair
|
|
|
|
-----------------
|
|
|
|
This function removes the key pair from Amazon.
|
|
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
|
|
|
|
salt-cloud -f delete_keypair ec2 keyname=mykeypair
|
|
|
|
|
2014-06-25 16:50:37 +00:00
|
|
|
Launching instances into a VPC
|
|
|
|
==============================
|
2014-01-10 18:16:51 +00:00
|
|
|
|
2014-06-25 16:50:37 +00:00
|
|
|
Simple launching into a VPC
|
|
|
|
---------------------------
|
|
|
|
|
|
|
|
In the amazon web interface, identify the id of the subnet into which your
|
|
|
|
image should be created. Then, edit your cloud.profiles file like so:-
|
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
profile-id:
|
|
|
|
provider: provider-name
|
|
|
|
subnetid: subnet-XXXXXXXX
|
|
|
|
image: ami-XXXXXXXX
|
|
|
|
size: m1.medium
|
|
|
|
ssh_username: ubuntu
|
|
|
|
securitygroupid:
|
|
|
|
- sg-XXXXXXXX
|
|
|
|
|
|
|
|
Specifying interface properties
|
|
|
|
-------------------------------
|
|
|
|
|
2014-08-27 20:00:30 +00:00
|
|
|
.. versionadded:: 2014.7.0
|
|
|
|
|
2014-06-25 16:50:37 +00:00
|
|
|
Launching into a VPC allows you to specify more complex configurations for
|
|
|
|
the network interfaces of your virtual machines, for example:-
|
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
profile-id:
|
|
|
|
provider: provider-name
|
|
|
|
image: ami-XXXXXXXX
|
|
|
|
size: m1.medium
|
|
|
|
ssh_username: ubuntu
|
|
|
|
|
|
|
|
# Do not include either 'subnetid' or 'securitygroupid' here if you are
|
|
|
|
# going to manually specify interface configuration
|
|
|
|
#
|
|
|
|
network_interfaces:
|
|
|
|
- DeviceIndex: 0
|
|
|
|
SubnetId: subnet-XXXXXXXX
|
|
|
|
SecurityGroupId:
|
|
|
|
- sg-XXXXXXXX
|
2015-03-06 04:10:02 +00:00
|
|
|
|
|
|
|
# Uncomment this line if you would like to set an explicit private
|
|
|
|
# IP address for the ec2 instance
|
|
|
|
#
|
|
|
|
# PrivateIpAddress: 192.168.1.66
|
2014-06-25 16:50:37 +00:00
|
|
|
|
|
|
|
# Uncomment this to associate an existing Elastic IP Address with
|
|
|
|
# this network interface:
|
|
|
|
#
|
|
|
|
# associate_eip: eni-XXXXXXXX
|
|
|
|
|
|
|
|
# You can allocate more than one IP address to an interface. Use the
|
|
|
|
# 'ip addr list' command to see them.
|
|
|
|
#
|
|
|
|
# SecondaryPrivateIpAddressCount: 2
|
|
|
|
|
|
|
|
# Uncomment this to allocate a new Elastic IP Address to this
|
|
|
|
# interface (will be associated with the primary private ip address
|
|
|
|
# of the interface
|
|
|
|
#
|
2014-12-01 20:46:32 +00:00
|
|
|
# allocate_new_eip: True
|
2014-06-25 16:50:37 +00:00
|
|
|
|
|
|
|
# Uncomment this instead to allocate a new Elastic IP Address to
|
|
|
|
# both the primary private ip address and each of the secondary ones
|
|
|
|
#
|
|
|
|
allocate_new_eips: True
|
|
|
|
|
2015-07-08 19:31:36 +00:00
|
|
|
# Uncomment this if you're creating NAT instances. Allows an instance
|
|
|
|
# to accept IP packets with destinations other than itself.
|
|
|
|
# SourceDestCheck: False
|
|
|
|
|
2014-06-25 16:50:37 +00:00
|
|
|
Note that it is an error to assign a 'subnetid' or 'securitygroupid' to a
|
|
|
|
profile where the interfaces are manually configured like this. These are both
|
|
|
|
really properties of each network interface, not of the machine itself.
|