<a id="cloud-ec2"></a>

# The Amazon EC2 cloud and Juju

<!--To see the older HTG-style doc, see version 35. Note that it may be out-of-date. -->

This document describes details specific to using your existing Amazon EC2 cloud with Juju.

> See more: [Amazon EC2](https://docs.aws.amazon.com/ec2/?icmpid=docs_homepage_featuredsvcs)

When using this cloud with Juju, it is important to keep in mind that it is a (1) machine cloud and (2) not some other cloud.

> See more: [Cloud differences](https://documentation.ubuntu.com/juju/2.9/reference/cloud.md#cloud-differences)

As the differences related to (1) are already documented generically in the rest of the docs, here we record just those that follow from (2).

## Notes on `juju add-cloud`

Type in Juju: `ec2`

Name in Juju: `aws`

## Notes on `juju add-credential`

### Authentication types

#### instance-role

Attributes:

- instance-profile-name: The AWS Instance Profile name (required)

#### access-key

Attributes:

- access-key: The EC2 access key (required)
- secret-key: The EC2 secret key (required)

## Notes on `juju bootstrap`

You can authenticate the controller with the cloud using instance profiles: Use the cloud CLI to create an instance profile, then pass the instance profile to the controller during bootstrap via the `instance-role` constraint: `juju bootstrap --bootstrap-constraints="instance-role=<my instance profile>"`.  See more: `instance-role` below or [Discourse | Using AWS instance profiles with Juju](https://discourse.charmhub.io/t/5185).

## Cloud-specific model configuration keys

### vpc-id-force

Force Juju to use the AWS VPC ID specified with vpc-id, when it fails the minimum validation criteria. Not accepted without vpc-id

|               |       |
|---------------|-------|
| type          | bool  |
| default value | false |
| immutable     | true  |
| mandatory     | false |

### vpc-id

Use a specific AWS VPC ID (optional). When not specified, Juju requires a default VPC or EC2-Classic features to be available for the account/region.

Example: vpc-a1b2c3d4

|               |        |
|---------------|--------|
| type          | string |
| default value | “”     |
| immutable     | true   |
| mandatory     | false  |

## Supported constraints

| [CONSTRAINT](https://documentation.ubuntu.com/juju/2.9/reference/constraint.md#constraint)                              |                                                                                                                                                            |
|---------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------|
| conflicting:                                                                                      | `instance-type` vs. `[cores, cpu-power, mem]`                                                                                                              |
| supported?                                                                                        |                                                                                                                                                            |
| - [allocate-public-ip](https://documentation.ubuntu.com/juju/2.9/reference/constraint.md#constraint-allocate-public-ip) | ✓                                                                                                                                                          |
| - [arch](https://documentation.ubuntu.com/juju/2.9/reference/constraint.md#constraint-arch)                             | ✓                                                                                                                                                          |
| - [container](https://documentation.ubuntu.com/juju/2.9/reference/constraint.md#constraint-container)                   | ✓                                                                                                                                                          |
| - [cores](https://documentation.ubuntu.com/juju/2.9/reference/constraint.md#constraint-cores)                           | ✓                                                                                                                                                          |
| - [cpu-power](https://documentation.ubuntu.com/juju/2.9/reference/constraint.md#constraint-cpu-power)                   | ✓                                                                                                                                                          |
| - [image-id](https://documentation.ubuntu.com/juju/2.9/reference/constraint.md#constraint-image-id)                     | ✓  (Starting with Juju 3.3) <br> Type: String. <br> Valid values: An AMI.                                                                                  |
| - [instance-role](https://documentation.ubuntu.com/juju/2.9/reference/constraint.md#constraint-instance-role)           | ✓  <br> Value: `auto` or an [instance profile](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_use_switch-role-ec2_instance-profiles.html) name. |
| - [instance-type](https://documentation.ubuntu.com/juju/2.9/reference/constraint.md#constraint-instance-type)           | ✓  <br> Valid values: See cloud provider. <br> Default value: `m3.medium`.                                                                                 |
| - [mem](https://documentation.ubuntu.com/juju/2.9/reference/constraint.md#constraint-mem)                               | ✓                                                                                                                                                          |
| - [root-disk](https://documentation.ubuntu.com/juju/2.9/reference/constraint.md#constraint-root-disk)                   | ✓                                                                                                                                                          |
| - [root-disk-source](https://documentation.ubuntu.com/juju/2.9/reference/constraint.md#constraint-root-disk-source)     | ✓                                                                                                                                                          |
| - [spaces](https://documentation.ubuntu.com/juju/2.9/reference/constraint.md#constraint-spaces)                         | ✓                                                                                                                                                          |
| - [tags](https://documentation.ubuntu.com/juju/2.9/reference/constraint.md#constraint-tags)                             | ✕                                                                                                                                                          |
| - [virt-type](https://documentation.ubuntu.com/juju/2.9/reference/constraint.md#constraint-virt-type)                   | ✕                                                                                                                                                          |
| - [zones](https://documentation.ubuntu.com/juju/2.9/reference/constraint.md#constraint-zones)                           | ✓                                                                                                                                                          |

## Supported placement directives

| [PLACEMENT DIRECTIVE](https://documentation.ubuntu.com/juju/2.9/reference/placement-directive.md#placement-directive)             |                                                                                                                                                                                                                 |
|----------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [<machine>](https://documentation.ubuntu.com/juju/2.9/reference/placement-directive.md#placement-directive-machine)               | ✓                                                                                                                                                                                                               |
| [subnet=<subnet>](https://documentation.ubuntu.com/juju/2.9/reference/placement-directive.md#placement-directive-subnet)          | ✓                                                                                                                                                                                                               |
| [system-id=<system ID>](https://documentation.ubuntu.com/juju/2.9/reference/placement-directive.md#placement-directive-system-id) | ✕                                                                                                                                                                                                               |
| [zone=<zone>](https://documentation.ubuntu.com/juju/2.9/reference/placement-directive.md#placement-directive-zone)                | ✓  <br> If the query looks like a CIDR, then this will match subnets with the same CIDR. If it follows the syntax of a “subnet-XXXX”, this will match the Subnet ID. Everything else is just matched as a Name. |
