Terraform Metadata Primary to Null

Hello,

We run terraform format, validate, plan and apply as part of CI/CD using github actions workflow to create DNS, LB in Cloudflare. As a part of creating a new DNS record, we have created a pull request in GIT which runs the terraform plan. We have observed a new set of objects/logs in plan as following.

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

  # cloudflare_record.x_y_z has changed
  ~ resource "cloudflare_record" "x_y_z" {
        id              = "xxxxxxxxxxxxxxxxxxx"
      ~ metadata        = {
          - "source"                 = "primary" -> null
            # (3 unchanged elements hidden)
        }
        name            = "xxxxxxxxxxxx"
        # (11 unchanged attributes hidden)
    }

But the record with it’s ID is in refreshing state but losing the original state of metadata. We have seen the same for all the records present in Github repo (previous deployments).

Is there any work around to retrieve the metadata to original state (last state file) ?

Thanks in advance.

The message "changes made outside of Terraform" indicates that this is the raw state that the provider returned for the resource, so there is nothing you can do from the configuration to prevent the change.

The full context wasn’t included here, but if this was a -refresh-only plan it will show all external changes even if they have no impact in the desired state. If this was a normal plan, and these changes are causing updates in that plan, then this is an issue that would need to be fixed within the provider.

I would also verify that you are using the latest provider and terraform releases, since it something which has already been noticed and fixed from earlier releases.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.