Skip to content

Commit bc13ecc

Browse files
authored
feat(transitgateway): added option to enable or disable GRE enhanced route propagation (IBM-Cloud#6311)
* feat(transitgateway): added option to enable or disable GRE enhanced route propagation * feat(transitgateway): updated documentation for gre erp * fix(transitgateway): changes to support gre erp connection * fix(transitgateway): resolved merge conflicts for version changes * fix(transitgateway): addressed gre erp related review comments * fix(transitgateway): connection tunnel options change to set name using tunnel patch
1 parent 437fa94 commit bc13ecc

13 files changed

+124
-19
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ require (
2727
github.com/IBM/logs-go-sdk v0.4.0
2828
github.com/IBM/logs-router-go-sdk v1.0.8
2929
github.com/IBM/mqcloud-go-sdk v0.3.0
30-
github.com/IBM/networking-go-sdk v0.51.10
30+
github.com/IBM/networking-go-sdk v0.51.11
3131
github.com/IBM/platform-services-go-sdk v0.86.0
3232
github.com/IBM/project-go-sdk v0.3.5
3333
github.com/IBM/push-notifications-go-sdk v0.0.0-20210310100607-5790b96c47f5

go.sum

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,8 @@ github.com/IBM/logs-router-go-sdk v1.0.8 h1:MU1TdYNdVbvVTUXeqeYPItu6BoiSV/NMN49y
147147
github.com/IBM/logs-router-go-sdk v1.0.8/go.mod h1:tCN2vFgu5xG0ob9iJcxi5M4bJ6mWmu3nhmRPnvlwev0=
148148
github.com/IBM/mqcloud-go-sdk v0.3.0 h1:zuRe+lu6IwIzsBsmoVKZT4JgX+GxH5PJG06r5y5Xnh4=
149149
github.com/IBM/mqcloud-go-sdk v0.3.0/go.mod h1:7zigCUz6k3eRrNE8KOcDkY72oPppEmoQifF+SB0NPRM=
150-
github.com/IBM/networking-go-sdk v0.51.10 h1:7IKKU2U/kxd2xWDCuapkRdo91WwRT+5aRl5vwyiXKV8=
151-
github.com/IBM/networking-go-sdk v0.51.10/go.mod h1:iM2xvQYk6cG6ZED8+7iRqt/eKGFIAxy4/gYUdlFswMQ=
150+
github.com/IBM/networking-go-sdk v0.51.11 h1:l+yMXcO9GDcb7JU9jl8riUOXjnHTvIKSLnXYFlYlKXo=
151+
github.com/IBM/networking-go-sdk v0.51.11/go.mod h1:TAXWyBUk3C3R7aS1m84EfKdnDcBMZMAClwLfDj/SYZc=
152152
github.com/IBM/platform-services-go-sdk v0.86.0 h1:Uqne0Z/P9e++WfRt1aN8DD55kyo/T15+7EipYktRIDQ=
153153
github.com/IBM/platform-services-go-sdk v0.86.0/go.mod h1:aGD045m6I8pfcB77wft8w2cHqWOJjcM3YSSV55BX0Js=
154154
github.com/IBM/project-go-sdk v0.3.5 h1:L+YClFUa14foS0B/hOOY9n7sIdsT5/XQicnXOyJSpyM=
@@ -173,6 +173,8 @@ github.com/IBM/vpc-go-sdk v0.70.1 h1:6NsbRkiA5gDNxe7cjNx8Pi1j9s0PlhwNQj29wsKZxAo
173173
github.com/IBM/vpc-go-sdk v0.70.1/go.mod h1:K3vVlje72PYE3ZRt1iouE+jSIq+vCyYzT1HiFC06hUA=
174174
github.com/Logicalis/asn1 v0.0.0-20190312173541-d60463189a56 h1:vuquMR410psHNax14XKNWa0Ae/kYgWJcXi0IFuX60N0=
175175
github.com/Logicalis/asn1 v0.0.0-20190312173541-d60463189a56/go.mod h1:Zb3OT4l0mf7P/GOs2w2Ilj5sdm5Whoq3pa24dAEBHFc=
176+
github.com/Masterminds/semver/v3 v3.2.1 h1:RN9w6+7QoMeJVGyfmbcgs28Br8cvmnucEXnY0rYXWg0=
177+
github.com/Masterminds/semver/v3 v3.2.1/go.mod h1:qvl/7zhW3nngYb5+80sSMF+FG2BjYrf8m9wsX0PNOMQ=
176178
github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow=
177179
github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM=
178180
github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ=
@@ -980,8 +982,8 @@ github.com/onsi/ginkgo/v2 v2.8.1/go.mod h1:N1/NbDngAFcSLdyZ+/aYTYGSlq9qMCS/cNKGJ
980982
github.com/onsi/ginkgo/v2 v2.9.0/go.mod h1:4xkjoL/tZv4SMWeww56BU5kAt19mVB47gTWxmrTcxyk=
981983
github.com/onsi/ginkgo/v2 v2.9.1/go.mod h1:FEcmzVcCHl+4o9bQZVab+4dC9+j+91t2FHSzmGAPfuo=
982984
github.com/onsi/ginkgo/v2 v2.9.2/go.mod h1:WHcJJG2dIlcCqVfBAwUCrJxSPFb6v4azBwgxeMeDuts=
983-
github.com/onsi/ginkgo/v2 v2.23.4 h1:ktYTpKJAVZnDT4VjxSbiBenUjmlL/5QkBEocaWXiQus=
984-
github.com/onsi/ginkgo/v2 v2.23.4/go.mod h1:Bt66ApGPBFzHyR+JO10Zbt0Gsp4uWxu5mIOTusL46e8=
985+
github.com/onsi/ginkgo/v2 v2.25.1 h1:Fwp6crTREKM+oA6Cz4MsO8RhKQzs2/gOIVOUscMAfZY=
986+
github.com/onsi/ginkgo/v2 v2.25.1/go.mod h1:ppTWQ1dh9KM/F1XgpeRqelR+zHVwV81DGRSDnFxK7Sk=
985987
github.com/onsi/gomega v0.0.0-20170829124025-dcabb60a477c/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA=
986988
github.com/onsi/gomega v1.4.2/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
987989
github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=

ibm/service/transitgateway/data_source_ibm_tg_gateway.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ func DataSourceIBMTransitGateway() *schema.Resource {
4747
Type: schema.TypeBool,
4848
Computed: true,
4949
},
50+
tgGreEnhancedRoutePropagation: {
51+
Type: schema.TypeBool,
52+
Computed: true,
53+
},
5054
tgStatus: {
5155
Type: schema.TypeString,
5256
Computed: true,
@@ -253,6 +257,7 @@ func dataSourceIBMTransitGatewayRead(d *schema.ResourceData, meta interface{}) e
253257
d.Set(tgUpdatedAt, tgw.UpdatedAt.String())
254258
}
255259
d.Set(tgGlobal, tgw.Global)
260+
d.Set(tgGreEnhancedRoutePropagation, tgw.GreEnhancedRoutePropagation)
256261
d.Set(tgStatus, tgw.Status)
257262

258263
if tgw.ResourceGroup != nil {

ibm/service/transitgateway/data_source_ibm_tg_gateway_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ func TestAccIBMTransitGatewayDataSource_basic(t *testing.T) {
3131
"data.ibm_tg_gateway.test_tg_gateway", "name", gatewayname),
3232
resource.TestCheckResourceAttr(
3333
"data.ibm_tg_gateway.test_tg_gateway", "location", location),
34+
resource.TestCheckResourceAttr(
35+
"data.ibm_tg_gateway.test_tg_gateway", "gre_enhanced_route_propagation", "false"),
3436
),
3537
},
3638
{

ibm/service/transitgateway/data_source_ibm_tg_gateways.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ func DataSourceIBMTransitGateways() *schema.Resource {
4646
Type: schema.TypeBool,
4747
Computed: true,
4848
},
49+
tgGreEnhancedRoutePropagation: {
50+
Type: schema.TypeBool,
51+
Computed: true,
52+
},
4953
tgStatus: {
5054
Type: schema.TypeString,
5155
Computed: true,
@@ -92,6 +96,7 @@ func dataSourceIBMTransitGatewaysRead(d *schema.ResourceData, meta interface{})
9296
transitgateway[tgUpdatedAt] = instance.UpdatedAt.String()
9397
}
9498
transitgateway[tgGlobal] = instance.Global
99+
transitgateway[tgGreEnhancedRoutePropagation] = instance.GreEnhancedRoutePropagation
95100
transitgateway[tgCrn] = instance.Crn
96101

97102
if instance.ResourceGroup != nil {

ibm/service/transitgateway/data_source_ibm_tg_gateways_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ func TestAccIBMTransitGatewaysDataSource_basic(t *testing.T) {
3838
resource.TestCheckResourceAttrSet(resName, "transit_gateways.0.name"),
3939
resource.TestCheckResourceAttrSet(resName, "transit_gateways.0.location"),
4040
resource.TestCheckResourceAttrSet(resName, "transit_gateways.0.global"),
41+
resource.TestCheckResourceAttrSet(resName, "transit_gateways.0.gre_enhanced_route_propagation"),
4142
),
4243
},
4344
},

ibm/service/transitgateway/resource_ibm_tg_gateway.go

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,18 @@ import (
2020
)
2121

2222
const (
23-
tgGateways = "transit_gateways"
24-
tgResourceGroup = "resource_group"
25-
tgID = "id"
26-
tgCrn = "crn"
27-
tgName = "name"
28-
tgLocation = "location"
29-
tgCreatedAt = "created_at"
30-
tgGlobal = "global"
31-
tgStatus = "status"
32-
tgUpdatedAt = "updated_at"
33-
tgGatewayTags = "tags"
23+
tgGateways = "transit_gateways"
24+
tgResourceGroup = "resource_group"
25+
tgID = "id"
26+
tgCrn = "crn"
27+
tgName = "name"
28+
tgLocation = "location"
29+
tgCreatedAt = "created_at"
30+
tgGlobal = "global"
31+
tgGreEnhancedRoutePropagation = "gre_enhanced_route_propagation"
32+
tgStatus = "status"
33+
tgUpdatedAt = "updated_at"
34+
tgGatewayTags = "tags"
3435

3536
isTransitGatewayProvisioning = "provisioning"
3637
isTransitGatewayProvisioningDone = "done"
@@ -83,6 +84,14 @@ func ResourceIBMTransitGateway() *schema.Resource {
8384
Description: "Allow global routing for a Transit Gateway. If unspecified, the default value is false",
8485
},
8586

87+
tgGreEnhancedRoutePropagation: {
88+
Type: schema.TypeBool,
89+
Optional: true,
90+
ForceNew: false,
91+
Default: false,
92+
Description: "Allow route propagation across all GREs connected to the same transit gateway. This affects connections on the gateway of type redundant_gre, unbound_gre_tunnel and gre_tunnel",
93+
},
94+
8695
tgGatewayTags: {
8796
Type: schema.TypeSet,
8897
Optional: true,
@@ -193,12 +202,14 @@ func resourceIBMTransitGatewayCreate(d *schema.ResourceData, meta interface{}) e
193202
location := d.Get(tgLocation).(string)
194203
name := d.Get(tgName).(string)
195204
global := d.Get(tgGlobal).(bool)
205+
greEnhancedRoutePropagation := d.Get(tgGreEnhancedRoutePropagation).(bool)
196206

197207
createTransitGatewayOptions := &transitgatewayapisv1.CreateTransitGatewayOptions{}
198208

199209
createTransitGatewayOptions.Name = &name
200210
createTransitGatewayOptions.Location = &location
201211
createTransitGatewayOptions.Global = &global
212+
createTransitGatewayOptions.GreEnhancedRoutePropagation = &greEnhancedRoutePropagation
202213

203214
if rsg, ok := d.GetOk(tgResourceGroup); ok {
204215
resourceGroup := rsg.(string)
@@ -351,6 +362,10 @@ func resourceIBMTransitGatewayUpdate(d *schema.ResourceData, meta interface{}) e
351362
global := d.Get(tgGlobal).(bool)
352363
updateTransitGatewayOptions.Global = &global
353364
}
365+
if d.HasChange(tgGreEnhancedRoutePropagation) {
366+
greEnhancedRoutePropagation := d.Get(tgGreEnhancedRoutePropagation).(bool)
367+
updateTransitGatewayOptions.GreEnhancedRoutePropagation = &greEnhancedRoutePropagation
368+
}
354369
if d.HasChange(tgGatewayTags) {
355370
oldList, newList := d.GetChange(tgGatewayTags)
356371
err = flex.UpdateTagsUsingCRN(oldList, newList, meta, *tgw.Crn)

ibm/service/transitgateway/resource_ibm_tg_gateway_connection.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -368,14 +368,14 @@ func resourceIBMTransitGatewayConnectionCreate(d *schema.ResourceData, meta inte
368368
createTransitGatewayConnectionOptions.SetPrefixFiltersDefault(default_prefix_filter)
369369
}
370370

371-
tunnelCreateList := make([]transitgatewayapisv1.TransitGatewayRedundantGRETunnelTemplate, 0)
371+
tunnelCreateList := make([]transitgatewayapisv1.TransitGatewayTunnelTemplate, 0)
372372

373373
if _, ok := d.GetOk(tgrGREtunnels); ok {
374374
tunnelList := d.Get(tgrGREtunnels).(*schema.Set).List()
375375
for _, tunnel := range tunnelList {
376376
tunnelData := tunnel.(map[string]interface{})
377377

378-
tunnelTemplateModel := new(transitgatewayapisv1.TransitGatewayRedundantGRETunnelTemplate)
378+
tunnelTemplateModel := new(transitgatewayapisv1.TransitGatewayTunnelTemplate)
379379

380380
if _, ok := tunnelData[tgLocalGatewayIp]; ok {
381381
tunnelTemplateModel.LocalGatewayIp = NewStrPointer(tunnelData[tgLocalGatewayIp].(string))

ibm/service/transitgateway/resource_ibm_tg_gateway_connection_tunnel.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,10 @@ func resourceIBMTransitGatewayConnectionRgreTunnelUpdate(d *schema.ResourceData,
369369
if d.HasChange(tgconTunnelName) {
370370
if d.Get(tgconTunnelName) != nil {
371371
name := d.Get(tgconTunnelName).(string)
372-
updateTransitGatewayConnectionOptions.Name = &name
372+
gwTunnelPatch := map[string]interface{}{
373+
"name": &name,
374+
}
375+
updateTransitGatewayConnectionOptions.SetTransitGatewayTunnelPatch(gwTunnelPatch)
373376
}
374377
}
375378

ibm/service/transitgateway/resource_ibm_tg_gateway_test.go

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,63 @@ func TestAccIBMTransitGateway_globalUpdate(t *testing.T) {
9191
})
9292
}
9393

94+
func TestAccIBMTransitGateway_greERPUpdate(t *testing.T) {
95+
var instance string
96+
gatewayname := fmt.Sprintf("tg-gateway-name-%d", acctest.RandIntRange(10, 100))
97+
newgatewayname := fmt.Sprintf("newgateway-name-%d", acctest.RandIntRange(10, 100))
98+
location := "us-south"
99+
global := true
100+
greERPTrue := true
101+
greERPFalse := false
102+
resource.Test(t, resource.TestCase{
103+
PreCheck: func() { acc.TestAccPreCheck(t) },
104+
Providers: acc.TestAccProviders,
105+
CheckDestroy: testAccCheckIBMTransitGatewayDestroy, // Delete test case
106+
Steps: []resource.TestStep{
107+
{
108+
//Create test case
109+
Config: testAccCheckIBMTransitGatewayGreERPUpdateConfig(gatewayname, location, greERPTrue),
110+
Check: resource.ComposeTestCheckFunc(
111+
testAccCheckIBMTransitGatewayExists("ibm_tg_gateway.test_tg_gateway", instance),
112+
resource.TestCheckResourceAttr("ibm_tg_gateway.test_tg_gateway", "name", gatewayname),
113+
resource.TestCheckResourceAttr("ibm_tg_gateway.test_tg_gateway", "location", location),
114+
resource.TestCheckResourceAttr("ibm_tg_gateway.test_tg_gateway", "global", fmt.Sprintf("%t", global)),
115+
resource.TestCheckResourceAttr(
116+
"ibm_tg_gateway.test_tg_gateway",
117+
"gre_enhanced_route_propagation", fmt.Sprintf("%t", greERPTrue),
118+
),
119+
),
120+
},
121+
{
122+
//Update test case
123+
Config: testAccCheckIBMTransitGatewayGreERPUpdateConfig(newgatewayname, location, greERPFalse),
124+
Check: resource.ComposeTestCheckFunc(
125+
testAccCheckIBMTransitGatewayExists("ibm_tg_gateway.test_tg_gateway", instance),
126+
resource.TestCheckResourceAttr("ibm_tg_gateway.test_tg_gateway", "name", newgatewayname),
127+
resource.TestCheckResourceAttr("ibm_tg_gateway.test_tg_gateway", "global", fmt.Sprintf("%t", global)),
128+
resource.TestCheckResourceAttr(
129+
"ibm_tg_gateway.test_tg_gateway",
130+
"gre_enhanced_route_propagation", fmt.Sprintf("%t", greERPFalse),
131+
),
132+
),
133+
},
134+
{
135+
//Update test case
136+
Config: testAccCheckIBMTransitGatewayGreERPUpdateConfig(newgatewayname, location, greERPTrue),
137+
Check: resource.ComposeTestCheckFunc(
138+
testAccCheckIBMTransitGatewayExists("ibm_tg_gateway.test_tg_gateway", instance),
139+
resource.TestCheckResourceAttr("ibm_tg_gateway.test_tg_gateway", "name", newgatewayname),
140+
resource.TestCheckResourceAttr("ibm_tg_gateway.test_tg_gateway", "global", fmt.Sprintf("%t", global)),
141+
resource.TestCheckResourceAttr(
142+
"ibm_tg_gateway.test_tg_gateway",
143+
"gre_enhanced_route_propagation", fmt.Sprintf("%t", greERPTrue),
144+
),
145+
),
146+
},
147+
},
148+
})
149+
}
150+
94151
func testAccCheckIBMTransitGatewayConfig(gatewayname, location string) string {
95152
return fmt.Sprintf(`
96153
@@ -112,6 +169,18 @@ func testAccCheckIBMTransitGatewayGlobalUpdateConfig(gatewayname, location strin
112169
`, gatewayname, location, global)
113170
}
114171

172+
func testAccCheckIBMTransitGatewayGreERPUpdateConfig(gatewayname, location string, greerp bool) string {
173+
return fmt.Sprintf(`
174+
175+
resource "ibm_tg_gateway" "test_tg_gateway"{
176+
name="%s"
177+
location="%s"
178+
global=true
179+
gre_enhanced_route_propagation=%t
180+
}
181+
`, gatewayname, location, greerp)
182+
}
183+
115184
func testAccCheckIBMTransitGatewayExists(n string, instance string) resource.TestCheckFunc {
116185
return func(s *terraform.State) error {
117186
rs, ok := s.RootModule().Resources[n]

0 commit comments

Comments
 (0)