go-gandi / terraform-provider-gandi

Terraform provider for the Gandi Domain services
Mozilla Public License 2.0
152 stars 45 forks source link

Managing domain tags #122

Closed Mika56 closed 2 years ago

Mika56 commented 2 years ago

We're considering using Terraform to manage our domains' configuration. As a reseller, we have a lot (200+) domains and would be moving our configuration gradually.

As such, being able to tag our domains with a terraform tag would allow us to quickly see which domains are managed by Terraform.

Managing domain tags is possible via the API https://api.gandi.net/docs/domains/#v5-domain-domains-domain-tags, but not implemented yet in terraform-provider-gandi

Ideally, in our opinion, Terraform would only manage the tags specified in configuration, allowing tags to be manually added to domains and not being deleted by Terraform on the next apply

nlewo commented 2 years ago

Hello @Mika56

Yep, that would definitely be nice to add the tags support in the gandi_domain resource.

We could add a tags attribute in the gandi_domain resource. By default, i think Terraform should manage all tags: if some tags have been set outside of the Terraform configuration, they are deleted in order to reconcile the API state with the configuration.

However, we could add a boolean attribute such as mutable_tags=False. When set to True, Terraform would only manage tags defined in the configuration. It would be really nice if you could provide more details about your usecase. I'm wondering why you want to manage some tags outside of the Terraform configuration. (Maybe we could address it without having to introduce a new attribute.)

FYI, a feature close to this one as been recently implemented: https://github.com/go-gandi/terraform-provider-gandi/pull/111. Basically, it tells Terraform to only manage TXT record values defined in the configuration.

Mika56 commented 2 years ago

Hi!

Our use case is this:

nlewo commented 2 years ago

To prevent renewing unused domains, we manually add the "Do not renew" tag on the domain.

If the team in charge of adding the flag Do not renew knows how to use Terraform, I fail to see why this team should manually do it ;) Pushing this kind of changes with Terraform brings some befenits (such as a log of this action in a Git repository). (Also, instead of setting this flag, maybe the team could even also disable the autorenew flag via Terraform.)

But, you are the user and you know better than me what you need :wink: So, if you need it, i think we could add the mutable_tags attribute.

Mika56 commented 2 years ago

You may be right, now might be a good time to change how we do things. As far as I'm concerned, we've been doing like this since the dawn of time 🙃

Since I won't be the one implementing it you 100% should implement how you think is the best for everyone. I think I can work with or without mutable_tags, you've made a good point.

nlewo commented 2 years ago

I created https://github.com/go-gandi/terraform-provider-gandi/issues/122 to add the tags attribute. I'm however not sure there will be more work on this topic during this month (August...).

sandstrom commented 2 years ago

I agree, the ability to manage tags via the Terraform provider would be great.

Basically just being able to set/remove/update any tag value on a domain via Terraform.

nlewo commented 2 years ago

See https://github.com/go-gandi/terraform-provider-gandi/pull/127 :)

nlewo commented 2 years ago

@Mika56 #127 have been merged and i will publish a new release of the provider.

Since this issue is about "managing domain tags", i close it. But i know we are not 100% you could adress your usecase with the current implementation. So, feel free to reopen this issue or open a new one if you want "mutable" tags.