thojkooi / terraform-digitalocean-docker-swarm-mode

Terraform module for provisioning a Docker Swarm mode cluster on DigitalOcean
https://registry.terraform.io/modules/thojkooi/docker-swarm-mode/digitalocean
MIT License
63 stars 27 forks source link

Tags And Firewall resources keep changing order #7

Open mageddo opened 7 years ago

mageddo commented 7 years ago

I am facing a issue with the DigitalOcean tag ids and firewall rules resources described here, basically every time I ran terraform plan it change the JSON tags order then terrraform understand that must apply a change.

Have you faced this issue? You found some workaround for that?

thojkooi commented 7 years ago

I haven't in the past, but I have been able to reproduce it. It seems like it's something to do with the lexical order of the tag names.

It does not seem to be an issue in this example:

variable "do_token" {}

provider "digitalocean" {
  token = "${var.do_token}"
}

variable "ssh_keys" {
  type = "list"
}

resource "digitalocean_tag" "cluster" {
  name = "swarm-mode-cluster"
}

resource "digitalocean_tag" "manager" {
  name = "manager"
}

resource "digitalocean_tag" "worker" {
  name = "worker"
}

module "swarm-cluster" {
  source           = "github.com/thojkooi/terraform-digitalocean-docker-swarm-mode"
  total_managers   = 1
  total_workers    = 1
  region           = "ams3"
  do_token         = "${var.do_token}"
  manager_ssh_keys = "${var.ssh_keys}"
  worker_ssh_keys  = "${var.ssh_keys}"
  manager_tags     = ["${digitalocean_tag.cluster.id}", "${digitalocean_tag.manager.id}"]
  worker_tags      = ["${digitalocean_tag.cluster.id}", "${digitalocean_tag.worker.id}"]
  domain           = "do.example.com"
}

If you reverse the cluster and manager tag, you have the issue as well.

Note; when running the above example, terraform destroy may not work properly at the moment. I encountered a cycle dependency when attempting to destroy the cluster module just now. now fixed through thojkooi/terraform-digitalocean-swarm-workers#2

I am at the moment playing around with ${sort(list(digitalocean_tag.cluster.id, digitalocean_tag.manager.id))} to see if that makes any difference and could be used as a work around.