louy / terraform-provider-uptimerobot

A terraform provider for UptimeRobot
Mozilla Public License 2.0
123 stars 85 forks source link

Special characters in friendly name cause modification on every apply #76

Open innovate-invent opened 4 years ago

innovate-invent commented 4 years ago

For example:

resource "uptimerobot_monitor" "id783840372" {
  friendly_name = "Galaxy for IslandCompare (AWS)"

results in

  # uptimerobot_monitor.id783840372 will be updated in-place
  ~ resource "uptimerobot_monitor" "id783840372" {
        custom_http_headers = {}
      ~ friendly_name       = "Galaxy for IslandCompare (AWS)" -> "Galaxy for IslandCompare (AWS)"

on every apply

drubin commented 4 years ago

This is sadly expetect behaviour and the uptime robot Api is doing this ( which is kinda bad)

You can fix this by changing your monitor name to not use the special chars or to just encode them as the Api returns them.

This should be documented though...

innovate-invent commented 4 years ago

Wouldn't it be appropriate for the provider to handle the necessary encoding between human readable and what the API requires?

drubin commented 4 years ago

I wouldn't think so because this is a not how core Terraform works it's also not documented how to unencode/encode or how to handle it.

This is how gpc and aws plugins work too when things get in

louy commented 4 years ago

This is obviously bad api behaviour, but I wonder whether calling html#UnescapeString on that field when fetching would fix this and make the UX a bit nicer. Should be easy to test and hopefully wouldn't introduce any unexpected issues.