You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
2.1 KiB

  1. # Terraform for Digital Ocean
  2. This is a generic [Terraform](https://www.terraform.io/) configuration that sets up DigitalOcean droplets.
  3. # Prerequisites
  4. * Install [HashiCorp Terraform](https://www.terraform.io) on a linux machine.
  5. * Create a [DigitalOcean API token](https://cloud.digitalocean.com/settings/api/tokens) with read and write capability.
  6. * Set an SSH key at the [DigitalOcean security page](https://cloud.digitalocean.com/settings/security).
  7. * Find out your SSH key ID at DigitalOcean by querying the below command on your linux box:
  8. ```
  9. DO_API_TOKEN="<The API token received from DigitalOcean>"
  10. curl -X GET -H "Content-Type: application/json" -H "Authorization: Bearer $DO_API_TOKEN" "https://api.digitalocean.com/v2/account/keys"
  11. ```
  12. # How to run
  13. ## Initialization
  14. If this is your first time using terraform, you have to initialize it by running the below command. (Note: initialization can be run multiple times)
  15. ```
  16. terraform init
  17. ```
  18. After initialization it's good measure to create a new Terraform environment for the droplets so they are always managed together.
  19. ```
  20. TESTNET_NAME="testnet-servers"
  21. terraform env new "$TESTNET_NAME"
  22. ## Execution
  23. The below command will create 4 nodes in DigitalOcean. They will be named `testnet-servers-node0` to `testnet-servers-node3` and they will be tagged as `testnet-servers`.
  24. ```
  25. DO_API_TOKEN="<The API token received from DigitalOcean>"
  26. terraform apply -var TESTNET_NAME="testnet-servers" -var servers=4 -var DO_API_TOKEN="$DO_API_TOKEN"
  27. ```
  28. Alternatively you can use the default settings. The number of default servers is 7 and the testnet name is `tf-testnet1`. Variables can also be defined as environment variables instead of the command-line. Environment variables that start with `TF_VAR_` will be translated into the Terraform configuration. For example the number of servers can be overriden by setting the `TF_VAR_servers` variable.
  29. ```
  30. TF_VAR_DO_API_TOKEN="<The API token received from DigitalOcean>"
  31. terraform-apply
  32. ```
  33. # What's next
  34. After setting up the nodes, head over to the [ansible folder](https://github.com/tendermint/tools) to set up tendermint and basecoin.