Skip to content

Commit 2577b90

Browse files
ajay-malhotra1hkantare
authored andcommitted
feat: adding MD5 authentication key for Direct link Resources, DataSources and Documents
1 parent ea91d84 commit 2577b90

9 files changed

+55
-1
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ website/vendor
2828
*.attach
2929
*.xml
3030
*.old
31+
vendor/
3132

3233
# Test exclusions
3334
!command/test-fixtures/**/*.tfstate

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ require (
1616
github.com/IBM/ibm-cos-sdk-go v1.7.0
1717
github.com/IBM/ibm-cos-sdk-go-config v1.2.0
1818
github.com/IBM/keyprotect-go-client v0.7.0
19-
github.com/IBM/networking-go-sdk v0.17.0
19+
github.com/IBM/networking-go-sdk v0.18.0
2020
github.com/IBM/platform-services-go-sdk v0.18.16
2121
github.com/IBM/push-notifications-go-sdk v0.0.0-20210310100607-5790b96c47f5
2222
github.com/IBM/schematics-go-sdk v0.0.2

go.sum

+2
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ github.com/IBM/keyprotect-go-client v0.7.0 h1:JstSHD14Lp6ihwQseyPuGcs1AjOBjAmcis
7272
github.com/IBM/keyprotect-go-client v0.7.0/go.mod h1:SVr2ylV/fhSQPDiUjWirN9fsyWFCNNbt8GIT8hPJVjE=
7373
github.com/IBM/networking-go-sdk v0.17.0 h1:AkP0aFX8ZfkHT7LDUOD1DtcImZWXqrlTr5eHlCgDcC4=
7474
github.com/IBM/networking-go-sdk v0.17.0/go.mod h1:nViqUm1Bv+ke8dyOhjQ6e+2U1XeqZX2y4bQbR8Od3Hc=
75+
github.com/IBM/networking-go-sdk v0.18.0 h1:mlALxXptnoDGviRW59ZQTyCr4PgTdQKp/5ksh2NM6Sk=
76+
github.com/IBM/networking-go-sdk v0.18.0/go.mod h1:nViqUm1Bv+ke8dyOhjQ6e+2U1XeqZX2y4bQbR8Od3Hc=
7577
github.com/IBM/platform-services-go-sdk v0.18.16 h1:blYycstPoNtPKtu1uZe240WvzcJENy/Lzx+HMUA8bOo=
7678
github.com/IBM/platform-services-go-sdk v0.18.16/go.mod h1:awc7TZUeGMlToSeMSaWEz34Knf0lQnuGWumcI4pcuoM=
7779
github.com/IBM/push-notifications-go-sdk v0.0.0-20210310100607-5790b96c47f5 h1:NPUhkoOCRuv3OFWt19PmwjXGGTKlvmbuPg9fUrBUNe4=

ibm/data_source_ibm_dl_gateway.go

+9
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,11 @@ func dataSourceIBMDLGateway() *schema.Resource {
7373
},
7474
},
7575

76+
dlAuthenticationKey: {
77+
Type: schema.TypeString,
78+
Computed: true,
79+
Description: "BGP MD5 authentication key",
80+
},
7681
dlBgpAsn: {
7782
Type: schema.TypeInt,
7883
Computed: true,
@@ -456,6 +461,10 @@ func dataSourceIBMDLGatewayRead(d *schema.ResourceData, meta interface{}) error
456461
d.Set(dlResourceGroup, *rg.ID)
457462
}
458463

464+
if instance.AuthenticationKey != nil {
465+
d.Set(dlAuthenticationKey, *instance.AuthenticationKey.Crn)
466+
}
467+
459468
}
460469
}
461470

ibm/data_source_ibm_dl_gateways.go

+10
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ func dataSourceIBMDLGateways() *schema.Resource {
3131
Computed: true,
3232
Description: "Id of the data source gateways",
3333
},
34+
dlAuthenticationKey: {
35+
Type: schema.TypeString,
36+
Computed: true,
37+
Description: "BGP MD5 authentication key",
38+
},
3439
dlBgpAsn: {
3540
Type: schema.TypeInt,
3641
Computed: true,
@@ -368,6 +373,11 @@ func dataSourceIBMDLGatewaysRead(d *schema.ResourceData, meta interface{}) error
368373
gatewayChangeRequest := gatewayChangeRequestIntf.(*directlinkv1.GatewayChangeRequest)
369374
gateway[dlChangeRequest] = *gatewayChangeRequest.Type
370375
}
376+
377+
if instance.AuthenticationKey != nil {
378+
gateway[dlAuthenticationKey] = *instance.AuthenticationKey.Crn
379+
}
380+
371381
gateways = append(gateways, gateway)
372382
}
373383
d.SetId(dataSourceIBMDLGatewaysID(d))

ibm/resource_ibm_dl_gateway.go

+29
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ const (
6060
dlGatewayProvisioning = "configuring"
6161
dlGatewayProvisioningDone = "provisioned"
6262
dlGatewayProvisioningRejected = "create_rejected"
63+
dlAuthenticationKey = "authentication_key"
6364
)
6465

6566
func resourceIBMDLGateway() *schema.Resource {
@@ -84,6 +85,12 @@ func resourceIBMDLGateway() *schema.Resource {
8485
),
8586

8687
Schema: map[string]*schema.Schema{
88+
dlAuthenticationKey: {
89+
Type: schema.TypeString,
90+
Optional: true,
91+
ForceNew: false,
92+
Description: "BGP MD5 authentication key",
93+
},
8794
dlBgpAsn: {
8895
Type: schema.TypeInt,
8996
Required: true,
@@ -503,6 +510,12 @@ func resourceIBMdlGatewayCreate(d *schema.ResourceData, meta interface{}) error
503510
}
504511
gatewayDedicatedTemplateModel.MacsecConfig = gatewayMacsecConfigTemplateModel
505512
}
513+
514+
if authKeyCrn, ok := d.GetOk(dlAuthenticationKey); ok {
515+
authKeyCrnStr := authKeyCrn.(string)
516+
gatewayDedicatedTemplateModel.AuthenticationKey = &directlinkv1.GatewayTemplateAuthenticationKey{Crn: &authKeyCrnStr}
517+
}
518+
506519
createGatewayOptionsModel.GatewayTemplate = gatewayDedicatedTemplateModel
507520

508521
} else if dtype == "connect" {
@@ -533,6 +546,12 @@ func resourceIBMdlGatewayCreate(d *schema.ResourceData, meta interface{}) error
533546
gatewayConnectTemplateModel.ResourceGroup = &directlinkv1.ResourceGroupIdentity{ID: &resourceGroup}
534547

535548
}
549+
550+
if authKeyCrn, ok := d.GetOk(dlAuthenticationKey); ok {
551+
authKeyCrnStr := authKeyCrn.(string)
552+
gatewayConnectTemplateModel.AuthenticationKey = &directlinkv1.GatewayTemplateAuthenticationKey{Crn: &authKeyCrnStr}
553+
}
554+
536555
createGatewayOptionsModel.GatewayTemplate = gatewayConnectTemplateModel
537556

538557
} else {
@@ -666,6 +685,9 @@ func resourceIBMdlGatewayRead(d *schema.ResourceData, meta interface{}) error {
666685
if instance.CreatedAt != nil {
667686
d.Set(dlCreatedAt, instance.CreatedAt.String())
668687
}
688+
if instance.AuthenticationKey != nil {
689+
d.Set(dlAuthenticationKey, *instance.AuthenticationKey.Crn)
690+
}
669691
if dtype == "dedicated" {
670692
if instance.MacsecConfig != nil {
671693
macsecList := make([]map[string]interface{}, 0)
@@ -835,6 +857,13 @@ func resourceIBMdlGatewayUpdate(d *schema.ResourceData, meta interface{}) error
835857
metered := d.Get(dlMetered).(bool)
836858
updateGatewayOptionsModel.Metered = &metered
837859
}
860+
if d.HasChange(dlAuthenticationKey) {
861+
authenticationKeyCrn := d.Get(dlAuthenticationKey).(string)
862+
authenticationKeyPatchTemplate := new(directlinkv1.GatewayPatchTemplateAuthenticationKey)
863+
authenticationKeyPatchTemplate.Crn = &authenticationKeyCrn
864+
updateGatewayOptionsModel = updateGatewayOptionsModel.SetAuthenticationKey(authenticationKeyPatchTemplate)
865+
}
866+
838867
if dtype == "dedicated" {
839868
if d.HasChange(dlMacSecConfig) && !d.IsNewResource() {
840869
// Construct an instance of the GatewayMacsecConfigTemplate model

website/docs/d/dl_gateway.html.markdown

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ Review the argument reference that you can specify for your resource.
2929
## Attribute reference
3030
In addition to the argument reference list, you can access the following attribute references after your data source is created.
3131

32+
- `authentication_key` - (String) BGP MD5 authentication key.
3233
- `bgp_asn` - (String) Customer BGP ASN.
3334
- `bgp_base_cidr` - (String) The BGP base CIDR.
3435
- `bgp_cer_cidr` - (String) The BGP customer edge router CIDR.

website/docs/d/dl_gateways.html.markdown

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ You can access the following attribute references after your data source is crea
2929
- `gateways` - (String) List of all the Direct Link Gateways in the IBM Cloud infrastructure.
3030

3131
Nested scheme for `gateways`:
32+
- `authentication_key` - (String) BGP MD5 authentication key.
3233
- `bgp_asn` - (String) Customer BGP ASN.
3334
- `bgp_base_cidr` - (String) The BGP base CIDR.
3435
- `bgp_cer_cidr` - (String) The BGP customer edge router CIDR.

website/docs/r/dl_gateway.html.markdown

+1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ resource "ibm_dl_gateway" "test_dl_connect" {
5858
## Argument reference
5959
Review the argument reference that you can specify for your resource.
6060

61+
- `authentication_key` - (Optional, String) BGP MD5 authentication key.
6162
- `bgp_asn`- (Required, Forces new resource, Integer) The BGP ASN of the gateway to be created. For example, `64999`.
6263
- `bgp_base_cidr` - (Optional, String) (Deprecated) The BGP base CIDR of the gateway to be created. See `bgp_ibm_cidr` and `bgp_cer_cidr` for details on how to create a gateway by using automatic or explicit IP assignment. Any `bgp_base_cidr` value set will be ignored.
6364
- `bgp_cer_cidr` - (Optional, Forces new resource, String) The BGP customer edge router CIDR. Specify a value within `bgp_base_cidr`. For auto IP assignment, omit `bgp_cer_cidr` and `bgp_ibm_cidr`. IBM will automatically select values for `bgp_cer_cidr` and `bgp_ibm_cidr`.

0 commit comments

Comments
 (0)