我有一个“ create_vm”模块,用于创建VM以及存储帐户,NIC等。>
我的要求是我想将IP地址列表从根模块传递到create_vm模块,以便任何人都可以根据自己的要求限制与VM的绑定连接。纠正我,我未对模块使用正确的术语。
目录结构如下:
subscription_1 subscription_2 Modules README.md ./subscription_1: ./subscription_2: main.tf sqlvm.tf.bak terraform.tfstate terraform.tfstate.backup variables.tf ./Modules: create_vm ./Modules/create_vm: main.tf variable.tf
cat ./Modules/create_vm/main.tf
resource "azurerm_network_security_rule" "tf-nsr-5986" { ... source_address_prefixes = "${var.allowed_source_ips}" ... }
cat ./Modules/create_vm/variable.tf
variable "allowed_source_ips" { description = "List of ips from which inbound connection to VMs is allowed" type = "list" }
在根模块中使用cat ./subscription_2/main.tf
module "vm_app" { ... allowed_source_ips = "${var.ip_list}" ... }
cat ./subscription_2/variable.tf
variable "ip_list" { description = "List of ips from which inbound connection to VMs is allowed" type = "list" }
现在,通过传递参数,我从本地vm运行terraform,与在Azure DevOps管道上完全一样。
terraform plan -var "resource_group_name=nxt-grp-prd-manage-rgp-au-se" -var "virtual_network_name=virtual_network_1" -var "sql_subnet_name=subnet_1" -var "app_subnet_name=subnet_2" -var "application_nsg=test_nsg" -var "count_vm=2" -var "sql_host_basename=sqlvms" -var "app_host_basename=appvms" -var "storage_account_suffix=sta" -var "virtual_machine_size=Standard_B1ms" -var "virtual_machine_image_publisher=MicrosoftWindowsServer" -var "virtual_machine_image_offer=WindowsServer" -var "virtual_machine_image_sku=2012-R2-Datacenter" -var "virtual_machine_image_version=latest" -var "username=devopsadmin" -var "password=Angular12#$%" -var "ip_list="a.b.c.d","p.q.r.s","x.y.z.l""
不幸的是,我收到如下错误消息:
Error: Invalid number literal on <value for var.ip_list> line 1: (source code not available) Failed to recognize the value of this number literal. Error: Extra characters after expression on <value for var.ip_list> line 1: (source code not available) An expression was successfully parsed, but extra characters were found after it.
以前有人解决过这种挑战吗?不太确定为什么会抱怨,我给出的方式与之前在create_vm模块中给出的方式相同。
任何帮助将不胜感激。
我有一个“ create_vm”模块,用于创建VM以及存储帐户,NIC等。我的要求是我想将根目录模块的IP地址列表传递给create_vm模块,以便任何人都可以限制绑定...