Basic Terraform module for provisioning a Chainlink EC2 instance.
- Terraform (https://terraform.io/)
-
Firstly install the Terraform cli from the official website and add it to your PATH:
-
Download your AWS programmatic credentials and place them in your user directory
~/.aws
:https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-files.html
-
In your AWS console, create a new SSH key pair called
chainlink-tf
and download it -
Run
terraform init
in this repository directory -
Run
terraform apply
in this repository directory. Once prompted for confirmation, enteryes
. -
If successful, an output similar to below will be shown:
Apply complete! Resources: 6 added, 0 changed, 0 destroyed. Outputs: public_ip = 1.2.3.4
-
To then access your node, just SSH into the IP shown with the key pair you downloaded:
ssh -i chainlink-tf.pem -L 6688:localhost:6688 [email protected]
-
Credentials are generated randomly and stored in
/root/.chainlink/api_pw
, to get them run:cat /root/.chainlink/api_pw
-
Browse to
http://localhost:6688
on your machine, and then enter the credentials from the file.
All done!
To edit configuration for the Chainlink instance being created, you can edit the defaults found in variables.tf
.
You can also change the variables when running terraform in your CLI. For example, this would restrict SSH access to just your IP:
terraform apply -var 'allowed_cidr=["1.2.3.4/32"]'
Or using a previous Chainlink version:
terraform apply -var 'image_tag=0.5.1'
Or using a different AWS region:
terraform apply -var 'region=eu-west-1'
Any further updates to this repository can be applied to your own AWS account by re-running terraform apply
.
Important: If you're applying changes and notice that the aws_instance
is being recreated, this will cause you to
loose all your data. If this is shown, backup your /root/.chainlink
folder on the instance and copy it to the new one.
To destroy the Chainlink EC2 instance and all subsequent resources, run:
terraform destroy
If you browse to CloudWatch in the AWS console and click "Logs", you should then see a chainlink-tf
group with logs
inside it for your Chainlink node.