@@ -4,12 +4,35 @@ provider gcore {
4
4
gcore_platform = " http://api.stg-45.staging.gcdn.co"
5
5
gcore_api = " http://10.100.179.92:33081"
6
6
}
7
+ resource "gcore_network" "network" {
8
+ name = " network_example"
9
+ mtu = 1450
10
+ type = " vxlan"
11
+ region_id = 1
12
+ project_id = 1
13
+ }
14
+
15
+ resource "gcore_subnet" "subnet" {
16
+ name = " subnet_example"
17
+ cidr = " 192.168.10.0/24"
18
+ network_id = gcore_network. network . id
19
+ dns_nameservers = [" 8.8.4.4" , " 1.1.1.1" ]
20
+
21
+ host_routes {
22
+ destination = " 10.0.3.0/24"
23
+ nexthop = " 10.0.0.13"
24
+ }
25
+
26
+ gateway_ip = " 192.168.10.1"
27
+ region_id = 1
28
+ project_id = 1
29
+ }
7
30
8
31
resource "gcore_volume" "first_volume" {
9
32
name = " boot volume"
10
33
type_name = " ssd_hiiops"
11
34
size = 5
12
- image_id = " f3847215-e4d7-4e64-8e69-14637e68e27f "
35
+ image_id = " f4ce3d30-e29c-4cfd-811f-46f383b6081f "
13
36
region_id = 1
14
37
project_id = 1
15
38
}
@@ -22,65 +45,50 @@ resource "gcore_volume" "second_volume" {
22
45
project_id = 1
23
46
}
24
47
25
- locals {
26
- volumes_ids = [gcore_volume . first_volume . id , gcore_volume . second_volume . id ]
27
- }
28
-
29
48
resource "gcore_instance" "instance" {
30
49
flavor_id = " g1-standard-2-4"
31
- name = var . names
50
+ name = " test "
32
51
33
- dynamic volumes {
34
- iterator = vol
35
- for_each = local. volumes_ids
36
- content {
37
- boot_index = index (local. volumes_ids , vol. value )
52
+ volume {
38
53
source = " existing-volume"
39
- volume_id = vol . value
40
- }
54
+ volume_id = gcore_volume . first_volume . id
55
+ boot_index = 0
41
56
}
42
57
43
- dynamic interfaces {
44
- iterator = iface
45
- for_each = var. interfaces
46
- content {
47
- type = iface. value . type
48
- network_id = iface. value . network_id
49
- subnet_id = iface. value . subnet_id
50
- fip_source = iface. value . fip_source
51
- existing_fip_id = iface. value . existing_fip_id
52
- port_id = iface. value . port_id
53
- ip_address = iface. value . ip_address
54
- }
58
+ volume {
59
+ source = " existing-volume"
60
+ volume_id = gcore_volume. second_volume . id
61
+ boot_index = 1
55
62
}
56
63
57
- dynamic security_groups {
58
- iterator = sg
59
- for_each = var. security_groups
60
- content {
61
- id = sg. value . id
62
- name = sg. value . name
63
- }
64
+ interface {
65
+ type = " subnet"
66
+ network_id = gcore_network. network . id
67
+ subnet_id = gcore_subnet. subnet . id
68
+ // port_id = null
69
+ // ip_address = null
70
+ // fip_source = null
71
+ // existing_fip_id = null
64
72
}
65
73
66
- dynamic metadata {
67
- iterator = md
68
- for_each = var. metadata
69
- content {
70
- key = md. value . key
71
- value = md. value . value
72
- }
74
+
75
+ security_group {
76
+ id = " d75db0b2-58f1-4a11-88c6-a932bb897310"
77
+ name = " default"
73
78
}
74
79
75
- dynamic configuration {
76
- iterator = cfg
77
- for_each = var. configuration
78
- content {
79
- key = cfg. value . key
80
- value = cfg. value . value
81
- }
80
+ metadata {
81
+ key = " some_key"
82
+ value = " some_data"
83
+ }
84
+
85
+ configuration {
86
+ key = " some_key"
87
+ value = " some_data"
82
88
}
83
89
84
90
region_id = 1
85
91
project_id = 1
86
- }
92
+ }
93
+
94
+
0 commit comments