Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem while updating resource in custom terraform provider #612

Closed
nabarunchatterjee opened this issue Oct 13, 2020 · 3 comments
Closed
Assignees
Labels
bug Something isn't working subsystem/types Issues and feature requests related to the type system of Terraform and our shims around it.
Milestone

Comments

@nabarunchatterjee
Copy link

I am trying to write a custom terraform provider. In that, I have a resource called dash_panel which looks something like this:

resource "dash_panel" "http_reliability" {
  name = "http_reliability"
  chart {
    title = "Reliability Test1"
    options = {
      "charting.chart" = "radialGauge"
    }
  }
}

Just to illustrate the issue, I have made this a local-only resource.

This resource is expected to return an xml that looks like this:

<panel>
    <chart>
        <title>Reliability Test1</title>
        <option name="charting.chart">radialGauge</option>
    </chart>
</panel>

This is working as expected.

The problem starts when I try to update the chart. For example, If change the title to New Title

What I expect to get is:

<panel>
  <chart>
    <title>New Title</title>
    <option name="charting.chart">radialGauge</option>
  </chart>
</panel>

What I am getting is:

<panel>
  <chart>
    <title>New Title</title>
    <option name="charting.chart">radialGauge</option>
  </chart>
  <chart></chart>
</panel>

Note: The placement of the empty chart is arbitrary, it is either before or after the chart with values.

Moreover, I noticed that there are two charts being passed in the schema.ResourceData of the update function of this resource.

I also noticed that this problem vanishes when I remove the options map from the chart schema.

Do let me know what I am doing wrong?

Other details:

Full Code: https://github.com/nabarunchatterjee/terraform-provider-test

Terraform version: 0.13.2

Golang version: 1.14.4
@nabarunchatterjee nabarunchatterjee added the bug Something isn't working label Oct 13, 2020
@paddycarver paddycarver added the subsystem/types Issues and feature requests related to the type system of Terraform and our shims around it. label Jan 6, 2021
@ewbankkit
Copy link
Contributor

ewbankkit commented Feb 18, 2021

@nabarunchatterjee Are you modeling options as TypeMap and chart as TypeSet?
If so, there are a couple of open issues (#588, #652) for the update adding an additional empty set element.

@bflad bflad self-assigned this Mar 15, 2022
@bflad bflad modified the milestones: v2.12.0, v2.13.0 Mar 15, 2022
@bflad
Copy link
Member

bflad commented Mar 21, 2022

I can confirm this issue still reproduces on the most recent versions of Terraform CLI (1.1.7) and terraform-plugin-sdk/v2 (v2.12.0). Given that we have #652 which also captures this same class of problem, I'm going to consolidate this issue into that one. Please subscribe to that issue for any further updates.

@bflad bflad closed this as completed Mar 21, 2022
@github-actions
Copy link

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 21, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working subsystem/types Issues and feature requests related to the type system of Terraform and our shims around it.
Projects
None yet
Development

No branches or pull requests

4 participants