2020-01-22 21:55:17 +00:00
|
|
|
# Terraform infrastructure
|
2018-12-18 19:37:03 +00:00
|
|
|
|
2020-01-22 21:55:17 +00:00
|
|
|
This folder contains terraform resources for provisioning EC2 instances on AWS
|
|
|
|
to use as the target of end-to-end tests.
|
2018-12-18 19:37:03 +00:00
|
|
|
|
2020-01-22 21:55:17 +00:00
|
|
|
Terraform provisions the AWS infrastructure only, whereas the Nomad
|
|
|
|
cluster is deployed to that infrastructure by the e2e
|
|
|
|
framework. Terraform's output will include a `provisioning` stanza
|
|
|
|
that can be written to a JSON file used by the e2e framework's
|
|
|
|
provisioning step.
|
2019-01-03 18:12:43 +00:00
|
|
|
|
2020-01-22 21:55:17 +00:00
|
|
|
You can use Terraform to output the provisioning parameter JSON file the e2e
|
2020-02-04 15:37:00 +00:00
|
|
|
framework uses.
|
2019-01-03 18:12:43 +00:00
|
|
|
|
2020-01-22 21:55:17 +00:00
|
|
|
## Setup
|
|
|
|
|
2020-09-17 13:20:18 +00:00
|
|
|
You'll need Terraform 0.13+, as well as AWS credentials to create the Nomad
|
|
|
|
cluster. This Terraform stack assumes that an appropriate instance role has
|
|
|
|
been configured elsewhere and that you have the ability to `AssumeRole` into
|
|
|
|
the AWS account.
|
2020-01-22 21:55:17 +00:00
|
|
|
|
|
|
|
Optionally, edit the `terraform.tfvars` file to change the number of
|
2020-02-04 15:37:00 +00:00
|
|
|
Linux clients or Windows clients.
|
2020-01-22 21:55:17 +00:00
|
|
|
|
|
|
|
```hcl
|
|
|
|
region = "us-east-1"
|
|
|
|
instance_type = "t2.medium"
|
|
|
|
server_count = "3"
|
|
|
|
client_count = "4"
|
|
|
|
windows_client_count = "1"
|
2018-12-18 19:37:03 +00:00
|
|
|
```
|
2020-01-22 21:55:17 +00:00
|
|
|
|
|
|
|
Run Terraform apply to deploy the infrastructure:
|
|
|
|
|
|
|
|
```sh
|
|
|
|
cd e2e/terraform/
|
2020-09-17 13:20:18 +00:00
|
|
|
terraform apply
|
2018-12-18 19:37:03 +00:00
|
|
|
```
|
|
|
|
|
2020-01-22 21:55:17 +00:00
|
|
|
## Outputs
|
|
|
|
|
|
|
|
After deploying the infrastructure, you can get connection information
|
|
|
|
about the cluster:
|
|
|
|
|
|
|
|
- `$(terraform output environment)` will set your current shell's
|
|
|
|
`NOMAD_ADDR` and `CONSUL_HTTP_ADDR` to point to one of the cluster's
|
|
|
|
server nodes, and set the `NOMAD_E2E` variable.
|
|
|
|
- `terraform output servers` will output the list of server node IPs.
|
|
|
|
- `terraform output linux_clients` will output the list of Linux
|
|
|
|
client node IPs.
|
|
|
|
- `terraform output windows_clients` will output the list of Windows
|
|
|
|
client node IPs.
|
|
|
|
- `terraform output provisioning | jq .` will output the JSON used by
|
|
|
|
the e2e framework for provisioning.
|
2019-01-03 21:31:19 +00:00
|
|
|
|
2019-05-03 14:54:34 +00:00
|
|
|
## SSH
|
|
|
|
|
2020-01-22 21:55:17 +00:00
|
|
|
You can use Terraform outputs above to access nodes via ssh:
|
2019-05-03 14:54:34 +00:00
|
|
|
|
2020-01-22 21:55:17 +00:00
|
|
|
```sh
|
2019-05-03 14:54:34 +00:00
|
|
|
ssh -i keys/nomad-e2e-*.pem ubuntu@${EC2_IP_ADDR}
|
|
|
|
```
|
|
|
|
|
2020-01-22 21:55:17 +00:00
|
|
|
The Windows client runs OpenSSH for convenience, but has a different
|
|
|
|
user and will drop you into a Powershell shell instead of bash:
|
2019-11-19 16:06:10 +00:00
|
|
|
|
2020-01-22 21:55:17 +00:00
|
|
|
```sh
|
2019-11-19 16:06:10 +00:00
|
|
|
ssh -i keys/nomad-e2e-*.pem Administrator@${EC2_IP_ADDR}
|
|
|
|
```
|
|
|
|
|
2019-05-03 14:54:34 +00:00
|
|
|
## Teardown
|
2019-01-03 21:31:19 +00:00
|
|
|
|
2020-02-04 15:37:00 +00:00
|
|
|
The terraform state file stores all the info.
|
2020-01-22 21:55:17 +00:00
|
|
|
|
|
|
|
```sh
|
|
|
|
cd e2e/terraform/
|
2020-09-17 13:20:18 +00:00
|
|
|
terraform destroy
|
2019-01-03 21:31:19 +00:00
|
|
|
```
|