Open framctr opened 1 month ago
This is especially problematic, as openstack_compute_floatingip_associate_v2
is deprecated, but the suggested openstack_networking_floatingip_associate_v2
only works with a port ID (same for openstack_networking_floatingip_v2
and directly assigning it to an instance using a port ID).
I also tried to query the port ID using a separate data source query after the instance is created, but the string for the port ID of my test instance openstack_compute_instance_v2.terraform-instance-1.network[0].port
stays "".
Consequently, openstack_compute_floatingip_associate_v2
(though deprecated) seems to be the only option to assign a floating IP to an instance currently.
i had a quick check and this doesnt seem to be an easy fix.
to the extend that it is possible i would recommend to have a separate port resource and use that on the instance resource. This should alleviate the above issue. So:
resource "openstack_networking_network_v2" "network_1" {
name = "network_1"
admin_state_up = "true"
}
resource "openstack_networking_subnet_v2" "subnet_1" {
name = "subnet_1"
network_id = openstack_networking_network_v2.network_1.id
cidr = "192.168.199.0/24"
}
resource "openstack_networking_port_v2" "port_1" {
name = "port_1"
network_id = openstack_networking_network_v2.network_1.id
admin_state_up = "true"
security_group_ids = []
fixed_ip {
subnet_id = openstack_networking_subnet_v2.subnet_1.id
}
}
resource "openstack_compute_instance_v2" "basic" {
name = "basic"
image_id = "ad091b52-742f-469e-8f3c-fd81cadf0743"
flavor_id = "3"
key_pair = "my_key_pair_name"
network {
port = openstack_networking_port_v2.port_1.id
}
}
Yes, I was already doing it in the way @nikParasyr suggested.
At this point, I was thinking if it would be easier and more maintenable to detach the network block from the instance resource, leaving only a port_ids
input for the resource, and force users using the openstack_networking_port
resource. This will maybe simplify code and keep things working. The only issue I see is that the port
resource does not accept network_name
as input, but only network_id
, while the instance accepts both. For example, I give unique names to my networks and I have modules accepting a network name as an input variable.
I would also say that the deprecation of the openstack_compute_floatingip_associate_v2
resource creates a bit of confusion on users because there is no documentation on how to replace it with the networking resources
I would also say that the deprecation of the
openstack_compute_floatingip_associate_v2
resource creates a bit of confusion on users because there is no documentation on how to replace it with the networking resources
we'll try to fix this within #1741
Terraform Version
Terraform v1.7.2
Affected Resource(s)
Terraform Configuration Files
Expected Behavior
The output should show the port ID of the instance
Actual Behavior
No output (port value is
null
).