Terraform - 创建 OpenStack 负载均衡器时出错:找不到资源
Terraform - Error creating OpenStack loadbalancer: Resource not found
我正在尝试使用 Terraform 创建 OpenStack 负载平衡器,但在 terraform apply
时出现以下错误:
Error: Error creating openstack_lb_loadbalancer_v2: Resource not found
on load-balancer/main.tf line 71, in resource
"openstack_lb_loadbalancer_v2" "lb_1": 71: resource
"openstack_lb_loadbalancer_v2" "lb_1" {
我的模板如下所示。
resource "openstack_lb_loadbalancer_v2" "lb_1" {
name = "loadbalancer"
vip_subnet_id = openstack_networking_subnet_v2.public.id
}
resource "openstack_lb_listener_v2" "listener_1" {
name = "https"
protocol = "TERMINATED_HTTPS"
protocol_port = 443
loadbalancer_id = openstack_lb_loadbalancer_v2.lb_1.id
default_tls_container_ref = openstack_keymanager_container_v1.tls_1.container_ref
}
resource "openstack_networking_network_v2" "lb_network" {
name = "lb-network"
port_security_enabled = "true"
}
resource "openstack_networking_subnet_v2" "public" {
name = "lb-subnet"
network_id = openstack_networking_network_v2.lb_network.id
cidr = "10.0.0.0/24"
ip_version = 4
}
我不知道如何进一步调试。这是否意味着找不到 vip_subnet_id
?还是 openstack_lb_loadbalancer_v2
未知资源类型?
我正在使用 Terraform v0.13.5 和 terraform-provider-openstack v1.33.0。
更新
我通过 Web 界面手动创建了一个 LB,现在我尝试通过 Terraform CLI 导入它并得到以下响应
Error: Cannot import non-existent remote object
While attempting to import an existing object to
openstack_lb_loadbalancer_v2.lb_1, the provider detected that no
object exists with the given id. Only pre-existing objects can be
imported; check that the id is correct and that it is associated with
the provider's configured region or endpoint, or use "terraform apply"
to create a new remote object for this resource.
我开始怀疑这可能是OpenStack服务器端的问题。
终于发现您需要在 openstack terraform 提供程序设置中设置 use_octiva = true
。请在此处查看相关文档:https://registry.terraform.io/providers/terraform-provider-openstack/openstack/latest/docs#use_octavia
示例配置:
cat main.tf
provider "openstack" {
user_name = var.os_user_name
tenant_name = var.os_tenant_name
password = var.os_password
auth_url = var.os_auth_url
region = var.os_region
endpoint_type = var.os_endpoint_type
use_octavia = true
}
这是相关的错误报告:https://github.com/terraform-provider-openstack/terraform-provider-openstack/issues/1100
我正在尝试使用 Terraform 创建 OpenStack 负载平衡器,但在 terraform apply
时出现以下错误:
Error: Error creating openstack_lb_loadbalancer_v2: Resource not found
on load-balancer/main.tf line 71, in resource "openstack_lb_loadbalancer_v2" "lb_1": 71: resource "openstack_lb_loadbalancer_v2" "lb_1" {
我的模板如下所示。
resource "openstack_lb_loadbalancer_v2" "lb_1" {
name = "loadbalancer"
vip_subnet_id = openstack_networking_subnet_v2.public.id
}
resource "openstack_lb_listener_v2" "listener_1" {
name = "https"
protocol = "TERMINATED_HTTPS"
protocol_port = 443
loadbalancer_id = openstack_lb_loadbalancer_v2.lb_1.id
default_tls_container_ref = openstack_keymanager_container_v1.tls_1.container_ref
}
resource "openstack_networking_network_v2" "lb_network" {
name = "lb-network"
port_security_enabled = "true"
}
resource "openstack_networking_subnet_v2" "public" {
name = "lb-subnet"
network_id = openstack_networking_network_v2.lb_network.id
cidr = "10.0.0.0/24"
ip_version = 4
}
我不知道如何进一步调试。这是否意味着找不到 vip_subnet_id
?还是 openstack_lb_loadbalancer_v2
未知资源类型?
我正在使用 Terraform v0.13.5 和 terraform-provider-openstack v1.33.0。
更新
我通过 Web 界面手动创建了一个 LB,现在我尝试通过 Terraform CLI 导入它并得到以下响应
Error: Cannot import non-existent remote object
While attempting to import an existing object to openstack_lb_loadbalancer_v2.lb_1, the provider detected that no object exists with the given id. Only pre-existing objects can be imported; check that the id is correct and that it is associated with the provider's configured region or endpoint, or use "terraform apply" to create a new remote object for this resource.
我开始怀疑这可能是OpenStack服务器端的问题。
终于发现您需要在 openstack terraform 提供程序设置中设置 use_octiva = true
。请在此处查看相关文档:https://registry.terraform.io/providers/terraform-provider-openstack/openstack/latest/docs#use_octavia
示例配置:
cat main.tf
provider "openstack" {
user_name = var.os_user_name
tenant_name = var.os_tenant_name
password = var.os_password
auth_url = var.os_auth_url
region = var.os_region
endpoint_type = var.os_endpoint_type
use_octavia = true
}
这是相关的错误报告:https://github.com/terraform-provider-openstack/terraform-provider-openstack/issues/1100