forked from ovh/terraform-provider-ovh
-
Notifications
You must be signed in to change notification settings - Fork 0
/
data_cloud_project_gateway_interface_test.go
115 lines (99 loc) · 3.8 KB
/
data_cloud_project_gateway_interface_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
package ovh
import (
"fmt"
"os"
"testing"
"github.com/hashicorp/terraform-plugin-testing/helper/acctest"
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
)
var testAccCloudProjectGatewayInterfaceDataSourceConfig = `
data "ovh_me" "myaccount" {}
data "ovh_order_cart" "mycart" {
ovh_subsidiary = data.ovh_me.myaccount.ovh_subsidiary
}
data "ovh_order_cart_product_plan" "cloud" {
cart_id = data.ovh_order_cart.mycart.id
price_capacity = "renew"
product = "cloud"
plan_code = "project.2018"
}
resource "ovh_cloud_project" "cloud" {
ovh_subsidiary = data.ovh_order_cart.mycart.ovh_subsidiary
description = "Cloud project for gateway interface test"
plan {
duration = data.ovh_order_cart_product_plan.cloud.selected_price.0.duration
plan_code = data.ovh_order_cart_product_plan.cloud.plan_code
pricing_mode = data.ovh_order_cart_product_plan.cloud.selected_price.0.pricing_mode
}
}
resource "ovh_vrack_cloudproject" "attach" {
service_name = "%s"
project_id = ovh_cloud_project.cloud.project_id
}
resource "ovh_cloud_project_network_private" "mypriv" {
service_name = ovh_vrack_cloudproject.attach.project_id
vlan_id = "%d"
name = "%s"
regions = ["GRA11"]
}
resource "ovh_cloud_project_network_private_subnet" "myprivsub" {
service_name = ovh_cloud_project_network_private.mypriv.service_name
network_id = ovh_cloud_project_network_private.mypriv.id
region = "GRA11"
start = "10.0.0.2"
end = "10.0.0.8"
network = "10.0.0.0/24"
dhcp = true
}
resource "ovh_cloud_project_network_private_subnet" "my_other_privsub" {
service_name = ovh_cloud_project_network_private.mypriv.service_name
network_id = ovh_cloud_project_network_private.mypriv.id
region = "GRA11"
start = "10.0.1.10"
end = "10.0.1.254"
network = "10.0.1.0/24"
dhcp = true
}
resource "ovh_cloud_project_gateway" "gateway" {
service_name = ovh_cloud_project_network_private.mypriv.service_name
name = "%s"
model = "s"
region = ovh_cloud_project_network_private_subnet.myprivsub.region
network_id = tolist(ovh_cloud_project_network_private.mypriv.regions_attributes[*].openstackid)[0]
subnet_id = ovh_cloud_project_network_private_subnet.myprivsub.id
}
resource "ovh_cloud_project_gateway_interface" "interface" {
service_name = ovh_cloud_project_network_private.mypriv.service_name
region = ovh_cloud_project_network_private_subnet.my_other_privsub.region
id = ovh_cloud_project_gateway.gateway.id
subnet_id = ovh_cloud_project_network_private_subnet.my_other_privsub.id
}
data "ovh_cloud_project_gateway_interface" "interface" {
service_name = ovh_cloud_project_gateway_interface.interface.service_name
region = ovh_cloud_project_gateway_interface.interface.region
id = ovh_cloud_project_gateway_interface.interface.id
interface_id = ovh_cloud_project_gateway_interface.interface.interface_id
}
`
func TestAccCloudProjectGatewayInterfaceDataSource_basic(t *testing.T) {
config := fmt.Sprintf(
testAccCloudProjectGatewayInterfaceDataSourceConfig,
os.Getenv("OVH_VRACK_SERVICE_TEST"),
acctest.RandIntRange(100, 200),
acctest.RandomWithPrefix(test_prefix),
acctest.RandomWithPrefix(test_prefix),
)
resource.Test(t, resource.TestCase{
ProtoV6ProviderFactories: testAccProtoV6ProviderFactories,
Steps: []resource.TestStep{
{
Config: config,
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrSet("data.ovh_cloud_project_gateway_interface.interface", "ip"),
resource.TestCheckResourceAttrSet("data.ovh_cloud_project_gateway_interface.interface", "subnet_id"),
resource.TestCheckResourceAttrSet("data.ovh_cloud_project_gateway_interface.interface", "network_id"),
),
},
},
})
}