[英]Can Terraform create a Compute Engine on a defined IP Range?
I'm able to create a Compute Engine with either a:我可以使用以下任一方式创建 Compute Engine:
But I can't create a Compute Engine with a semi-dynamic address, ie the first 3 numbers being static but not the last one, eg 255.255.255.*但我无法创建一个具有半动态地址的计算引擎,即前 3 个数字是静态的但不是最后一个,例如 255.255.255.*
The Compute Engine is being created on a VPC whose IP address range is too wide for my requirements.计算引擎是在 VPC 上创建的,该 VPC 的 IP 地址范围对于我的要求来说太宽了。 I'm attempting to created all of my servers on a close range of IP addresses but I also don't want make each one static and have to maintain it in the Terraform code.
我试图在近距离的 IP 地址上创建我的所有服务器,但我也不希望每个服务器都是静态的,并且必须在 Terraform 代码中维护它。
Does anyone know a means to reserve and assign IP's in this restricted way?有没有人知道以这种受限方式保留和分配 IP 的方法?
The best fit I see for your need is to use the "Google Address Terraform Module", where you can define a list of ip addresses that match a list of instance names and assign the corresponding values.我认为最适合您的需求是使用“Google 地址 Terraform 模块”,您可以在其中定义与实例名称列表匹配的 IP 地址列表并分配相应的值。 Here, you can find a document describing the module and how to use it [1].
在这里,您可以找到描述该模块及其使用方法的文档 [1]。
Below, there is an example for the allocation of 3 ip addresses to different instances as a reference:下面以3个ip地址分配给不同实例为例,供参考:
module "address-fe" {
source = "terraform-google-modules/address/google"
version = "0.1.0"
subnetwork = "projects/gcp-network/regions/us-west1/subnetworks/dev-us-west1-dynamic"
names = [
"gusw1-dev-fooapp-fe-0001-a-001-ip",
"gusw1-dev-fooapp-fe-0001-a-002-ip",
"gusw1-dev-fooapp-fe-0001-a-003-ip"
]
addresses = [
"10.11.0.10",
"10.11.0.11",
"10.11.0.12"
]
}
[1] https://registry.terraform.io/modules/terraform-google-modules/address/google/latest [1] https://registry.terraform.io/modules/terraform-google-modules/address/google/latest
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.