我正在使用 Terraform azurerm 提供程序版本 1.19 创建 AKS 集群。我想在创建集群时指定网络安全组规则,但我不知道如何引用创建的安全组,因为生成的安全组被赋予了带有随机数的名称。
就像是:
aks-agentpool-33577837-nsg
有没有办法引用创建的 nsg 或至少输出名称中使用的随机数?
创建集群的配置:
resource "azurerm_resource_group" "k8s" {
name = "${var.resource_group_name}"
location = "${var.location}"
}
resource "azurerm_kubernetes_cluster" "k8s" {
name = "${var.cluster_name}"
location = "${azurerm_resource_group.k8s.location}"
resource_group_name = "${azurerm_resource_group.k8s.name}"
dns_prefix = "${var.dns_prefix}"
kubernetes_version = "${var.kubernetes_version}"
linux_profile {
admin_username = "azureuser"
ssh_key {
key_data = "${file("${var.ssh_public_key}")}"
}
}
agent_pool_profile {
name = "default"
count = "${var.agent_count}"
vm_size = "${var.vm_size}"
os_type = "Linux"
}
service_principal {
client_id = "${var.client_id}"
client_secret = "${var.client_secret}"
} …Run Code Online (Sandbox Code Playgroud)