Skip to content

Commit b8f8408

Browse files
SnehaKamat1Sneha Kamat
andauthored
Feat: Transit gateway support for Vmaas Terraform (IBM-Cloud#6377)
* feat: update vmware service Signed-off-by: Sneha Kamat <[email protected]> * Feat: fix testcase Signed-off-by: Sneha Kamat <[email protected]> * fix: terraform fmt and update test removed Signed-off-by: Sneha Kamat <[email protected]> * fix: accept_language changes Signed-off-by: Sneha Kamat <[email protected]> * fix: update api patch Signed-off-by: Sneha Kamat <[email protected]> * fix: remove the unwanted optional Signed-off-by: Sneha Kamat <[email protected]> * updated readme Signed-off-by: Sneha Kamat <[email protected]> * FeatD: transit gateway support for vmaas provider Signed-off-by: Sneha Kamat <[email protected]> * fix: testcases Signed-off-by: Sneha Kamat <[email protected]> * Datasource test fix for tgw Signed-off-by: Sneha Kamat <[email protected]> * fix: removed unwanted code and review fixes Signed-off-by: Sneha Kamat <[email protected]> * fix: tgw_id added Signed-off-by: Sneha Kamat <[email protected]> * fix: added required fields in documentation Signed-off-by: Sneha Kamat <[email protected]> * fix:update function fix Signed-off-by: Sneha Kamat <[email protected]> * fix:update delete Signed-off-by: Sneha Kamat <[email protected]> * fix: removed update function Signed-off-by: Sneha Kamat <[email protected]> * fix: change documentation Signed-off-by: Sneha Kamat <[email protected]> --------- Signed-off-by: Sneha Kamat <[email protected]> Co-authored-by: Sneha Kamat <[email protected]>
1 parent 0c6110e commit b8f8408

12 files changed

+1469
-3
lines changed

examples/ibm-vmware/README.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,36 @@ resource "ibm_vmaas_vdc" "vmaas_vdc_instance" {
6868
| status | Determines the state of the virtual data center. |
6969
| type | Determines whether this virtual data center is in a single-tenant or multitenant Cloud Director site. |
7070

71+
### Resource: ibm_vmaas_transit_gateway_connection
72+
73+
```hcl
74+
resource "ibm_vmaas_transit_gateway_connection" "vmaas_transit_gateway_connection_instance" {
75+
vdc_id = var.vmaas_transit_gateway_connection_vdc_id
76+
edge_id = var.vmaas_transit_gateway_connection_edge_id
77+
region = var.vmaas_transit_gateway_connection_region
78+
vmaas_transit_gateway_connection_id = var.vmaas_transit_gateway_connection_id
79+
}
80+
```
81+
82+
#### Inputs
83+
84+
| Name | Description | Type | Required |
85+
|------|-------------|------|---------|
86+
| ibmcloud\_api\_key | IBM Cloud API key | `string` | true |
87+
| vdc_id | A unique ID for a virtual data center. | `string` | true |
88+
| edge_id | A unique ID for an edge. | `string` | true |
89+
| region | The region where the IBM Transit Gateway is deployed. | `string` | false |
90+
| vmaas_transit_gateway_connection_id | A unique ID for an IBM Transit Gateway. | `string` | true |
91+
92+
#### Outputs
93+
94+
| Name | Description |
95+
|------|-------------|
96+
| connections | IBM Transit Gateway connections. |
97+
| status | Determines the state of the IBM Transit Gateway based on its connections. |
98+
| vmaas_transit_gateway_connection_id | A unique ID for an IBM Transit Gateway. |
99+
100+
71101
## VMware Cloud Foundation as a Service API data sources
72102

73103
### Data source: ibm_vmaas_vdc
@@ -110,6 +140,28 @@ data "ibm_vmaas_vdc" "vmaas_vdc_instance" {
110140
| windows_byol | Indicates if the Microsoft Windows VMs will be using the license from IBM or the customer will use their own license (BYOL). |
111141
| director_site | The Cloud Director site in which to deploy the virtual data center (VDC). |
112142

143+
### Data source: ibm_vmaas_transit_gateway_connection
144+
145+
```hcl
146+
data "ibm_vmaas_transit_gateway_connection" "vmaas_transit_gateway_connection_instance" {
147+
vmaas_transit_gateway_connection_id = var.data_vmaas_transit_gateway_connection_vmaas_transit_gateway_connection_id
148+
}
149+
```
150+
151+
#### Inputs
152+
153+
| Name | Description | Type | Required |
154+
|------|-------------|------|---------|
155+
| vmaas_transit_gateway_connection_id | A unique ID for a specified virtual data center. | `string` | true |
156+
157+
#### Outputs
158+
159+
| Name | Description |
160+
|------|-------------|
161+
| connections | IBM Transit Gateway connections. |
162+
| status | Determines the state of the IBM Transit Gateway based on its connections. |
163+
| region | The region where the IBM Transit Gateway is deployed. |
164+
113165
## Assumptions
114166

115167
1. TODO

examples/ibm-vmware/main.tf

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@ resource "ibm_vmaas_vdc" "vmaas_vdc_instance" {
2323
}
2424
}
2525

26+
// Provision vmaas_transit_gateway_connection resource instance
27+
resource "ibm_vmaas_transit_gateway_connection" "vmaas_transit_gateway_connection_instance" {
28+
vmaas_transit_gateway_connection_id = var.vmaas_transit_gateway_connection_id
29+
vdc_id = var.vmaas_transit_gateway_connection_vdc_id
30+
edge_id = var.vmaas_transit_gateway_connection_edge_id
31+
region = var.vmaas_transit_gateway_connection_region
32+
}
33+
2634
// Data source is not linked to a resource instance
2735
// Uncomment if an existing data source instance exists
2836
/*
@@ -32,3 +40,11 @@ data "ibm_vmaas_vdc" "vmaas_vdc_instance" {
3240
accept_language = var.data_vmaas_vdc_accept_language
3341
}
3442
*/
43+
// Data source is not linked to a resource instance
44+
// Uncomment if an existing data source instance exists
45+
/*
46+
// Create vmaas_transit_gateway_connection data source
47+
data "ibm_vmaas_transit_gateway_connection" "vmaas_transit_gateway_connection_instance" {
48+
vmaas_transit_gateway_connection_id = var.data_vmaas_transit_gateway_connection_vmaas_transit_gateway_connection_id
49+
}
50+
*/

examples/ibm-vmware/outputs.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,9 @@ output "ibm_vmaas_vdc" {
44
value = ibm_vmaas_vdc.vmaas_vdc_instance
55
description = "vmaas_vdc resource instance"
66
}
7+
// This output allows vmaas_transit_gateway_connection data to be referenced by other resources and the terraform CLI
8+
// Modify this output if only certain data should be exposed
9+
output "ibm_vmaas_transit_gateway_connection" {
10+
value = ibm_vmaas_transit_gateway_connection.vmaas_transit_gateway_connection_instance
11+
description = "vmaas_transit_gateway_connection resource instance"
12+
}

examples/ibm-vmware/variables.tf

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,30 @@ variable "vmaas_vdc_windows_byol" {
4040
default = true
4141
}
4242

43+
// Resource arguments for vmaas_transit_gateway_connection
44+
variable "vmaas_transit_gateway_connection_vdc_id" {
45+
description = "A unique ID for a virtual data center."
46+
type = string
47+
default = "vdc_id"
48+
}
49+
variable "vmaas_transit_gateway_connection_edge_id" {
50+
description = "A unique ID for an edge."
51+
type = string
52+
default = "edge_id"
53+
}
54+
variable "vmaas_transit_gateway_connection_id" {
55+
description = "A unique ID for a transit gateway."
56+
type = string
57+
default = "tgw_id"
58+
}
59+
60+
variable "vmaas_transit_gateway_connection_region" {
61+
description = "The region where the IBM Transit Gateway is deployed."
62+
type = string
63+
default = "jp-tok"
64+
}
65+
66+
4367
// Data source arguments for vmaas_vdc
4468
variable "data_vmaas_vdc_vmaas_vdc_id" {
4569
description = "A unique ID for a specified virtual data center."
@@ -51,3 +75,10 @@ variable "data_vmaas_vdc_accept_language" {
5175
type = string
5276
default = "en-us"
5377
}
78+
79+
// Data source arguments for vmaas_transit_gateway_connection
80+
variable "data_vmaas_transit_gateway_connection_vmaas_transit_gateway_connection_id" {
81+
description = "A unique ID for a specified virtual data center."
82+
type = string
83+
default = "vdc_id"
84+
}

ibm/acctest/acctest.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,9 @@ var (
425425
var (
426426
Vmaas_Directorsite_id string
427427
Vmaas_Directorsite_pvdc_id string
428+
Vmaas_edge_id string
429+
Vmaas_transit_gateway_id string
430+
Vmaas_vdc_id string
428431
)
429432

430433
// For IAM Access Management
@@ -2103,6 +2106,21 @@ func init() {
21032106
fmt.Println("[WARN] Set the environment variable IBM_VMAAS_DS_PVDC_ID for testing ibm_vmaas_vdc resource else tests will fail if this is not set correctly")
21042107
}
21052108

2109+
Vmaas_edge_id = os.Getenv("IBM_VMAAS_EDGE_ID")
2110+
if Vmaas_edge_id == "" {
2111+
fmt.Println("[INFO] Set the environment variable IBM_VMAAS_EDGE_ID for testing ibm_vmaas_vdc resource else tests will fail if this is not set correctly")
2112+
}
2113+
2114+
Vmaas_transit_gateway_id = os.Getenv("IBM_VMAAS_TRANSIT_GATEWAY_ID")
2115+
if Vmaas_transit_gateway_id == "" {
2116+
fmt.Println("[INFO] Set the environment variable IBM_VMAAS_TRANSIT_GATEWAY_ID for testing ibm_vmaas_vdc resource else tests will fail if this is not set correctly")
2117+
}
2118+
2119+
Vmaas_vdc_id = os.Getenv("IBM_VMAAS_VDC_ID")
2120+
if Vmaas_vdc_id == "" {
2121+
fmt.Println("[INFO] Set the environment variable IBM_VMAAS_VDC_ID for testing ibm_vmaas_vdc resource else tests will fail if this is not set correctly")
2122+
}
2123+
21062124
TargetAccountId = os.Getenv("IBM_POLICY_ASSIGNMENT_TARGET_ACCOUNT_ID")
21072125
if TargetAccountId == "" {
21082126
fmt.Println("[INFO] Set the environment variable IBM_POLICY_ASSIGNMENT_TARGET_ACCOUNT_ID for testing ibm_iam_policy_assignment resource else tests will fail if this is not set correctly")
@@ -2484,6 +2502,20 @@ func TestAccPreCheckVMwareService(t *testing.T) {
24842502
t.Fatal("IBM_VMAAS_DS_PVDC_ID must be set for acceptance tests")
24852503
}
24862504
}
2505+
func TestAccPreCheckVMwareTGWService(t *testing.T) {
2506+
if v := os.Getenv("IC_API_KEY"); v == "" {
2507+
t.Fatal("IC_API_KEY must be set for acceptance tests")
2508+
}
2509+
if Vmaas_edge_id == "" {
2510+
t.Fatal("IBM_VMAAS_EDGE_ID must be set for acceptance tests")
2511+
}
2512+
if Vmaas_transit_gateway_id == "" {
2513+
t.Fatal("IBM_VMAAS_TRANSIT_GATEWAY_ID must be set for acceptance tests")
2514+
}
2515+
if Vmaas_vdc_id == "" {
2516+
t.Fatal("IBM_VMAAS_VDC_ID must be set for acceptance tests")
2517+
}
2518+
}
24872519

24882520
func TestAccPreCheckPartnerCenterSell(t *testing.T) {
24892521
TestAccPreCheck(t)

ibm/provider/provider.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1069,7 +1069,9 @@ func Provider() *schema.Provider {
10691069
"ibm_project_environment": project.DataSourceIbmProjectEnvironment(),
10701070

10711071
// Added for VMware as a Service
1072-
"ibm_vmaas_vdc": vmware.DataSourceIbmVmaasVdc(),
1072+
"ibm_vmaas_vdc": vmware.DataSourceIbmVmaasVdc(),
1073+
"ibm_vmaas_transit_gateway_connection": vmware.DataSourceIbmVmaasTransitGatewayConnection(),
1074+
10731075
// Logs Service
10741076
"ibm_logs_alert": logs.AddLogsInstanceFields(logs.DataSourceIbmLogsAlert()),
10751077
"ibm_logs_alerts": logs.AddLogsInstanceFields(logs.DataSourceIbmLogsAlerts()),
@@ -1745,7 +1747,9 @@ func Provider() *schema.Provider {
17451747
"ibm_project_environment": project.ResourceIbmProjectEnvironment(),
17461748

17471749
// Added for VMware as a Service
1748-
"ibm_vmaas_vdc": vmware.ResourceIbmVmaasVdc(),
1750+
"ibm_vmaas_vdc": vmware.ResourceIbmVmaasVdc(),
1751+
"ibm_vmaas_transit_gateway_connection": vmware.ResourceIbmVmaasTransitGatewayConnection(),
1752+
17491753
// Logs Service
17501754
"ibm_logs_alert": logs.AddLogsInstanceFields(logs.ResourceIbmLogsAlert()),
17511755
"ibm_logs_rule_group": logs.AddLogsInstanceFields(logs.ResourceIbmLogsRuleGroup()),
@@ -2253,7 +2257,9 @@ func Validator() validate.ValidatorDict {
22532257
"ibm_en_destination_custom_email": eventnotification.ResourceIBMEnEmailDestinationValidator(),
22542258

22552259
// Added for VMware as a Service
2256-
"ibm_vmaas_vdc": vmware.ResourceIbmVmaasVdcValidator(),
2260+
"ibm_vmaas_vdc": vmware.ResourceIbmVmaasVdcValidator(),
2261+
"ibm_vmaas_transit_gateway_connection": vmware.ResourceIbmVmaasTransitGatewayConnectionValidator(),
2262+
22572263
"ibm_logs_alert": logs.ResourceIbmLogsAlertValidator(),
22582264
"ibm_logs_rule_group": logs.ResourceIbmLogsRuleGroupValidator(),
22592265
"ibm_logs_outgoing_webhook": logs.ResourceIbmLogsOutgoingWebhookValidator(),

0 commit comments

Comments
 (0)