Git Product home page Git Product logo

Comments (8)

mrparkers avatar mrparkers commented on August 21, 2024

Hi @trois-six, the role will not have any composite roles if you omit the composite_roles attribute completely. Let me know if that works for you.

from terraform-provider-keycloak.

trois-six avatar trois-six commented on August 21, 2024

Yes that works, but if I have a role that have composite roles and I want to remove the composite roles, I can't.

from terraform-provider-keycloak.

mrparkers avatar mrparkers commented on August 21, 2024

Omitting the attribute should remove all of that role's composites, can you give me the HCL you're using and explain the behavior you're getting verses the behavior you're expecting?

from terraform-provider-keycloak.

mrparkers avatar mrparkers commented on August 21, 2024

Also, my acceptance tests explicitly cover this scenario (adding composite roles and removing them all) so if you're noticing some strange behavior, it's probably a bug that I'd like to get fixed.

from terraform-provider-keycloak.

trois-six avatar trois-six commented on August 21, 2024

OK I confirm that omitting the attribute remove all the role's composites. That's not usual for a Terraform resource but it works. Thank you !

from terraform-provider-keycloak.

mrparkers avatar mrparkers commented on August 21, 2024

I'm open to allowing users to specify an empty list of composite_roles if that would make you feel better. I would also like to keep the behavior of removing composite roles if the attribute is not specified.

If this is something you want, you can re-open this issue and I'll work on it when I get a chance.

from terraform-provider-keycloak.

trois-six avatar trois-six commented on August 21, 2024

The way it is done, I can't use this resource inside a module with a default value, but I can workaround it for the moment.

from terraform-provider-keycloak.

mrparkers avatar mrparkers commented on August 21, 2024

That's a fair use case, I did not think about that.

I think with HCL2 you could do something like this (forgive me if the syntax is incorrect, I don't use HCL2 yet):

resource "keycloak_role" "role" {
    realm_id = "master"
    name     = "test"

    composite_roles = len(var.composites == 0) ? null : var.composites
}

I think with HCL1 (which is what I'm still using) you'd have to do something even worse due to the lack of the null type:

resource "keycloak_role" "role" {
    count    = "${len(var.composites) == 0 ? 1 : 0}"
    realm_id = "master"
    name     = "test"
}

resource "keycloak_role" "role_with_composites" {
    count    = "${len(var.composites) == 0 ? 0 : 1}"
    realm_id = "master"
    name     = "test"

    composite_roles = "${var.composites}"
}

In either case, I agree that it is silly to have to add logic to your HCL because the provider won't allow you to specify an empty list for this attribute.

Thanks for helping me understand your use case, I'll work on this when I have some free time.

from terraform-provider-keycloak.

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.