Skip to content

Commit b50e5db

Browse files
authored
Fix: Fixed TGW-146 Terraform: some lines in logs are useless when create RGRE connection (IBM-Cloud#6143)
* fix: minor tweak dependency: none * fix: minor tweak 2 dependency: none * fix: minor tweak 3 dependency: none * fix: minor tweak 3 dependency: none * fix: minor tweak 3 dependency: none
1 parent ba73e26 commit b50e5db

File tree

2 files changed

+299
-6
lines changed

2 files changed

+299
-6
lines changed
Lines changed: 296 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,296 @@
1+
2+
# Terraform IBM Local Development Guide
3+
4+
This guide outlines how to build, install, and test a **local build** of the IBM Terraform Provider. It supports working against the STG environment.
5+
6+
---
7+
8+
## Environment Setup (STG)
9+
10+
Before running Terraform, set the following environment variables:
11+
12+
```bash
13+
#!/bin/sh
14+
export IBMCLOUD_ACCOUNT_MANAGEMENT_API_ENDPOINT=https://accountmanagement.stage1.ng.bluemix.net
15+
export IBMCLOUD_CF_API_ENDPOINT=https://api.stage1.ng.bluemix.net
16+
export IBMCLOUD_CS_API_ENDPOINT=https://containers.test.cloud.ibm.com/global
17+
export IBMCLOUD_CR_API_ENDPOINT=https://registry.stage1.ng.bluemix.net
18+
export IBMCLOUD_CIS_API_ENDPOINT=https://api.cis.test.cloud.ibm.com
19+
export IBMCLOUD_GS_API_ENDPOINT=https://api.global-search-tagging.test.cloud.ibm.com
20+
export IBMCLOUD_IAMPAP_API_ENDPOINT=https://iam.test.cloud.ibm.com
21+
export IBMCLOUD_ICD_API_ENDPOINT=https://api.us-south.databases.test.cloud.ibm.com
22+
export IBMCLOUD_MCCP_API_ENDPOINT=https://mccp.us-south.cf.test.cloud.ibm.com
23+
export IBMCLOUD_UAA_ENDPOINT=https://login.stage1.ng.bluemix.net/UAALoginServerWAR
24+
export IBMCLOUD_COS_ENDPOINT=https://s3.us-west.cloud-object-storage.test.appdomain.cloud
25+
export IBMCLOUD_COS_CONFIG_ENDPOINT=https://config.cloud-object-storage.test.cloud.ibm.com/v1
26+
27+
export IBMCLOUD_IAM_API_ENDPOINT=https://iam.test.cloud.ibm.com
28+
export IBMCLOUD_RESOURCE_CONTROLLER_API_ENDPOINT=https://resource-controller.test.cloud.ibm.com
29+
export IBMCLOUD_RESOURCE_CATALOG_API_ENDPOINT=https://globalcatalog.test.cloud.ibm.com
30+
export IBMCLOUD_RESOURCE_MANAGEMENT_API_ENDPOINT=https://resource-controller.test.cloud.ibm.com
31+
export IBMCLOUD_GT_API_ENDPOINT=https://tags.global-search-tagging.test.cloud.ibm.com
32+
export IBMCLOUD_IS_NG_API_ENDPOINT=https://us-south-stage01.iaasdev.cloud.ibm.com/v1
33+
export IBMCLOUD_TG_API_ENDPOINT=https://transit.test.cloud.ibm.com/v1
34+
export IBMCLOUD_API_KEY=**********
35+
```
36+
37+
---
38+
39+
## Local Build Setup (One Time Only)
40+
41+
### Step 1: Build the Provider
42+
```bash
43+
cd ~/go/src/github.ibm.com/CloudBBS/terraform-provider-ibm
44+
make build
45+
```
46+
47+
### Step 2: Create Local Plugin Directory
48+
```bash
49+
mkdir -p ~/.terraform.d/plugins/registry.terraform.io/ibm-cloud/ibm/1.77.1/darwin_amd64
50+
```
51+
52+
### Step 3: Copy the Binary
53+
```bash
54+
cp ~/go/bin/terraform-provider-ibm ~/.terraform.d/plugins/registry.terraform.io/ibm-cloud/ibm/1.77.1/darwin_amd64/terraform-provider-ibm_v1.77.1
55+
chmod +x ~/.terraform.d/plugins/registry.terraform.io/ibm-cloud/ibm/1.77.1/darwin_amd64/terraform-provider-ibm_v1.77.1
56+
```
57+
58+
### Step 4: Update Your Terraform CLI Config
59+
Edit `~/.terraformrc`:
60+
61+
```hcl
62+
provider_installation {
63+
filesystem_mirror {
64+
path = "/Users/<your_username>/.terraform.d/plugins/"
65+
include = ["ibm-cloud/ibm"]
66+
}
67+
direct {
68+
include = ["*/*"]
69+
}
70+
}
71+
```
72+
73+
---
74+
75+
## Rebuild
76+
77+
```bash
78+
cd ~/go/src/github.ibm.com/CloudBBS/terraform-provider-ibm
79+
make build
80+
cp ~/go/bin/terraform-provider-ibm ~/.terraform.d/plugins/registry.terraform.io/ibm-cloud/ibm/1.77.1/darwin_amd64/terraform-provider-ibm_v1.77.1
81+
chmod +x ~/.terraform.d/plugins/registry.terraform.io/ibm-cloud/ibm/1.77.1/darwin_amd64/terraform-provider-ibm_v1.77.1
82+
```
83+
84+
Then navigate into terraform-provider-ibm/ibm/service/transitgateway and run Terraform:
85+
```bash
86+
terraform init
87+
terraform plan
88+
terraform apply
89+
```
90+
91+
```
92+
93+
Notice: Run the below command to output more details:
94+
```
95+
TF_LOG=DEBUG terraform plan | tee plan.log
96+
```
97+
98+
If your logs show your custom build debug lines, the local binary is working.
99+
100+
---
101+
102+
## Troubleshooting
103+
104+
**Problem:**
105+
```text
106+
Error while installing ibm-cloud/ibm v1.77.1: the local package doesn't match any checksums
107+
```
108+
109+
**Fix:**
110+
```bash
111+
rm .terraform.lock.hcl
112+
terraform init
113+
```
114+
115+
---
116+
117+
Keep this file around to save your future self HOURS of headbanging. 🤘
118+
119+
120+
# Examples:
121+
Create a Gateway and a Redundant GRE Connection
122+
123+
```
124+
terraform {
125+
required_providers {
126+
ibm = {
127+
source = "ibm-cloud/ibm"
128+
version = "1.77.1"
129+
}
130+
time = {
131+
source = "hashicorp/time"
132+
version = "0.9.1"
133+
}
134+
}
135+
}
136+
137+
variable "region" {
138+
default = "us-south"
139+
description = "The VPC Region that you want your VPC, Transit Gateway and PDNS to be provisioned it. To list available regions, run `ibmcloud is regions`."
140+
}
141+
142+
# Provider block - Alias initialized to interact with VNF Experiment account
143+
##############################################################################
144+
provider "ibm" {
145+
ibmcloud_api_key = "**YourAPIKey**"
146+
region = var.region
147+
ibmcloud_timeout = 300
148+
}
149+
150+
151+
# Create the Transit Gateway
152+
resource "ibm_tg_gateway" "new_tg_gw" {
153+
name = "gw-terraform"
154+
location = "us-south"
155+
global = true
156+
}
157+
158+
# Create RGRE connection using existing gateway
159+
resource "ibm_tg_connection" "test_ibm_tg_connection" {
160+
gateway = data.ibm_tg_gateway.existing_tg_gw.id
161+
network_type = "redundant_gre"
162+
name = "rgre-terraform"
163+
base_network_type = "classic"
164+
165+
tunnels {
166+
local_gateway_ip = "192.193.200.1"
167+
local_tunnel_ip = "192.193.239.2"
168+
name = "tunne1_terraform"
169+
remote_gateway_ip = "10.144.104.123"
170+
remote_tunnel_ip = "192.193.239.1"
171+
zone = "us-south-1"
172+
}
173+
174+
tunnels {
175+
local_gateway_ip = "192.193.201.1"
176+
local_tunnel_ip = "192.193.238.2"
177+
name = "tunne2_terraform"
178+
remote_gateway_ip = "10.144.104.123"
179+
remote_tunnel_ip = "192.193.238.1"
180+
zone = "us-south-1"
181+
}
182+
}
183+
184+
```
185+
186+
# Example 2: Create a Redundant GRE connection on an existing Gateway
187+
```
188+
189+
terraform {
190+
required_providers {
191+
ibm = {
192+
source = "ibm-cloud/ibm"
193+
version = "1.77.1"
194+
}
195+
time = {
196+
source = "hashicorp/time"
197+
version = "0.9.1"
198+
}
199+
}
200+
}
201+
202+
variable "region" {
203+
default = "us-south"
204+
description = "The VPC Region that you want your VPC, Transit Gateway and PDNS to be provisioned it. To list available regions, run `ibmcloud is regions`."
205+
}
206+
207+
# Provider block - Alias initialized to interact with VNF Experiment account
208+
##############################################################################
209+
provider "ibm" {
210+
ibmcloud_api_key = "**YourAPIKey**"
211+
region = var.region
212+
ibmcloud_timeout = 300
213+
}
214+
215+
216+
# Look up existing TG gateway
217+
data "ibm_tg_gateway" "existing_tg_gw" {
218+
name = "gw-terraform"
219+
}
220+
221+
# Create RGRE connection using existing gateway
222+
resource "ibm_tg_connection" "test_ibm_tg_connection" {
223+
gateway = data.ibm_tg_gateway.existing_tg_gw.id
224+
network_type = "redundant_gre"
225+
name = "rgre-terraform"
226+
base_network_type = "classic"
227+
228+
tunnels {
229+
local_gateway_ip = "192.193.200.1"
230+
local_tunnel_ip = "192.193.239.2"
231+
name = "tunne1_terraform"
232+
remote_gateway_ip = "10.144.104.123"
233+
remote_tunnel_ip = "192.193.239.1"
234+
zone = "us-south-1"
235+
}
236+
237+
tunnels {
238+
local_gateway_ip = "192.193.201.1"
239+
local_tunnel_ip = "192.193.238.2"
240+
name = "tunne2_terraform"
241+
remote_gateway_ip = "10.144.104.123"
242+
remote_tunnel_ip = "192.193.238.1"
243+
zone = "us-south-1"
244+
}
245+
}
246+
```
247+
248+
249+
250+
## Example 3. Create a Classic connection
251+
```
252+
253+
terraform {
254+
required_providers {
255+
ibm = {
256+
source = "ibm-cloud/ibm"
257+
version = "1.77.1"
258+
}
259+
time = {
260+
source = "hashicorp/time"
261+
version = "0.9.1"
262+
}
263+
}
264+
}
265+
266+
variable "region" {
267+
default = "us-south"
268+
description = "The VPC Region that you want your VPC, Transit Gateway and PDNS to be provisioned it. To list available regions, run `ibmcloud is regions`."
269+
}
270+
271+
# Provider block - Alias initialized to interact with VNF Experiment account
272+
##############################################################################
273+
provider "ibm" {
274+
ibmcloud_api_key = "**YourAPIKey**"
275+
region = var.region
276+
ibmcloud_timeout = 300
277+
}
278+
279+
280+
# Look up existing TG gateway
281+
data "ibm_tg_gateway" "existing_tg_gw" {
282+
name = "gw-terraform"
283+
}
284+
285+
# Create RGRE connection using existing gateway
286+
resource "ibm_tg_connection" "test_ibm_tg_connection" {
287+
gateway = data.ibm_tg_gateway.existing_tg_gw.id
288+
network_type = "classic"
289+
name = "classic-terraform"
290+
local_gateway_ip = "192.193.200.1"
291+
local_tunnel_ip = "192.193.239.2"
292+
remote_gateway_ip = "10.144.104.123"
293+
remote_tunnel_ip = "192.193.239.1"
294+
zone = "us-south-1"
295+
}
296+
```

ibm/service/transitgateway/resource_ibm_tg_gateway_connection.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ func ResourceIBMTransitGatewayConnection() *schema.Resource {
6262
Update: schema.DefaultTimeout(10 * time.Minute),
6363
},
6464

65+
// Excluded Computed:true to suppress parent-level rendering for RGRE; handled in tunnel blocks only.
66+
// Affected fields: local_gateway_ip, local_tunnel_ip, remote_bgp_asn,
67+
// remote_gateway_ip, remote_tunnel_ip, zone.
6568
Schema: map[string]*schema.Schema{
6669
tgGatewayId: {
6770
Type: schema.TypeString,
@@ -118,42 +121,36 @@ func ResourceIBMTransitGatewayConnection() *schema.Resource {
118121
tgLocalGatewayIp: {
119122
Type: schema.TypeString,
120123
Optional: true,
121-
Computed: true,
122124
ForceNew: true,
123125
Description: "The local gateway IP address. This field only applies to network type 'gre_tunnel' and 'unbound_gre_tunnel' connections.",
124126
},
125127
tgLocalTunnelIp: {
126128
Type: schema.TypeString,
127129
Optional: true,
128-
Computed: true,
129130
ForceNew: true,
130131
Description: "The local tunnel IP address. This field only applies to network type 'gre_tunnel' and 'unbound_gre_tunnel' connections.",
131132
},
132133
tgRemoteBgpAsn: {
133134
Type: schema.TypeInt,
134135
Optional: true,
135-
Computed: true,
136136
ForceNew: true,
137137
Description: "The remote network BGP ASN. This field only applies to network type 'gre_tunnel' and 'unbound_gre_tunnel' connections.",
138138
},
139139
tgRemoteGatewayIp: {
140140
Type: schema.TypeString,
141141
Optional: true,
142-
Computed: true,
143142
ForceNew: true,
144143
Description: "The remote gateway IP address. This field only applies to network type 'gre_tunnel' and 'unbound_gre_tunnel' connections.",
145144
},
146145
tgRemoteTunnelIp: {
147146
Type: schema.TypeString,
148147
Optional: true,
149-
Computed: true,
150148
ForceNew: true,
151149
Description: "The remote tunnel IP address. This field only applies to network type 'gre_tunnel' and 'unbound_gre_tunnel' connections.",
152150
},
153151
tgZone: {
154152
Type: schema.TypeString,
155153
Optional: true,
156-
Computed: true,
157154
ForceNew: true,
158155
Description: "Location of GRE tunnel. This field only applies to network type 'gre_tunnel' and 'unbound_gre_tunnel' connections.",
159156
},

0 commit comments

Comments
 (0)