Giter VIP home page Giter VIP logo

Comments (8)

jakubgs avatar jakubgs commented on August 30, 2024 4

I'm trying to use sort() with a list of tags but it has o effect:

locals = {
  tags = ["${var.stage}", "${var.group}", "${var.env}"]
  tags_sorted = "${sort(distinct(local.tags))}"
  tags_count = "${length(local.tags_sorted)}"
}

resource "digitalocean_tag" "host" {
  name  = "${element(local.tags_sorted, count.index)}"
  count = "${local.tags_count}"
}

resource "digitalocean_droplet" "host" {
...
    tags = ["${sort(digitalocean_tag.host.*.id)}"]
...
}

The result is still the same, tags re-ordering on every run.

from terraform-provider-digitalocean.

mageddo avatar mageddo commented on August 30, 2024

Same issue here.

-                            "tags.0": "worker",
-                            "tags.1": "cluster",
+                            "tags.0": "cluster",
+                            "tags.1": "worker",

from terraform-provider-digitalocean.

jackivanov avatar jackivanov commented on August 30, 2024

Same issue.
Use sort() is a workaround

from terraform-provider-digitalocean.

TheYorkshireDev avatar TheYorkshireDev commented on August 30, 2024

This still seems to be an issue, @jackivanov can you elaborate and give an example?

from terraform-provider-digitalocean.

dharmeshptl avatar dharmeshptl commented on August 30, 2024

this worked for me

module "do_swarm_worker" {
source = "./do_swarm_worker"
token = "${var.do_token}"
region = "${var.do_region}"
domain = "${var.domain}"
tags = ["${sort(list(digitalocean_tag.cluster.id,digitalocean_tag.worker.id))}"]
}

from terraform-provider-digitalocean.

soar avatar soar commented on August 30, 2024

Very annoying issue

from terraform-provider-digitalocean.

paranoidd avatar paranoidd commented on August 30, 2024

Hello fellow DigitalOcean Terraformers! I've joined the group of people suffering from the issue. No sort work-arounds are working for me. I've recently also hit a hard limit of DigitalOcean firewalls (100), what caused me to start heavily rely on tags. So now for each TF workspace, we do get a plan with changes, even tho there are not real changes :(

Considering that we are kind of forced to use tags if we want to utilise digitalocean_firewall effectively, I think this issue is more than annoying. Any known work-arounds are welcome!

Side question - did anyone try to sort the problem with lifecycle & ignore_changes? I haven't explored it yet as it feels like dirty hack - I still kind of care about changes to tags (if there are actual changes)

from terraform-provider-digitalocean.

baffolobill avatar baffolobill commented on August 30, 2024

@paranoidd It totally depends on your implementation/requirements/needs. For example, you can do it like in this demo https://github.com/baffolobill/terraform-digitalocean-tags-hack (this is part of my project, not sure that all dependencies included) - I just manually process tags via bash scripts. This is just an idea, not complete solution.

resource "null_resource" "assign_tags_to_droplet" {
    depends_on = [
        "digitalocean_droplet.bastion",
        "module.droplet_tags",
    ]
    count      = "${var.num_nodes}"

    triggers {
        tag_ids    = "${join(",", module.droplet_tags.tags)}",
        droplet_id = "${element(digitalocean_droplet.bastion.*.id, count.index)}",
    }

    # !!! All magic does this script. You can test it like so:
    provisioner "local-exec" {
        command = "\"${path.module}/../../../../scripts/assign_tags_to_droplet.sh\" ${element(digitalocean_droplet.bastion.*.id, count.index)} ${join(" ", module.droplet_tags.tags)}"
    }
}

I do so because of another problem with tags: in some cases when Terraform sees changes in tags, it destroys a tag by deleting it (contrary to "untag") (if it's not obvious, Terraform doesn't re-add resources to a tag, when it re-creates a tag). As result, this tag disappear from all resources, even from those which aren't managed by Terraform. It brings me to situation when Droplets didn't see each other (my firewall rules totally rely on tags), consul couldn't connect to leader (because auto-join rely on tags).

from terraform-provider-digitalocean.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.