Skip to content

Commit 7f953b8

Browse files
authored
fix: add deprecation notice for the vpn_gateways input (see [VPN Gateway migration steps](https://github.com/terraform-ibm-modules/terraform-ibm-landing-zone-vpc/blob/main/docs/migration_guide.md) (#1041)
1 parent fc4a63a commit 7f953b8

File tree

6 files changed

+156
-7
lines changed

6 files changed

+156
-7
lines changed

README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
[![latest release](https://img.shields.io/github/v/release/terraform-ibm-modules/terraform-ibm-landing-zone-vpc?logo=GitHub&sort=semver)](https://github.com/terraform-ibm-modules/terraform-ibm-landing-zone-vpc/releases/latest)
77
[![Renovate enabled](https://img.shields.io/badge/renovate-enabled-brightgreen.svg)](https://renovatebot.com/)
88

9+
> ⚠️ In `v9.0.0` this module will no longer support VPN gateway functionality. Please see [migration guide](https://github.com/terraform-ibm-modules/terraform-ibm-landing-zone-vpc/blob/main/docs/migration_guide.md) for steps on how to migrate to the [terraform-ibm-site-to-site-vpn](https://github.com/terraform-ibm-modules/terraform-ibm-site-to-site-vpn) module.
10+
911
This module creates the following IBM Cloud® Virtual Private Cloud (VPC) network components:
1012

1113
- VPC: Creates a VPC in a resource group. The VPC and components are specified in the [main.tf](main.tf) file.
@@ -131,6 +133,7 @@ module.subnets.ibm_is_vpc_address_prefix.subnet_prefix["gcat-multizone-subnet-c"
131133
```
132134

133135
### Required IAM access policies
136+
134137
You need the following permissions to run this module.
135138

136139
- IAM services
@@ -188,6 +191,7 @@ To attach access management tags to resources in this module, you need the follo
188191
| [ibm_is_vpc_routing_table_route.routing_table_routes](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/is_vpc_routing_table_route) | resource |
189192
| [ibm_is_vpn_gateway.vpn_gateway](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/is_vpn_gateway) | resource |
190193
| [ibm_resource_instance.dns_instance_hub](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/resource_instance) | resource |
194+
| [terraform_data.deprecation_warning](https://registry.terraform.io/providers/hashicorp/terraform/latest/docs/resources/data) | resource |
191195
| [time_sleep.wait_for_authorization_policy](https://registry.terraform.io/providers/hashicorp/time/latest/docs/resources/sleep) | resource |
192196
| [time_sleep.wait_for_vpc_creation_data](https://registry.terraform.io/providers/hashicorp/time/latest/docs/resources/sleep) | resource |
193197
| [ibm_iam_account_settings.iam_account_settings](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/data-sources/iam_account_settings) | data source |
@@ -249,7 +253,7 @@ To attach access management tags to resources in this module, you need the follo
249253
| <a name="input_use_existing_dns_instance"></a> [use\_existing\_dns\_instance](#input\_use\_existing\_dns\_instance) | Whether to use an existing dns instance. If true, existing\_dns\_instance\_id must be set. | `bool` | `false` | no |
250254
| <a name="input_use_public_gateways"></a> [use\_public\_gateways](#input\_use\_public\_gateways) | Create a public gateway in any of the three zones with `true`. | <pre>object({<br/> zone-1 = optional(bool)<br/> zone-2 = optional(bool)<br/> zone-3 = optional(bool)<br/> })</pre> | <pre>{<br/> "zone-1": true,<br/> "zone-2": true,<br/> "zone-3": true<br/>}</pre> | no |
251255
| <a name="input_vpc_flow_logs_name"></a> [vpc\_flow\_logs\_name](#input\_vpc\_flow\_logs\_name) | The name to give the provisioned VPC flow logs. If not set, the module generates a name based on the `prefix` and `name` variables. | `string` | `null` | no |
252-
| <a name="input_vpn_gateways"></a> [vpn\_gateways](#input\_vpn\_gateways) | List of VPN gateways to create. | <pre>list(<br/> object({<br/> name = string<br/> subnet_name = string # Do not include prefix, use same name as in `var.subnets`<br/> mode = optional(string)<br/> resource_group = optional(string)<br/> access_tags = optional(list(string), [])<br/> })<br/> )</pre> | `[]` | no |
256+
| <a name="input_vpn_gateways"></a> [vpn\_gateways](#input\_vpn\_gateways) | [DEPRECATED] List of VPN gateways to create. For more information please refer the [migration guide](https://github.com/terraform-ibm-modules/terraform-ibm-landing-zone-vpc/blob/main/docs/migration_guide.md). | <pre>list(<br/> object({<br/> name = string<br/> subnet_name = string # Do not include prefix, use same name as in `var.subnets`<br/> mode = optional(string, "route")<br/> resource_group = optional(string)<br/> access_tags = optional(list(string), [])<br/> })<br/> )</pre> | `[]` | no |
253257

254258
### Outputs
255259

@@ -277,8 +281,8 @@ To attach access management tags to resources in this module, you need the follo
277281
| <a name="output_vpc_flow_logs"></a> [vpc\_flow\_logs](#output\_vpc\_flow\_logs) | Details of VPC flow logs collector |
278282
| <a name="output_vpc_id"></a> [vpc\_id](#output\_vpc\_id) | ID of VPC created |
279283
| <a name="output_vpc_name"></a> [vpc\_name](#output\_vpc\_name) | Name of VPC created |
280-
| <a name="output_vpn_gateways_data"></a> [vpn\_gateways\_data](#output\_vpn\_gateways\_data) | Details of VPN gateways data. |
281-
| <a name="output_vpn_gateways_name"></a> [vpn\_gateways\_name](#output\_vpn\_gateways\_name) | List of names of VPN gateways. |
284+
| <a name="output_vpn_gateways_data"></a> [vpn\_gateways\_data](#output\_vpn\_gateways\_data) | [DEPRECATED] Details of VPN gateways data. For more information please refer the [migration guide](https://github.com/terraform-ibm-modules/terraform-ibm-landing-zone-vpc/blob/main/docs/migration_guide.md). |
285+
| <a name="output_vpn_gateways_name"></a> [vpn\_gateways\_name](#output\_vpn\_gateways\_name) | [DEPRECATED] List of names of VPN gateways. For more information please refer the [migration guide](https://github.com/terraform-ibm-modules/terraform-ibm-landing-zone-vpc/blob/main/docs/migration_guide.md). |
282286
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
283287

284288
## Contributing

docs/migration_guide.md

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
# VPN Gateway migration steps
2+
3+
## VPN Gateway changes in `v9.0.0`
4+
5+
* Starting with version `v9.0.0`, direct use of the VPN gateway in the main setup will be **removed**.
6+
* Instead of defining the VPN gateway resources, reference the [`terraform-ibm-modules/site-to-site-vpn`](https://github.com/terraform-ibm-modules/terraform-ibm-site-to-site-vpn) module.
7+
* Users must migrate their Terraform state and update outputs to avoid resource recreation and broken references.
8+
9+
## Overview
10+
11+
This change improves maintainability and consistency by consolidating VPN gateway logic into a dedicated module.
12+
Because resource addresses and outputs have changed, you must migrate your Terraform state and update any dependent references.
13+
14+
This release introduces the following changes:
15+
16+
1. Resource address migration (using `terraform state mv` and new helper resources).
17+
2. Output block changes (deprecation of `vpn_gateways_name` and link to new outputs).
18+
19+
## Resource Address Migration
20+
21+
The module to create VPN gateways can now be used as shown in the below example.
22+
23+
```hcl
24+
module "vpn_gateways" {
25+
source = "terraform-ibm-modules/site-to-site-vpn/ibm"
26+
version = "3.0.4" # Replace with the version of site to site VPN Module
27+
for_each = {
28+
vpn_gw_1 = {
29+
resource_group_id = "xxXXxxXXxXxXXXXxxXxxxXXXXxXXXXX" # Replace with your resource group id.
30+
name = "gateway-1"
31+
mode = "route"
32+
subnet_id = "xxXXxxXXxXxXXXXxxXxxxXXXXxXXXXX" # Replace with the subnet id where VPN Gateway will be created.
33+
}
34+
vpn_gw_2 = {
35+
resource_group_id = "xxXXxxXXxXxXXXXxxXxxxXXXXxXXXXX" # Replace with your resource group id.
36+
name = "gateway-2"
37+
mode = "policy"
38+
subnet_id = "xxXXxxXXxXxXXXXxxXxxxXXXXxXXXXX" # Replace with the subnet id where VPN Gateway will be created.
39+
}
40+
}
41+
resource_group_id = each.value.resource_group_id
42+
vpn_gateway_name = each.value.name
43+
vpn_gateway_subnet_id = each.value.subnet_id
44+
vpn_gateway_mode = each.value.mode
45+
}
46+
```
47+
48+
**Resource address (current):** `module.<module-name>.ibm_is_vpn_gateway.vpn_gateway["<gateway-name>"]`
49+
**Resource address (after migration):** `module.<module-name>.module.vpn_gateways["<gateway-name>"]`.ibm_is_vpn_gateway.vpn_gateway[0]`
50+
51+
## Migration Command
52+
53+
If you are upgrading an existing environment, you need to tell Terraform that the resource has moved so it doesn’t try to recreate it.
54+
55+
**Option 1: Using moved block :**
56+
57+
```hcl
58+
moved {
59+
from = module.<module-name>.ibm_is_vpn_gateway.vpn_gateway["gateway-1"]
60+
to = module.<module-name>.module.vpn_gateways["gateway-1"].ibm_is_vpn_gateway.vpn_gateway[0]
61+
}
62+
```
63+
64+
**Option 2: Using terraform state mv (manual alternative):**
65+
66+
Use the terraform state mv command to migrate each gateway:
67+
68+
```sh
69+
terraform state mv 'module.<module-name>.ibm_is_vpn_gateway.vpn_gateway[<gateway-name>]' 'module.<module-name>.module.vpn_gateways[<gateway-name>].ibm_is_vpn_gateway.vpn_gateway[0]'
70+
```
71+
72+
**Example:**
73+
74+
If the name of `vpn_gateway` is `gateway-1`, i.e.
75+
76+
```hcl
77+
vpn_gateways = [{
78+
name = "gateway-1"
79+
subnet_name = "subnet-a"
80+
}]
81+
```
82+
83+
Then terraform state moved command that can be used is:
84+
85+
```sh
86+
terraform state mv 'module.<module-name>.ibm_is_vpn_gateway.vpn_gateway["gateway-1"]' 'module.<module-name>.module.vpn_gateways["gateway-1"].ibm_is_vpn_gateway.vpn_gateway[0]'
87+
```
88+
89+
## New Resources
90+
91+
The vpn_gateways module introduces helper resources (e.g., `time_sleep.wait_for_gateway_creation`). This is new and will be created automatically on the next apply. No migration is required.
92+
93+
## Output block changes
94+
95+
* The `site‑to‑site-vpn` module does not expose VPN names directly thus the output `vpn_gateways_name` will no longer be available.
96+
97+
* The existing `vpn_gateways_data` will be updated to consume the module, i.e.
98+
99+
``` hcl
100+
output "vpn_gateways_data" {
101+
description = "Details of VPN gateways data."
102+
value = [
103+
for gateway in module.vpn_gateways : gateway
104+
]
105+
}
106+
```

main.tf

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,7 @@ locals {
433433
##############################################################################
434434
# Create VPN Gateways
435435
##############################################################################
436+
# ⚠️ [DEPRECATED]. Refer the [migration guide](https://github.com/terraform-ibm-modules/terraform-ibm-landing-zone-vpc/blob/main/docs/migration_guide.md) for more information.
436437

437438
locals {
438439
# Convert the vpn_gateway input from list to a map
@@ -454,4 +455,20 @@ resource "ibm_is_vpn_gateway" "vpn_gateway" {
454455
}
455456
}
456457

458+
# This block will be removed once the migration to the [terraform-ibm-site-to-site-vpn](https://github.com/terraform-ibm-modules/terraform-ibm-site-to-site-vpn) module is completed.
459+
460+
resource "terraform_data" "deprecation_warning" {
461+
462+
count = length(var.vpn_gateways) > 0 ? 1 : 0
463+
464+
triggers_replace = {
465+
always_run = timestamp()
466+
}
467+
provisioner "local-exec" {
468+
command = <<EOT
469+
echo "[WARNING] DEPRECATED variable 'vpn_gateways' is in use. Please migrate to the new variable.
470+
See migration guide: https://github.com/terraform-ibm-modules/terraform-ibm-landing-zone-vpc/blob/main/docs/migration_guide.md"
471+
EOT
472+
}
473+
}
457474
##############################################################################

outputs.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,15 +203,15 @@ output "dns_record_ids" {
203203
##############################################################################
204204

205205
output "vpn_gateways_name" {
206-
description = "List of names of VPN gateways."
206+
description = "[DEPRECATED] List of names of VPN gateways. For more information please refer the [migration guide](https://github.com/terraform-ibm-modules/terraform-ibm-landing-zone-vpc/blob/main/docs/migration_guide.md)."
207207
value = [
208208
for gateway in ibm_is_vpn_gateway.vpn_gateway :
209209
gateway.name
210210
]
211211
}
212212

213213
output "vpn_gateways_data" {
214-
description = "Details of VPN gateways data."
214+
description = "[DEPRECATED] Details of VPN gateways data. For more information please refer the [migration guide](https://github.com/terraform-ibm-modules/terraform-ibm-landing-zone-vpc/blob/main/docs/migration_guide.md)."
215215
value = [
216216
for gateway in ibm_is_vpn_gateway.vpn_gateway :
217217
gateway

tests/pr_test.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,16 @@ var dnsZoneMap = []map[string]interface{}{
5858
{"name": "slz.com"},
5959
}
6060

61+
var IgnoreUpdates = []string{
62+
"module.slz_vpc.terraform_data.deprecation_warning",
63+
"module.vpc.terraform_data.deprecation_warning[0]",
64+
}
65+
66+
var IgnoreDestroys = []string{
67+
"module.slz_vpc.terraform_data.deprecation_warning",
68+
"module.vpc.terraform_data.deprecation_warning[0]",
69+
}
70+
6171
func TestMain(m *testing.M) {
6272
// Read the YAML file contents
6373
var err error
@@ -78,6 +88,12 @@ func setupOptions(t *testing.T, prefix string, terraformDir string) *testhelper.
7888
TerraformVars: map[string]interface{}{
7989
"access_tags": permanentResources["accessTags"],
8090
},
91+
IgnoreUpdates: testhelper.Exemptions{ // Ignore for consistency check
92+
List: IgnoreUpdates,
93+
},
94+
IgnoreDestroys: testhelper.Exemptions{ // Ignore for consistency check
95+
List: IgnoreDestroys,
96+
},
8197
})
8298

8399
return options
@@ -280,6 +296,12 @@ func TestFullyConfigurableWithFlowLogs(t *testing.T) {
280296
DeleteWorkspaceOnFail: false,
281297
WaitJobCompleteMinutes: 120,
282298
TerraformVersion: terraformVersion,
299+
IgnoreUpdates: testhelper.Exemptions{ // Ignore for consistency check
300+
List: IgnoreUpdates,
301+
},
302+
IgnoreDestroys: testhelper.Exemptions{ // Ignore for consistency check
303+
List: IgnoreDestroys,
304+
},
283305
})
284306

285307
options.TerraformVars = []testschematic.TestSchematicTerraformVar{

variables.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -817,13 +817,13 @@ variable "dns_records" {
817817
##############################################################################
818818

819819
variable "vpn_gateways" {
820-
description = "List of VPN gateways to create."
820+
description = "[DEPRECATED] List of VPN gateways to create. For more information please refer the [migration guide](https://github.com/terraform-ibm-modules/terraform-ibm-landing-zone-vpc/blob/main/docs/migration_guide.md)."
821821
nullable = false
822822
type = list(
823823
object({
824824
name = string
825825
subnet_name = string # Do not include prefix, use same name as in `var.subnets`
826-
mode = optional(string)
826+
mode = optional(string, "route")
827827
resource_group = optional(string)
828828
access_tags = optional(list(string), [])
829829
})

0 commit comments

Comments
 (0)