github.com/bigcommerce/nomad@v0.9.3-bc/terraform/aws/README.md (about)

     1  # Provision a Nomad cluster on AWS
     2  
     3  ## Pre-requisites
     4  
     5  To get started, create the following:
     6  
     7  - AWS account
     8  - [API access keys](http://aws.amazon.com/developers/access-keys/)
     9  - [SSH key pair](http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-key-pairs.html)
    10  
    11  ## Set the AWS environment variables
    12  
    13  ```bash
    14  $ export AWS_ACCESS_KEY_ID=[AWS_ACCESS_KEY_ID]
    15  $ export AWS_SECRET_ACCESS_KEY=[AWS_SECRET_ACCESS_KEY]
    16  ```
    17  
    18  ## Build an AWS machine image with Packer
    19  
    20  [Packer](https://www.packer.io/intro/index.html) is HashiCorp's open source tool 
    21  for creating identical machine images for multiple platforms from a single 
    22  source configuration. The Terraform templates included in this repo reference a 
    23  publicly available Amazon machine image (AMI) by default. The AMI can be customized 
    24  through modifications to the [build configuration script](../shared/scripts/setup.sh) 
    25  and [packer.json](packer.json).
    26  
    27  Use the following command to build the AMI:
    28  
    29  ```bash
    30  $ packer build packer.json
    31  ```
    32  
    33  ## Provision a cluster with Terraform
    34  
    35  `cd` to an environment subdirectory:
    36  
    37  ```bash
    38  $ cd env/us-east
    39  ```
    40  
    41  Update `terraform.tfvars` with your SSH key name and your AMI ID if you created 
    42  a custom AMI:
    43  
    44  ```bash
    45  region                  = "us-east-1"
    46  ami                     = "ami-066a7f2ffac02f833"
    47  instance_type           = "t2.medium"
    48  key_name                = "KEY_NAME"
    49  server_count            = "3"
    50  client_count            = "4"
    51  ```
    52  
    53  Modify the `region`, `instance_type`, `server_count`, and `client_count` variables
    54  as appropriate. At least one client and one server are required. You can 
    55  optionally replace the Nomad binary at runtime by adding the `nomad_binary` 
    56  variable like so:
    57  
    58  ```bash
    59  region                  = "us-east-1"
    60  ami                     = "ami-066a7f2ffac02f833"
    61  instance_type           = "t2.medium"
    62  key_name                = "KEY_NAME"
    63  server_count            = "3"
    64  client_count            = "4"
    65  nomad_binary            = "https://releases.hashicorp.com/nomad/0.7.0/nomad_0.7.0_linux_amd64.zip"
    66  ```
    67  
    68  Provision the cluster:
    69  
    70  ```bash
    71  $ terraform init
    72  $ terraform get
    73  $ terraform plan
    74  $ terraform apply
    75  ```
    76  
    77  ## Access the cluster
    78  
    79  SSH to one of the servers using its public IP:
    80  
    81  ```bash
    82  $ ssh -i /path/to/private/key ubuntu@PUBLIC_IP
    83  ```
    84  
    85  The infrastructure that is provisioned for this test environment is configured to 
    86  allow all traffic over port 22. This is obviously not recommended for production 
    87  deployments.
    88  
    89  ## Next Steps
    90  
    91  Click [here](../README.md#test) for next steps.