@@ -7,11 +7,43 @@ data "openstack_images_image_v2" "this" {
77 most_recent = true
88}
99
10+ data "openstack_networking_network_v2" "this" {
11+ name = " ${ var . network_name } "
12+ }
13+
14+ data "openstack_networking_secgroup_v2" "this" {
15+ count = " ${ length (var. security_group_names )} "
16+
17+ name = " ${ var . security_group_names [count . index ]} "
18+ }
19+
1020resource "openstack_compute_instance_v2" "this" {
1121 count = " ${ var . instance_count } "
1222
13- name = " ${ var . compute_name } -${ count . index } "
14- image_name = " ${ data . openstack_images_image_v2 . this . name } "
15- flavor_id = " ${ data . openstack_compute_flavor_v2 . this . id } "
16- key_pair = " ${ var . keypair } "
23+ name = " ${ var . instance_name } -${ count . index } "
24+ image_name = " ${ data . openstack_images_image_v2 . this . name } "
25+ flavor_id = " ${ data . openstack_compute_flavor_v2 . this . id } "
26+ key_pair = " ${ var . keypair } "
27+
28+ network {
29+ port = " ${ openstack_networking_port_v2 . this . * . id [count . index ]} "
30+ }
31+ }
32+
33+ resource "openstack_networking_port_v2" "this" {
34+ count = " ${ var . instance_count } "
35+
36+ name = " ${ var . network_name } -port-${ count . index } "
37+ network_id = " ${ data . openstack_networking_network_v2 . this . id } "
38+ admin_state_up = " true"
39+ security_group_ids = [" ${ data . openstack_networking_secgroup_v2 . this . * . id } " ]
1740}
41+
42+ # resource "openstack_compute_interface_attach_v2" "this" {
43+ # count = "${var.instance_count}"
44+
45+
46+ # instance_id = "${openstack_compute_instance_v2.this.*.id[count.index]}"
47+ # port_id = "${openstack_networking_port_v2.this.*.id[count.index]}"
48+ # }
49+
0 commit comments