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.

37 lines
723 B

  1. terraform {
  2. required_providers {
  3. digitalocean = {
  4. source = "digitalocean/digitalocean"
  5. version = "~> 2.0"
  6. }
  7. }
  8. }
  9. resource "digitalocean_tag" "cluster" {
  10. name = "${var.name}"
  11. }
  12. resource "digitalocean_ssh_key" "cluster" {
  13. name = "${var.name}"
  14. public_key = "${file(var.ssh_key)}"
  15. }
  16. resource "digitalocean_droplet" "cluster" {
  17. name = "${var.name}-node${count.index}"
  18. image = "centos-7-x64"
  19. size = "${var.instance_size}"
  20. region = "${element(var.regions, count.index)}"
  21. ssh_keys = ["${digitalocean_ssh_key.cluster.id}"]
  22. count = "${var.servers}"
  23. tags = ["${digitalocean_tag.cluster.id}"]
  24. lifecycle = {
  25. prevent_destroy = false
  26. }
  27. connection {
  28. timeout = "30s"
  29. }
  30. }