我应该如何使用Terraform在OVH上创建一个专用网络/子网?如果使用ovh
提供商,则有一个与OpenStack(openstack_networking_subnet_v2
(和OVH特异性(ovh_publiccloud_private_network_subnet
(相关的公共资源。
我在问,因为当我遵循本指南时,我的私人网络接口不会在接口上分配IPv4-address(在此问题中似乎已经描述了相同的问题:OVH OpenStack上的Terraform的专用网络创建(。我可以看到Horizon Control-Panel中的IP-ADDR,但是当我使用Ext-Net IPv4 ADDR和类型ifconfig
SSH进行实例时,我看到没有为专用网络接口分配的IPv4 ADDR。接口已启动,但没有分配IPv4。我只是从这样的指南中使用Terraform代码:
# Create a private sub network
resource "ovh_publiccloud_private_network_subnet" "private_subnet" {
# Get the id of the resource ovh_publiccloud_private_network named
# private_network
network_id = "${ovh_publiccloud_private_network.private_network.id}"
project_id = "${var.project_id}" # With OS_TENANT_ID your tenant id's project
region = "WAW1" # With OS_REGION_NAME the OS_REGION_NAME environment variable
network = "192.168.42.0/24" # Global network
start = "192.168.42.2" # First IP for the subnet
end = "192.168.42.200" # Last IP for the subnet
dhcp = false # Deactivate the DHCP service
provider = "ovh.ovh" # Provider's name
}
resource "openstack_compute_instance_v2" "front" {
# Number of time the instance will be created
count = "${length(var.front_private_ip)}"
provider = "openstack.ovh" # Provider's name
name = "front" # Instance's name
flavor_name = "s1-2" # Flavor's name
image_name = "CoreOS Stable" # Image's name
key_pair = "${openstack_compute_keypair_v2.test_keypair.name}"
security_groups = ["default"] # Add into a security group
network = [
{
name = "Ext-Net" # Public interface name
}
,
{
# Private interface name
name = "${ovh_publiccloud_private_network.private_network.name}"
# Give an IP address depending on count.index
fixed_ip_v4 = "192.168.42.4"
}
]
}
,正如我所说的上面示例对我不起作用(因为我必须在界面上手动分配私有的IPv4-ADDR,而我希望Terraform为我做到这一点(。然后,我在OVH Github上发现了Terraform-ovh-ovh-publicCloud网络模块。尝试了此仓库中的简单示例(从readme复制(,我可以看到bastion节点上的第二个接口获取IPv4 ADDR成功从私有净范围分配了。从模块的代码中,我还可以看到openstack_networking_subnet_v2
资源使用而不是特定于OVH的ovh_publiccloud_private_network_subnet
?为什么它们之间有什么区别?当我从头开始编写自己的Terraform定义时,我应该使用哪一个?
我的目标是创建一个专用网络/子网并创建一个带有两个接口的计算实例(连接到public Ext-Net
和我刚创建的私有子网(。如果您有这样的经验,请为我提供一个简短的工作示例,或者让我知道我是否缺少某些东西。
您可以以$ 800的价格从OVH租用A/24个公共IP。但是你必须先这样做。