Setup a Cluster

Cluster on AWS

In this section we show you how to use the aws terraform module to setup your own infrastructure on Amazon AWS provider.

Setup Project

You can use our aws template to create a repository. Click on the Use this template link on the repo.

use module template

Name the module and simply clone the repository down.

Let’s begin by cloning our repository we created using the template.

git clone [email protected]:<your-organization>/<your-repo>.git

Cluster Bootstrap

Once you’ve cloned down the repository simply replace the cluster_name with the desired name for your cluster. You can also update the node_size and the size parameter in the cluster_topology based on the value you wish to use from aws ec2 instance sizes.

Once you’ve updated the values create a .auto.tfvars and add your tokens.

aws_access_key = <your aws access key>
aws_secret_key = <your aws secret key>
instellar_auth_token = <your instellar auth token>

You can get the instellar_auth_token by signing up and heading over to the Credentials page on instellar.

SSH Key

This section assumes you already know how to generate the ssh-key. If you don’t know how to do this I recommend this post. To add the ssh-key to Amazon AWS. Head to the EC2 Dashboard and look for the Key Pairs link.

key pairs

Click the Import key pair button.

create key pair

You can import the key pair by copying your public key and paste it in the box.

import key pair

Once you’ve added your public key you can copy the name and use it in your main.tf.

AWS Access and Secret Key

Let’s look at how we can retrieve the Access Key and Secret Key to be used with the terraform module.

Head over to the IAM section

iam section

Click the Add users button.

add users

Give the user a name and simply click Next.

create user form

You’ll need to attach the AdministratorAccess role to the user, and click Next.

attach policy

Review all the details and once you’re ready click Create user.

create user

Once you created the user go to the user detail, and click on the Security credentials page.

user detail

Find the Access keys section and click Create access key

access key section

Select Other and click Next.

create access key

Set description for your access key

set description

Finally you can retrieve your access key.

retrieve access key

The access key should never be checked into your code repository. This is for running locally or using in terraform cloud only. If running locally you can put these values in .auto.tfvars.

Running Locally via CLI

Sensitive Token

The aws_access_key and aws_secret_key variable should not be checked into your code repository.

Create the .auto.tfvars in your working directory. This file should not be checked into your code repository.

aws_access_key = "<aws-access-key>"
aws_secret_key = "<aws-secret-key>"

If you use the template above the .auto.tfvars is automatically ignored.

Once all the configuration files are in place simply run:

terraform init
terraform plan
terraform apply

If you have further suggestions on how we can make this better please don't hesitate to open an issue. Or reach out to us via one of our support channels. If you need a quick support and would like to chat you can join our slack group.