github.com/hspak/nomad@v0.7.2-0.20180309000617-bc4ae22a39a5/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 avaialble 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-d42d74ae"
    47  instance_type           = "t2.medium"
    48  key_name                = "KEY_NAME"
    49  server_count            = "3"
    50  client_count            = "4"
    51  ```
    52  
    53  You can also modify the `region`, `instance_type`, `server_count`, and `client_count`. 
    54  At least one client and one server are required.
    55  
    56  Provision the cluster:
    57  
    58  ```bash
    59  $ terraform init
    60  $ terraform get
    61  $ terraform plan
    62  $ terraform apply
    63  ```
    64  
    65  ## Access the cluster
    66  
    67  SSH to one of the servers using its public IP:
    68  
    69  ```bash
    70  $ ssh -i /path/to/private/key ubuntu@PUBLIC_IP
    71  ```
    72  
    73  The infrastructure that is provisioned for this test environment is configured to 
    74  allow all traffic over port 22. This is obviously not recommended for production 
    75  deployments.
    76  
    77  ## Next Steps
    78  
    79  Click [here](../README.md#test) for next steps.