Skip to content

Commit bddb00e

Browse files
authored
incapsula_origin_pop: avoid crashing when upgrading from version 2* to 3* without changing the resource format in the state file + Add deprecation message to already deprecated resources (old data_center resources) (#167)
1 parent a39ee68 commit bddb00e

File tree

4 files changed

+29
-13
lines changed

4 files changed

+29
-13
lines changed

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
## 3.5.2 (Unreleased)
22

3+
IMPROVEMENTS:
4+
5+
* Add deprecation message to already deprecated resources (old data_center resources)
6+
37
BUG FIXES:
48

59
* incapsula_site: formatting parameters with %t fails if the values are strings, not bool ([#158](https://github.com/imperva/terraform-provider-incapsula/issues/158))
6-
* incapsula_site: add retries when configuring site after creating it - to allow the site creation to fully finish
10+
* incapsula_site: add retries when configuring site after creating it - to allow the site creation to fully finish ([#165](https://github.com/imperva/terraform-provider-incapsula/issues/165))
711
* incapsula_notification_center_policy: Fix redundant slash in path issue ([#162](https://github.com/imperva/terraform-provider-incapsula/issues/162))
12+
* incapsula_origin_pop: avoid crashing when upgrading from version 2* to 3* without changing the resource format in the state file
813

914
## 3.5.1 (Released)
1015

incapsula/resource_data_center.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@ import (
1212

1313
func resourceDataCenter() *schema.Resource {
1414
return &schema.Resource{
15-
Create: resourceDataCenterCreate,
16-
Read: resourceDataCenterRead,
17-
Update: resourceDataCenterUpdate,
18-
Delete: resourceDataCenterDelete,
15+
DeprecationMessage: "This resource is deprecated. It will be removed in a future version. Please use resource incapsula_data_centers_configuration instead.",
16+
Create: resourceDataCenterCreate,
17+
Read: resourceDataCenterRead,
18+
Update: resourceDataCenterUpdate,
19+
Delete: resourceDataCenterDelete,
1920
Importer: &schema.ResourceImporter{
2021
State: func(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) {
2122
idSlice := strings.Split(d.Id(), "/")

incapsula/resource_data_center_server.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@ import (
1010

1111
func resourceDataCenterServer() *schema.Resource {
1212
return &schema.Resource{
13-
Create: resourceDataCenterServerCreate,
14-
Read: resourceDataCenterServerRead,
15-
Update: resourceDataCenterServerUpdate,
16-
Delete: resourceDataCenterServerDelete,
13+
DeprecationMessage: "This resource is deprecated. It will be removed in a future version. Please use resource incapsula_data_centers_configuration instead.",
14+
Create: resourceDataCenterServerCreate,
15+
Read: resourceDataCenterServerRead,
16+
Update: resourceDataCenterServerUpdate,
17+
Delete: resourceDataCenterServerDelete,
1718
Importer: &schema.ResourceImporter{
1819
State: func(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) {
1920
idSlice := strings.Split(d.Id(), "/")

incapsula/resource_origin_pop.go

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@ import (
1010

1111
func resourceOriginPOP() *schema.Resource {
1212
return &schema.Resource{
13-
Create: resourceOriginPOPUpdate,
14-
Read: resourceOriginPOPRead,
15-
Update: resourceOriginPOPUpdate,
16-
Delete: resourceOriginPOPDelete,
13+
DeprecationMessage: "This resource is deprecated. It will be removed in a future version. Please use resource incapsula_data_centers_configuration instead.",
14+
Create: resourceOriginPOPUpdate,
15+
Read: resourceOriginPOPRead,
16+
Update: resourceOriginPOPUpdate,
17+
Delete: resourceOriginPOPDelete,
1718
Importer: &schema.ResourceImporter{
1819
StateContext: schema.ImportStatePassthroughContext,
1920
},
@@ -74,6 +75,14 @@ func resourceOriginPOPUpdate(d *schema.ResourceData, m interface{}) error {
7475
func resourceOriginPOPRead(d *schema.ResourceData, m interface{}) error {
7576
// Implement by reading the ListDataCentersResponse for the data centers
7677
client := m.(*Client)
78+
if !strings.Contains(d.Id(), "/") {
79+
log.Printf("[ERROR] The origin_pop resource in your state file is in the old, unsupported format. /n" +
80+
"We recommend to use the new resource of data_center_configuration which replaced this resource./n" +
81+
"If you choose to continue using this resource, you must update the resource in your configuration files according to the new format. /n " +
82+
"The old resource will now be removed from state file, and will be updated back on the next terraform plan.")
83+
d.SetId("")
84+
return nil
85+
}
7786
siteID := strings.Split(d.Id(), "/")[0]
7887
dcID := strings.Split(d.Id(), "/")[1]
7988

0 commit comments

Comments
 (0)