gpt4 book ai didi

azure - 使用 Terraform 实现 Azure 应用程序安全组

转载 作者:行者123 更新时间:2023-12-03 01:42:23 25 4
gpt4 key购买 nike

应用程序安全组功能于四月份刚刚发布。我们正在尝试实现这一点,因为我们拥有大量服务器,因此网络安全组很快就会变得难以管理。

我找不到任何示例 Terraform 代码。我已经修改了 https://learn.microsoft.com/en-us/azure/virtual-machines/linux/terraform-create-complete-vm 中的示例 Terraform 代码快速进行 POC。场景是我们有一组堡垒服务器(目前只有 1 个),我们对其进行保护,并且所有重要服务器的 SSH 都将来自这些堡垒服务器。因此,我创建了一个 bastion_asg 应用程序安全组,并将 DL2staging_rtb_nsg 设置为仅允许来自 bastion_asg 的服务器进行 SSH 访问。然而,一旦它运行并创建了服务器,我就无法通过 ssh 进入 DL2staging_rtb_vm。我已附上我的代码。

非常感谢任何有关我的 POC 可能出现问题的指示。

谢谢

德里克

** 这是来自 https://learn.microsoft.com/en-us/azure/virtual-machines/linux/terraform-create-complete-vm 的示例 Terraform 代码中添加的主要代码:

resource "azurerm_network_security_group" "DL2staging_rtb_nsg" {
...

security_rule {
name = "AllowSSHInbound"
...
source_application_security_group_ids = ["${azurerm_application_security_group.bastion_asg.id}"]
destination_address_prefix = "*"
}

# Create network interface
resource "azurerm_network_interface" "DL2staging_rtb_nic" {
...

ip_configuration {
name = "DL2NicConfiguration"
...
application_security_group_ids = ["${azurerm_application_security_group.staging_sellsidertb_asg.id}"]
}

完整代码位于https://github.com/dl888888/azure-terraform-application-security-group/blob/master/vm3.tf

最佳答案

事实证明我的代码可以工作。我遇到的问题是假设 ASG(应用程序安全组)可以使用我拥有的虚拟机的公共(public) IP 地址。我通过 Azure 产品经理发现 ASG 仅适用于私有(private) IP 地址。这是 ASG 文档中的一个重大遗漏。

德里克

关于azure - 使用 Terraform 实现 Azure 应用程序安全组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51864181/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com