github.com/iqoqo/nomad@v0.11.3-0.20200911112621-d7021c74d101/e2e/terraform/README.md (about) 1 # Terraform infrastructure 2 3 This folder contains terraform resources for provisioning EC2 instances on AWS 4 to use as the target of end-to-end tests. 5 6 Terraform provisions the AWS infrastructure only, whereas the Nomad 7 cluster is deployed to that infrastructure by the e2e 8 framework. Terraform's output will include a `provisioning` stanza 9 that can be written to a JSON file used by the e2e framework's 10 provisioning step. 11 12 You can use Terraform to output the provisioning parameter JSON file the e2e 13 framework uses. 14 15 ## Setup 16 17 You'll need Terraform 0.12+, as well as AWS credentials (`AWS_ACCESS_KEY_ID` 18 and `AWS_SECRET_ACCESS_KEY`) to create the Nomad cluster. Use 19 [envchain](https://github.com/sorah/envchain) to store your AWS credentials. 20 21 Optionally, edit the `terraform.tfvars` file to change the number of 22 Linux clients or Windows clients. 23 24 ```hcl 25 region = "us-east-1" 26 instance_type = "t2.medium" 27 server_count = "3" 28 client_count = "4" 29 windows_client_count = "1" 30 ``` 31 32 Run Terraform apply to deploy the infrastructure: 33 34 ```sh 35 cd e2e/terraform/ 36 envchain nomadaws terraform apply 37 ``` 38 39 ## Outputs 40 41 After deploying the infrastructure, you can get connection information 42 about the cluster: 43 44 - `$(terraform output environment)` will set your current shell's 45 `NOMAD_ADDR` and `CONSUL_HTTP_ADDR` to point to one of the cluster's 46 server nodes, and set the `NOMAD_E2E` variable. 47 - `terraform output servers` will output the list of server node IPs. 48 - `terraform output linux_clients` will output the list of Linux 49 client node IPs. 50 - `terraform output windows_clients` will output the list of Windows 51 client node IPs. 52 - `terraform output provisioning | jq .` will output the JSON used by 53 the e2e framework for provisioning. 54 55 ## SSH 56 57 You can use Terraform outputs above to access nodes via ssh: 58 59 ```sh 60 ssh -i keys/nomad-e2e-*.pem ubuntu@${EC2_IP_ADDR} 61 ``` 62 63 The Windows client runs OpenSSH for convenience, but has a different 64 user and will drop you into a Powershell shell instead of bash: 65 66 ```sh 67 ssh -i keys/nomad-e2e-*.pem Administrator@${EC2_IP_ADDR} 68 ``` 69 70 ## Teardown 71 72 The terraform state file stores all the info. 73 74 ```sh 75 cd e2e/terraform/ 76 envchain nomadaws terraform destroy 77 ```