terraform-provider-cloudflare icon indicating copy to clipboard operation
terraform-provider-cloudflare copied to clipboard

Newly created ressource detected as "modified outside of terraform"

Open apollo13 opened this issue 3 years ago • 3 comments

Confirmation

  • [X] My issue isn't already found on the issue tracker.
  • [X] I have replicated my issue using the latest version of the provider and it is still present.

Terraform and Cloudflare provider version

Terraform v1.0.0
on linux_amd64
+ provider registry.terraform.io/cloudflare/cloudflare v2.21.0

I also tested against git master

Affected resource(s)

cloudflare_record

Terraform configuration files

resource "cloudflare_record" "test_record" {
  zone_id  = "my_id"
  name     = "id"
  value    = "123"
  type     = "TXT"
}

Debug output

2021-06-09T14:18:58.630+0200 [DEBUG] provider.terraform-provider-cloudflare_v2.21.0: 2021/06/09 14:18:58 [DEBUG] Cloudflare API Response Details:
2021-06-09T14:18:58.631+0200 [DEBUG] provider.terraform-provider-cloudflare_v2.21.0: ---[ RESPONSE ]--------------------------------------
2021-06-09T14:18:58.631+0200 [DEBUG] provider.terraform-provider-cloudflare_v2.21.0: HTTP/2.0 200 OK
2021-06-09T14:18:58.631+0200 [DEBUG] provider.terraform-provider-cloudflare_v2.21.0: Cf-Cache-Status: DYNAMIC
2021-06-09T14:18:58.631+0200 [DEBUG] provider.terraform-provider-cloudflare_v2.21.0: Cf-Ray: 
2021-06-09T14:18:58.631+0200 [DEBUG] provider.terraform-provider-cloudflare_v2.21.0: Cf-Request-Id: 
2021-06-09T14:18:58.631+0200 [DEBUG] provider.terraform-provider-cloudflare_v2.21.0: Content-Type: application/json
2021-06-09T14:18:58.631+0200 [DEBUG] provider.terraform-provider-cloudflare_v2.21.0: Date: Wed, 09 Jun 2021 12:18:58 GMT
2021-06-09T14:18:58.631+0200 [DEBUG] provider.terraform-provider-cloudflare_v2.21.0: Expect-Ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
2021-06-09T14:18:58.631+0200 [DEBUG] provider.terraform-provider-cloudflare_v2.21.0: Server: cloudflare
2021-06-09T14:18:58.631+0200 [DEBUG] provider.terraform-provider-cloudflare_v2.21.0: Set-Cookie: 
2021-06-09T14:18:58.631+0200 [DEBUG] provider.terraform-provider-cloudflare_v2.21.0: Set-Cookie: 
2021-06-09T14:18:58.631+0200 [DEBUG] provider.terraform-provider-cloudflare_v2.21.0: Vary: Accept-Encoding
2021-06-09T14:18:58.631+0200 [DEBUG] provider.terraform-provider-cloudflare_v2.21.0: X-Envoy-Upstream-Service-Time: 3
2021-06-09T14:18:58.631+0200 [DEBUG] provider.terraform-provider-cloudflare_v2.21.0: 
2021-06-09T14:18:58.631+0200 [DEBUG] provider.terraform-provider-cloudflare_v2.21.0: {
2021-06-09T14:18:58.631+0200 [DEBUG] provider.terraform-provider-cloudflare_v2.21.0:  "result": {
2021-06-09T14:18:58.631+0200 [DEBUG] provider.terraform-provider-cloudflare_v2.21.0:   "id": "my_record_id",
2021-06-09T14:18:58.631+0200 [DEBUG] provider.terraform-provider-cloudflare_v2.21.0:   "zone_id": "my_id",
2021-06-09T14:18:58.631+0200 [DEBUG] provider.terraform-provider-cloudflare_v2.21.0:   "zone_name": "domain.tld",
2021-06-09T14:18:58.631+0200 [DEBUG] provider.terraform-provider-cloudflare_v2.21.0:   "name": "id",
2021-06-09T14:18:58.631+0200 [DEBUG] provider.terraform-provider-cloudflare_v2.21.0:   "type": "TXT",
2021-06-09T14:18:58.631+0200 [DEBUG] provider.terraform-provider-cloudflare_v2.21.0:   "content": "123",
2021-06-09T14:18:58.631+0200 [DEBUG] provider.terraform-provider-cloudflare_v2.21.0:   "proxiable": false,
2021-06-09T14:18:58.631+0200 [DEBUG] provider.terraform-provider-cloudflare_v2.21.0:   "proxied": false,
2021-06-09T14:18:58.631+0200 [DEBUG] provider.terraform-provider-cloudflare_v2.21.0:   "ttl": 1,
2021-06-09T14:18:58.631+0200 [DEBUG] provider.terraform-provider-cloudflare_v2.21.0:   "locked": false,
2021-06-09T14:18:58.631+0200 [DEBUG] provider.terraform-provider-cloudflare_v2.21.0:   "meta": {
2021-06-09T14:18:58.631+0200 [DEBUG] provider.terraform-provider-cloudflare_v2.21.0:    "auto_added": false,
2021-06-09T14:18:58.631+0200 [DEBUG] provider.terraform-provider-cloudflare_v2.21.0:    "managed_by_apps": false,
2021-06-09T14:18:58.631+0200 [DEBUG] provider.terraform-provider-cloudflare_v2.21.0:    "managed_by_argo_tunnel": false,
2021-06-09T14:18:58.632+0200 [DEBUG] provider.terraform-provider-cloudflare_v2.21.0:    "source": "primary"
2021-06-09T14:18:58.632+0200 [DEBUG] provider.terraform-provider-cloudflare_v2.21.0:   },
2021-06-09T14:18:58.632+0200 [DEBUG] provider.terraform-provider-cloudflare_v2.21.0:   "created_on": "2021-05-17T13:17:15.865907Z",
2021-06-09T14:18:58.632+0200 [DEBUG] provider.terraform-provider-cloudflare_v2.21.0:   "modified_on": "2021-05-17T13:17:15.865907Z"
2021-06-09T14:18:58.632+0200 [DEBUG] provider.terraform-provider-cloudflare_v2.21.0:  },
2021-06-09T14:18:58.632+0200 [DEBUG] provider.terraform-provider-cloudflare_v2.21.0:  "success": true,
2021-06-09T14:18:58.632+0200 [DEBUG] provider.terraform-provider-cloudflare_v2.21.0:  "errors": [],
2021-06-09T14:18:58.632+0200 [DEBUG] provider.terraform-provider-cloudflare_v2.21.0:  "messages": []
2021-06-09T14:18:58.632+0200 [DEBUG] provider.terraform-provider-cloudflare_v2.21.0: }
2021-06-09T14:18:58.632+0200 [DEBUG] provider.terraform-provider-cloudflare_v2.21.0: -----------------------------------------------------
2021-06-09T14:18:58.632+0200 [DEBUG] provider.terraform-provider-cloudflare_v2.21.0: 2021/06/09 14:18:58 [DEBUG] Data found in config: map[string]interface {}{}
2021-06-09T14:18:58.638+0200 [WARN]  Provider "registry.terraform.io/cloudflare/cloudflare" produced an invalid plan for cloudflare_record.test, but we are tolerating it because it is using the legacy plugin SDK.
    The following problems may be the cause of any confusing errors from downstream operations:
      - .data: planned value cty.MapValEmpty(cty.String) for a non-computed attribute
      - .proxied: planned value cty.False for a non-computed attribute
2021-06-09T14:18:58.639+0200 [DEBUG] provider.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = transport is closing"
2021-06-09T14:18:58.641+0200 [DEBUG] provider: plugin process exited: path=.terraform/providers/registry.terraform.io/cloudflare/cloudflare/2.21.0/linux_amd64/terraform-provider-cloudflare_v2.21.0 pid=49178
2021-06-09T14:18:58.641+0200 [DEBUG] provider: plugin exited
2021-06-09T14:18:58.641+0200 [INFO]  backend/local: plan operation completed

Note: Objects have changed outside of Terraform

Terraform detected the following changes made outside of Terraform since the last "terraform apply":

  # cloudflare_record.test has been changed
  ~ resource "cloudflare_record" "test" {
      + data        = {}
        id          = "my_record_id"
        name        = "id"
        # (10 unchanged attributes hidden)
    }

Unless you have made equivalent changes to your configuration, or ignored the relevant attributes using ignore_changes, the following plan may include actions to undo or respond to these changes.

─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

No changes. Your infrastructure matches the configuration.

Panic output

No response

Expected output

No changes. Infrastructure is up-to-date.

This means that Terraform did not detect any differences between your configuration and the remote system(s). As a result, there are no actions to take.

Actual output

Note: Objects have changed outside of Terraform

Terraform detected the following changes made outside of Terraform since the last "terraform apply":

  # cloudflare_record.test has been changed
  ~ resource "cloudflare_record" "test" {
      + data        = {}
        id          = "my_record_id"
        name        = "id"
        # (10 unchanged attributes hidden)
    }

Unless you have made equivalent changes to your configuration, or ignored the relevant attributes using ignore_changes, the following plan may include actions to undo or respond to these changes.

─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

No changes. Your infrastructure matches the configuration.

Steps to reproduce

  1. Create (any?) txt record in a cloudflare zone via TF
  2. Run plan again
  3. Observe the change in data = {}

Additional factoids

Terraform 0.15.3 did not show the error. Starting with 0.15.4 terraform added this as new "feature" https://github.com/hashicorp/terraform/blob/v0.15/CHANGELOG.md#0154-may-19-2021

References

No response

apollo13 avatar Jun 09 '21 12:06 apollo13

I can confirm that the issue starts with Terraform 0.15.4. Given the debug output of legacy feature usage I am not sure who is at fault (TF or the provider)

apollo13 avatar Jun 09 '21 12:06 apollo13

I also have this issue since upgrading to Terraform 1.0.0. I suspect everyone will.

It isn't just TXT records - this also happens with CNAME records and probably all types of DNS record.

I guess this error occurs because value and data are alternative ways of describing the content in a cloudflare_record.

It appears that, if Terraform is in local execution mode, the status can be cleared by running terraform apply -refresh-only. However when using Terraform Cloud, there is no mechanism to clear the status without making a further active modification.

johnowennixon avatar Jun 16 '21 15:06 johnowennixon

Relevant discussion on the Terraform project https://github.com/hashicorp/terraform/issues/28803

Evesy avatar Jun 17 '21 10:06 Evesy

closing this out as core behaviour and not something we can directly impact and the upstream fix in https://github.com/hashicorp/terraform/issues/28803#issuecomment-1072740861 should have addressed the concerns here.

jacobbednarz avatar Sep 28 '22 03:09 jacobbednarz