2021-09-29 15:33:03 -07:00
|
|
|
# AWS Host Plugin for HashiCorp Boundary
|
|
|
|
|
|
|
|
|
|
This repo contains a Host-type plugin for [HashiCorp
|
|
|
|
|
Boundary](https://www.boundaryproject.io/) allowing dynamically sourcing hosts
|
|
|
|
|
from Amazon EC2.
|
|
|
|
|
|
|
|
|
|
Host sets created with this plugin define filters which select and group like
|
|
|
|
|
instances within AWS; these host sets can in turn be added to targets within
|
|
|
|
|
Boundary as host sources.
|
|
|
|
|
|
|
|
|
|
At creation or update of a host catalog of this type, configuration of the
|
|
|
|
|
plugin is performed via the attribute/secret values passed to the create or
|
|
|
|
|
update calls actions. These values are input as JSON objects; the expected types
|
|
|
|
|
are indicated below with the valid fields.
|
|
|
|
|
|
2021-09-30 09:35:19 -07:00
|
|
|
The plugin fetches hosts through the
|
|
|
|
|
[DescribeInstances](https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeInstances.html)
|
|
|
|
|
call.
|
|
|
|
|
|
|
|
|
|
## Credential Rotation
|
|
|
|
|
|
|
|
|
|
Although credentials are stored encrypted within Boundary, by default this
|
|
|
|
|
plugin will attempt to rotate credentials when they are supplied through the
|
|
|
|
|
`secrets` object on a create or update call to the host catalog resource. The
|
|
|
|
|
given credentials will be used to create a new credential, and then the given
|
|
|
|
|
credential will be revoked. In this way, after rotation, only Boundary knows the
|
|
|
|
|
client secret in use by this plugin.
|
|
|
|
|
|
2022-01-04 15:06:59 -08:00
|
|
|
## Getting Started
|
|
|
|
|
|
2022-01-04 15:56:09 -08:00
|
|
|
Refer to [Attributes and Secrets](#attributes-and-secrets) for more detail on
|
|
|
|
|
configuration options for host catalogs and sets.
|
|
|
|
|
|
2022-01-04 15:06:59 -08:00
|
|
|
To create a host catalog (using default scope created by `boundary dev`):
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
boundary host-catalogs create plugin \
|
|
|
|
|
-scope-id p_1234567890 \
|
|
|
|
|
-name "Example Plugin-Based Host Catalog" \
|
|
|
|
|
-description "Description for plugin-based host catalog" \
|
|
|
|
|
-plugin-name aws \
|
|
|
|
|
-attr region=REGION \
|
|
|
|
|
-secret access_key_id='KEY' \
|
|
|
|
|
-secret secret_access_key='SECRET'
|
|
|
|
|
```
|
|
|
|
|
|
2022-01-04 15:56:09 -08:00
|
|
|
To create a host set, filtering the host set based on tag keys `foo` or `bar`
|
|
|
|
|
(either tag can be present), ensuring that any targets set to this host set only
|
|
|
|
|
connect to external addresses in the `54.0.0.0/8` class A subnet:
|
2022-01-04 15:06:59 -08:00
|
|
|
|
|
|
|
|
```
|
|
|
|
|
boundary host-sets create plugin \
|
|
|
|
|
-host-catalog-id HOST_CATALOG_ID \
|
|
|
|
|
-name "Example Plugin-Based Host Set" \
|
|
|
|
|
-description "Description for plugin-based host set" \
|
|
|
|
|
-attr filters=tag-key=foo,bar \
|
|
|
|
|
-preferred-endpoint "cidr:54.0.0.0/8"
|
|
|
|
|
```
|
|
|
|
|
|
2022-01-04 15:56:09 -08:00
|
|
|
As above, but instances must have both tags (both `foo` and `bar` *must* be
|
|
|
|
|
present):
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
boundary host-sets create plugin \
|
|
|
|
|
-host-catalog-id HOST_CATALOG_ID \
|
|
|
|
|
-name "Example Plugin-Based Host Set" \
|
|
|
|
|
-description "Description for plugin-based host set" \
|
|
|
|
|
-attr filters=tag-key=foo \
|
|
|
|
|
-attr filters=tag-key=bar \
|
|
|
|
|
-preferred-endpoint "cidr:54.0.0.0/8"
|
|
|
|
|
```
|
|
|
|
|
|
2022-03-09 12:16:50 -07:00
|
|
|
As above, but matching on tag key named "development" with value "prod" or "dev"
|
|
|
|
|
and launch date:
|
2022-01-04 15:56:09 -08:00
|
|
|
|
|
|
|
|
```
|
|
|
|
|
boundary host-sets create plugin \
|
|
|
|
|
-host-catalog-id HOST_CATALOG_ID \
|
|
|
|
|
-name "Example Plugin-Based Host Set" \
|
|
|
|
|
-description "Description for plugin-based host set" \
|
2022-03-09 12:16:50 -07:00
|
|
|
-attr filters=tag:development=prod,dev \
|
2022-01-04 15:56:09 -08:00
|
|
|
-attr filters=launch-time=2022-01-04T* \
|
|
|
|
|
-preferred-endpoint "cidr:54.0.0.0/8"
|
|
|
|
|
```
|
|
|
|
|
|
2021-09-30 09:35:19 -07:00
|
|
|
## Required IAM Privileges
|
|
|
|
|
|
2021-09-30 09:43:21 -07:00
|
|
|
The following IAM privileges, at the very least, are required to be attached to
|
|
|
|
|
a configured IAM user for this provider:
|
2021-09-30 09:35:19 -07:00
|
|
|
|
|
|
|
|
* `ec2:DescribeInstances`, configured to `*` (`DescribeInstances` cannot be
|
|
|
|
|
scoped to a resource ARN). Example policy:
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
{
|
|
|
|
|
"Version": "2012-10-17",
|
|
|
|
|
"Statement": [
|
|
|
|
|
{
|
|
|
|
|
"Action": [
|
|
|
|
|
"ec2:DescribeInstances"
|
|
|
|
|
],
|
|
|
|
|
"Effect": "Allow",
|
|
|
|
|
"Resource": "*"
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
* `iam:GetUser`, `iam:CreateAccessKey`, and `iam:DeleteAccessKey`, configured to
|
2021-09-30 09:40:55 -07:00
|
|
|
the IAM user to allow credential rotation. Example policy:
|
2021-09-30 09:35:19 -07:00
|
|
|
|
|
|
|
|
```
|
|
|
|
|
{
|
|
|
|
|
"Version": "2012-10-17",
|
|
|
|
|
"Statement": [
|
|
|
|
|
{
|
|
|
|
|
"Action": [
|
|
|
|
|
"iam:DeleteAccessKey",
|
|
|
|
|
"iam:GetUser",
|
|
|
|
|
"iam:CreateAccessKey"
|
|
|
|
|
],
|
|
|
|
|
"Effect": "Allow",
|
|
|
|
|
"Resource": "arn:aws:iam::123456789012:user/JohnDoe"
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## Attributes and Secrets
|
|
|
|
|
|
|
|
|
|
### Host Catalog
|
|
|
|
|
|
2021-09-30 09:40:55 -07:00
|
|
|
The following `attributes` are valid on an AWS host catalog resource:
|
2021-09-30 09:35:19 -07:00
|
|
|
|
|
|
|
|
- `disable_credential_rotation` (bool): If `true`, credential rotation will not
|
2021-09-30 09:40:55 -07:00
|
|
|
be performed. See the [Credential Rotation](#credential-rotation) section
|
|
|
|
|
above.
|
2021-09-30 09:35:19 -07:00
|
|
|
- `region` (string): The region to configure the host catalog for. All host sets
|
|
|
|
|
in this catalog will be configured for this region.
|
|
|
|
|
|
2021-09-30 09:40:55 -07:00
|
|
|
The following `secrets` are valid on an AWS host catalog resource:
|
2021-09-30 09:35:19 -07:00
|
|
|
|
|
|
|
|
- `access_key_id` (string): The access key ID for the IAM user to use with this
|
|
|
|
|
host catalog.
|
|
|
|
|
- `secret_access_key` (string): The secret access key for the IAM user to use
|
|
|
|
|
with this host catalog.
|
|
|
|
|
|
|
|
|
|
### Host Set
|
|
|
|
|
|
2021-09-30 09:40:55 -07:00
|
|
|
The following attributes are valid on an AWS host Set resource:
|
2021-09-30 09:35:19 -07:00
|
|
|
|
2021-11-03 21:21:27 -04:00
|
|
|
- `filters` (array of strings): An array of string filters in the format
|
|
|
|
|
`key=val1,val2`. The key corresponds to a filter option, and the value(s) are
|
|
|
|
|
a comma-separated list. For a list of filter options, check out
|
|
|
|
|
[describe-instances in the AWS CLI
|
2021-09-30 09:35:19 -07:00
|
|
|
reference](https://docs.aws.amazon.com/cli/latest/reference/ec2/describe-instances.html).
|