logzio / terraform-provider-logzio

Terraform provider for logz.io alerts, endpoints and users
Apache License 2.0
19 stars 17 forks source link

Added datasource and provider for grafana_dashboard #109

Closed etiennejournet closed 1 year ago

etiennejournet commented 2 years ago

Hello team,

Here is an proposition for the logzio_dashboard terraform resource. This loads a json dashboard from a local file and applies it on logzio.

For the moment it's still a WIP because :

  1. the non-idempotent field version gets updated after each run and will always differ from the json version field
  2. the json dashboard id field cannot be present (in the file) when "Create" (API call CreateUpdateGrafanaDashboard failed with missing dashboard 300661, data: {"message":"Dashboard not found","status":"not-found"}), but is required in the json file for "Update". That makes for a perpetual change because the json's id field will always differ from the state's id.

Would you have any idea on how to workaround this ?

Note : this works with this code

Thanks,

mirii1994 commented 1 year ago

Hi @etiennejournet thank you for your contribution. I made a few changes to your code. Now, when applying a plan, the fields id and version are remove from the state. That way there are no diffs.

etiennejournet commented 1 year ago

Hello @mirii1994, thx for your insights and this opportunity to navigate through properly-structured code 👍

Good job with the grafanaDashboardsFieldsToDelete variable !

Regards,