github.com/iqoqo/nomad@v0.11.3-0.20200911112621-d7021c74d101/e2e/terraform/main.tf (about) 1 variable "name" { 2 description = "Used to name various infrastructure components" 3 default = "nomad-e2e" 4 } 5 6 variable "region" { 7 description = "The AWS region to deploy to." 8 default = "us-east-1" 9 } 10 11 variable "availability_zone" { 12 description = "The AWS availability zone to deploy to." 13 default = "us-east-1a" 14 } 15 16 variable "indexed" { 17 description = "Different configurations per client/server" 18 default = true 19 } 20 21 variable "instance_type" { 22 description = "The AWS instance type to use for both clients and servers." 23 default = "t2.medium" 24 } 25 26 variable "server_count" { 27 description = "The number of servers to provision." 28 default = "3" 29 } 30 31 variable "client_count" { 32 description = "The number of clients to provision." 33 default = "4" 34 } 35 36 variable "windows_client_count" { 37 description = "The number of windows clients to provision." 38 default = "1" 39 } 40 41 variable "nomad_sha" { 42 description = "The sha of Nomad to write to provisioning output" 43 default = "" 44 } 45 46 provider "aws" { 47 region = var.region 48 } 49 50 resource "random_pet" "e2e" { 51 } 52 53 resource "random_password" "windows_admin_password" { 54 length = 20 55 special = true 56 override_special = "_%@" 57 } 58 59 locals { 60 random_name = "${var.name}-${random_pet.e2e.id}" 61 } 62 63 # Generates keys to use for provisioning and access 64 module "keys" { 65 name = local.random_name 66 path = "${path.root}/keys" 67 source = "mitchellh/dynamic-keys/aws" 68 version = "v2.0.0" 69 } 70 71 data "aws_ami" "linux" { 72 most_recent = true 73 owners = ["self"] 74 75 filter { 76 name = "name" 77 values = ["nomad-e2e-*"] 78 } 79 80 filter { 81 name = "tag:OS" 82 values = ["Ubuntu"] 83 } 84 } 85 86 data "aws_ami" "windows" { 87 most_recent = true 88 owners = ["self"] 89 90 filter { 91 name = "name" 92 values = ["nomad-e2e-windows-2016*"] 93 } 94 95 filter { 96 name = "tag:OS" 97 values = ["Windows2016"] 98 } 99 } 100 101 data "aws_caller_identity" "current" { 102 } 103 104 output "servers" { 105 value = aws_instance.server.*.public_ip 106 } 107 108 output "linux_clients" { 109 value = aws_instance.client_linux.*.public_ip 110 } 111 112 output "windows_clients" { 113 value = aws_instance.client_windows.*.public_ip 114 } 115 116 output "message" { 117 value = <<EOM 118 Your cluster has been provisioned! - To prepare your environment, run the 119 following: 120 121 ``` 122 export NOMAD_ADDR=http://${aws_instance.server[0].public_ip}:4646 123 export CONSUL_HTTP_ADDR=http://${aws_instance.server[0].public_ip}:8500 124 export NOMAD_E2E=1 125 ``` 126 127 Then you can run e2e tests with: 128 129 ``` 130 go test -v ./e2e 131 ``` 132 133 ssh into nodes with: 134 ``` 135 # server 136 ssh -i keys/${local.random_name}.pem ubuntu@${aws_instance.server[0].public_ip} 137 138 # clients 139 %{ for ip in aws_instance.client_linux.*.public_ip ~} 140 ssh -i keys/${local.random_name}.pem ubuntu@${ip} 141 %{ endfor ~} 142 ``` 143 EOM 144 145 }