2018-12-17 17:40:09 +00:00
|
|
|
variable "name" {
|
|
|
|
description = "Used to name various infrastructure components"
|
|
|
|
default = "nomad-e2e"
|
|
|
|
}
|
|
|
|
|
|
|
|
variable "region" {
|
|
|
|
description = "The AWS region to deploy to."
|
|
|
|
default = "us-east-1"
|
|
|
|
}
|
|
|
|
|
|
|
|
variable "indexed" {
|
|
|
|
description = "Different configurations per client/server"
|
2019-01-04 15:55:14 +00:00
|
|
|
default = true
|
2018-12-17 17:40:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
variable "instance_type" {
|
|
|
|
description = "The AWS instance type to use for both clients and servers."
|
|
|
|
default = "t2.medium"
|
|
|
|
}
|
|
|
|
|
|
|
|
variable "server_count" {
|
|
|
|
description = "The number of servers to provision."
|
|
|
|
default = "3"
|
|
|
|
}
|
|
|
|
|
|
|
|
variable "client_count" {
|
|
|
|
description = "The number of clients to provision."
|
|
|
|
default = "4"
|
|
|
|
}
|
|
|
|
|
2019-11-19 16:06:10 +00:00
|
|
|
variable "windows_client_count" {
|
|
|
|
description = "The number of windows clients to provision."
|
|
|
|
default = "1"
|
|
|
|
}
|
|
|
|
|
2018-12-17 17:40:09 +00:00
|
|
|
variable "nomad_sha" {
|
|
|
|
description = "The sha of Nomad to run"
|
|
|
|
}
|
|
|
|
|
|
|
|
provider "aws" {
|
2019-10-14 15:27:08 +00:00
|
|
|
region = var.region
|
2018-12-17 17:40:09 +00:00
|
|
|
}
|
|
|
|
|
2019-10-14 15:27:08 +00:00
|
|
|
resource "random_pet" "e2e" {
|
|
|
|
}
|
2018-12-17 17:40:09 +00:00
|
|
|
|
2019-11-19 16:06:10 +00:00
|
|
|
resource "random_password" "windows_admin_password" {
|
|
|
|
length = 20
|
|
|
|
special = true
|
|
|
|
override_special = "_%@"
|
|
|
|
}
|
|
|
|
|
2018-12-17 17:40:09 +00:00
|
|
|
locals {
|
|
|
|
random_name = "${var.name}-${random_pet.e2e.id}"
|
|
|
|
}
|
|
|
|
|
|
|
|
# Generates keys to use for provisioning and access
|
|
|
|
module "keys" {
|
2019-10-14 15:27:08 +00:00
|
|
|
name = local.random_name
|
|
|
|
path = "${path.root}/keys"
|
|
|
|
source = "mitchellh/dynamic-keys/aws"
|
|
|
|
version = "v2.0.0"
|
2018-12-17 17:40:09 +00:00
|
|
|
}
|
|
|
|
|
2019-11-19 16:06:10 +00:00
|
|
|
data "aws_ami" "linux" {
|
2018-12-17 17:40:09 +00:00
|
|
|
most_recent = true
|
|
|
|
owners = ["self"]
|
|
|
|
|
|
|
|
filter {
|
|
|
|
name = "name"
|
|
|
|
values = ["nomad-e2e-*"]
|
|
|
|
}
|
2019-08-30 20:51:13 +00:00
|
|
|
|
|
|
|
filter {
|
|
|
|
name = "tag:OS"
|
|
|
|
values = ["Ubuntu"]
|
|
|
|
}
|
2018-12-17 17:40:09 +00:00
|
|
|
}
|
|
|
|
|
2019-11-19 16:06:10 +00:00
|
|
|
data "aws_ami" "windows" {
|
|
|
|
most_recent = true
|
|
|
|
owners = ["self"]
|
|
|
|
|
|
|
|
filter {
|
|
|
|
name = "name"
|
|
|
|
values = ["nomad-e2e-windows-2016*"]
|
|
|
|
}
|
|
|
|
|
|
|
|
filter {
|
|
|
|
name = "tag:OS"
|
|
|
|
values = ["Windows2016"]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-10-14 15:27:08 +00:00
|
|
|
data "aws_caller_identity" "current" {
|
|
|
|
}
|
2019-09-06 19:49:18 +00:00
|
|
|
|
2018-12-17 17:40:09 +00:00
|
|
|
output "servers" {
|
2019-10-14 15:27:08 +00:00
|
|
|
value = aws_instance.server.*.public_ip
|
2018-12-17 17:40:09 +00:00
|
|
|
}
|
|
|
|
|
2019-11-25 18:31:00 +00:00
|
|
|
output "linux_clients" {
|
|
|
|
value = aws_instance.client_linux.*.public_ip
|
|
|
|
}
|
|
|
|
|
|
|
|
output "windows_clients" {
|
|
|
|
value = aws_instance.client_windows.*.public_ip
|
2018-12-17 17:40:09 +00:00
|
|
|
}
|
|
|
|
|
2019-01-04 15:55:14 +00:00
|
|
|
output "message" {
|
|
|
|
value = <<EOM
|
|
|
|
Your cluster has been provisioned! - To prepare your environment, run the
|
|
|
|
following:
|
|
|
|
|
|
|
|
```
|
2019-11-25 18:31:00 +00:00
|
|
|
export NOMAD_ADDR=http://${aws_instance.server[0].public_ip}:4646
|
|
|
|
export CONSUL_HTTP_ADDR=http://${aws_instance.server[0].public_ip}:8500
|
2019-01-04 15:55:14 +00:00
|
|
|
export NOMAD_E2E=1
|
|
|
|
```
|
|
|
|
|
|
|
|
Then you can run e2e tests with:
|
|
|
|
|
|
|
|
```
|
|
|
|
go test -v ./e2e
|
|
|
|
```
|
2019-05-03 14:54:34 +00:00
|
|
|
|
|
|
|
ssh into nodes with:
|
|
|
|
```
|
2019-11-25 18:31:00 +00:00
|
|
|
ssh -i keys/${local.random_name}.pem ubuntu@${aws_instance.client_linux[0].public_ip}
|
2019-05-03 14:54:34 +00:00
|
|
|
```
|
2019-01-04 15:55:14 +00:00
|
|
|
EOM
|
2019-10-14 15:27:08 +00:00
|
|
|
|
2019-01-04 15:55:14 +00:00
|
|
|
}
|