Empty state when refreshing firewall resource created in another region
zulh-civo opened this issue · 2 comments
zulh-civo commented
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 commented
Looks like this was already implemented in #78 - https://github.com/civo/terraform-provider-civo/pull/78/files