github.com/bigcommerce/nomad@v0.9.3-bc/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 "indexed" {
    12    description = "Different configurations per client/server"
    13    default     = true
    14  }
    15  
    16  variable "instance_type" {
    17    description = "The AWS instance type to use for both clients and servers."
    18    default     = "t2.medium"
    19  }
    20  
    21  variable "server_count" {
    22    description = "The number of servers to provision."
    23    default     = "3"
    24  }
    25  
    26  variable "client_count" {
    27    description = "The number of clients to provision."
    28    default     = "4"
    29  }
    30  
    31  variable "retry_join" {
    32    description = "Used by Consul to automatically form a cluster."
    33    default     = "provider=aws tag_key=ConsulAutoJoin tag_value=auto-join"
    34  }
    35  
    36  variable "nomad_sha" {
    37    description = "The sha of Nomad to run"
    38  }
    39  
    40  provider "aws" {
    41    region = "${var.region}"
    42  }
    43  
    44  resource "random_pet" "e2e" {}
    45  
    46  locals {
    47    random_name = "${var.name}-${random_pet.e2e.id}"
    48  }
    49  
    50  # Generates keys to use for provisioning and access
    51  module "keys" {
    52    name   = "${local.random_name}"
    53    path   = "${path.root}/keys"
    54    source = "mitchellh/dynamic-keys/aws"
    55  }
    56  
    57  data "aws_ami" "main" {
    58    most_recent = true
    59    owners      = ["self"]
    60  
    61    filter {
    62      name   = "name"
    63      values = ["nomad-e2e-*"]
    64    }
    65  }
    66  
    67  output "servers" {
    68    value = "${aws_instance.server.*.public_ip}"
    69  }
    70  
    71  output "clients" {
    72    value = "${aws_instance.client.*.public_ip}"
    73  }
    74  
    75  output "message" {
    76    value = <<EOM
    77  Your cluster has been provisioned! - To prepare your environment, run the
    78  following:
    79  
    80  ```
    81  export NOMAD_ADDR=http://${aws_instance.client.0.public_ip}:4646
    82  export CONSUL_HTTP_ADDR=http://${aws_instance.client.0.public_ip}:8500
    83  export NOMAD_E2E=1
    84  ```
    85  
    86  Then you can run e2e tests with:
    87  
    88  ```
    89  go test -v ./e2e
    90  ```
    91  
    92  ssh into nodes with:
    93  ```
    94  ssh -i keys/${local.random_name}.pem ubuntu@${aws_instance.client.0.public_ip}
    95  ```
    96  EOM
    97  }