Giter VIP home page Giter VIP logo

Comments (5)

remilapeyre avatar remilapeyre commented on August 17, 2024 2

Hi @the-nando, thanks for reporting this issue. Indeed it was expected to use policies IDs in this parameter. I don't think we can accept both name and IDs in this parameter in a backward compatible manner so I will add a validation and better documentation so that an detailled error can be returned early to the user, and work to support both names and IDs in a later major version of the provider.

from terraform-provider-consul.

remilapeyre avatar remilapeyre commented on August 17, 2024 1

Hello @the-nando, @jorgemarey, I have started to look into this issue in more depth in order to support both using an ID or a name.

The solution proposed by @jorgemarey should work and I think it may be a good short-term solution.

I have also started working a release for the provider that should address this and other long-standing issues: https://registry.terraform.io/providers/remilapeyre/consul-next/latest/docs/resources/acl_token.

I am still working on it but you should be able to use either an ID or the name with it:

resource "consul_acl_policy" "test" {
  name  = "test"
  rules = <<-RULE
    node_prefix "" {
      policy = "read"
    }
  RULE
}

resource "consul_acl_policy" "test2" {
  name  = "test2"
  rules = <<-RULE
    node_prefix "" {
      policy = "read"
    }
  RULE
}

resource "consul_acl_token" "test" {
  policies = [
    {
      id = consul_acl_policy.test.id
    },
    {
      name = consul_acl_policy.test2.name
    }
  ]
}

EDIT: if you test here I am very interested by your feedback either here or on the other repo.

from terraform-provider-consul.

const-tmp avatar const-tmp commented on August 17, 2024

In Consul API policies by name are documented.
Provider documentation says nothing about policy IDs.
It looks very confusing.

from terraform-provider-consul.

jorgemarey avatar jorgemarey commented on August 17, 2024

Hi @remilapeyre, on the ID vs name case, I guess, at the same time you added that the policy should be a valid UUID, maybe we can change that and provide the value as an ID if it's a valid UUID or as a name otherwise. I guess this won't break for anyone, as it would be backwards compatible. Everyone right now should be providing valid UUIDs. So this would only open the scope to set the value as name if it's not a valid UUID. What do you think?

I'm open to making a PR for this if you think it's valid.

from terraform-provider-consul.

the-nando avatar the-nando commented on August 17, 2024

@remilapeyre would it be an option to automatically derive whether the passed value in the policies list is a UUID or a name by parsing it? Something along the lines of:

import "github.com/google/uuid"

func IsValidUUID(u string) bool {
    _, err := uuid.Parse(u)
    return err == nil
 }

What do you think? It doesn't account for the case of someone naming his policies with UUIDs, which is a corner case I'd say.

from terraform-provider-consul.

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.