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

Empty state when refreshing firewall resource created in another region #80

Closed
zulh-civo opened this issue Sep 1, 2021 · 2 comments
Closed
Assignees
Labels

Comments

@zulh-civo
Copy link
Member

zulh-civo commented Sep 1, 2021

Terraform config file:

provider "civo" {
    token = "api-token"
    region = "LON1"
}

resource "civo_firewall" "www" {
  name = "www"
  region = "NYC1"
}

Terminal traces:

$ tf apply --auto-approve

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # civo_firewall.www will be created
  + resource "civo_firewall" "www" {
      + id         = (known after apply)
      + name       = "www"
      + network_id = (known after apply)
      + region     = "NYC1"
    }

Plan: 1 to add, 0 to change, 0 to destroy.
civo_firewall.www: Creating...
civo_firewall.www: Creation complete after 5s [id=a6a12049-b55d-4d4e-a520-a339acfc72cb]

Apply complete! Resources: 1 added, 0 changed, 0 destroyed.



$ tf refresh && tf show
civo_firewall.www: Refreshing state... [id=a6a12049-b55d-4d4e-a520-a339acfc72cb]




$ tf refresh && tf show
╷
│ Warning: Empty or non-existent state
│
│ There are currently no resources tracked in the state, so there is nothing to refresh.

How to fix:

Add the following block in firewall's Read, Update and Delete function. It only exists in Create function currently.

if attr, ok := d.GetOk("region"); ok {
    apiClient.Region = attr.(string)
}
@zulh-civo
Copy link
Member Author

zulh-civo commented Sep 3, 2021

Looks like this was already implemented in #78 - https://github.com/civo/terraform-provider-civo/pull/78/files

@zulh-civo
Copy link
Member Author

I tested master branch (0bbeab8) and I can confirm this issue is fixed by PR above.

@zulh-civo zulh-civo self-assigned this Sep 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant