Azure Network Interface Application Security Group Association

This page shows how to write Terraform and Azure Resource Manager for Network Interface Application Security Group Association and write them securely.

azurerm_network_interface_application_security_group_association (Terraform)

The Interface Application Security Group Association in Network can be configured in Terraform with the resource name azurerm_network_interface_application_security_group_association. The following sections describe 10 examples of how to use the resource and its parameters.

Example Usage from GitHub

app_sec_grp_assos.tf#L2
resource "azurerm_network_interface_application_security_group_association" "bastions" {
  count                         = var.bastions_amount
  network_interface_id          = azurerm_network_interface.bastions.*.id[count.index]
  ip_configuration_name         = azurerm_network_interface.bastions.*.ip_configuration.0.name[count.index]
  application_security_group_id = azurerm_application_security_group.bastions.id
}
security.tf#L2
resource "azurerm_network_interface_application_security_group_association" "ask_issue_asg" {
  network_interface_id          = azurerm_network_interface.issuer.id
  application_security_group_id = data.terraform_remote_state.networks.outputs.asg_ask_issue_id
}

resource "azurerm_network_interface_application_security_group_association" "behind_proxy_asg" {
security.tf#L2
resource "azurerm_network_interface_application_security_group_association" "ask_issue_asg" {
  network_interface_id          = azurerm_network_interface.issuer.id
  application_security_group_id = data.terraform_remote_state.networks.outputs.asg_ask_issue_id
}

resource "azurerm_network_interface_application_security_group_association" "web_proxy_asg" {
main.tf#L1
resource "azurerm_network_interface_application_security_group_association" "multiasgassociation" {
 for_each =  var.multiasgassociation_settings
  network_interface_id  = each.value.network_interface_id
  application_security_group_id = each.value.resource_group_name

security_group.tf#L7
resource "azurerm_network_interface_application_security_group_association" "pks-nic-asg-assoc" {
  count                         = var.master_asg == "" ? 0 : length(var.master_nics)
  network_interface_id          = data.azurerm_network_interface.pks-master-nics[count.index].id
  application_security_group_id = data.azurerm_application_security_group.pks-master-asg[0].id
}
asg_associations.tf#L1
resource "azurerm_network_interface_application_security_group_association" "asg" {
  application_security_group_id = var.application_security_group_id
  network_interface_id          = var.network_interface_id
}
main.tf#L7
resource "azurerm_network_interface_application_security_group_association" "nic_asg_assoc" {
  count                         = var.asg_associate ? 1 : 0
  application_security_group_id = azurerm_application_security_group.asg.id
  network_interface_id          = var.network_interface_id
asg_associations.tf#L1
resource "azurerm_network_interface_application_security_group_association" "asg" {
  application_security_group_id = var.application_security_group_id
  network_interface_id          = var.network_interface_id
}
security.tf#L2
resource "azurerm_network_interface_application_security_group_association" "issuer_asg" {
  network_interface_id          = azurerm_network_interface.ca_issuer.id
  application_security_group_id = data.terraform_remote_state.networks.outputs.asg_issuer_id
}
application_security_group.tf#L1
resource "azurerm_network_interface_application_security_group_association" "assoc" {
  for_each = local.nic_asg

  network_interface_id          = azurerm_network_interface.nic[each.value.nic_key].id
  application_security_group_id = each.value.asg_id
}

Review your Terraform file for Azure best practices

Shisho Cloud, our free checker to make sure your Terraform configuration follows best practices, is available (beta).

Parameters

Explanation in Terraform Registry

Manages the association between a Network Interface and a Application Security Group.

Tips: Best Practices for The Other Azure Network Resources

In addition to the azurerm_network_security_group, Azure Network has the other resources that should be configured for security reasons. Please check some examples of those resources and precautions.

risk-label

azurerm_network_security_group

Ensure to disable RDP port from the Internet

It is better to disable the RDP port from the Internet. RDP access should not be accepted from the Internet (*, 0.0.0.0, /0, internet, any), and consider using the Azure Bastion Service.

risk-label

azurerm_network_security_rule

Ensure to set a more restrictive CIDR range for ingress from the internet

It is better to set a more restrictive CIDR range not to use very broad subnets. If possible, segments should be divided into smaller subnets.

risk-label

azurerm_network_watcher_flow_log

Ensure to enable Retention policy for flow logs and set it to enough duration

It is better to enable a retention policy for flow logs. Flow logs show us all network activity in the cloud environment and support us when we face critical incidents.

Review your Azure Network settings

In addition to the above, there are other security points you should be aware of making sure that your .tf files are protected in Shisho Cloud.

Microsoft.Network/applicationSecurityGroups (Azure Resource Manager)

The applicationSecurityGroups in Microsoft.Network can be configured in Azure Resource Manager with the resource name Microsoft.Network/applicationSecurityGroups. The following sections describe how to use the resource and its parameters.

Example Usage from GitHub

azure.com_network-applicationSecurityGroup_2017-10-01.json#L114
                      "type": "Microsoft.Network/applicationSecurityGroups"
                    },
                    {
                      "id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/applicationSecurityGroups/asg2",
                      "location": "westus",
                      "name": "asg2",
asg.json#L43
            "type": "Microsoft.Network/applicationSecurityGroups",
            "name": "[parameters('applicationSecurityGroupName')]",
            "location": "[variables('locationName')]"
        },
        {
            "apiVersion": "2019-02-01",
genericNetworkTemplate.json#L97
            "type": "Microsoft.Network/applicationSecurityGroups",
            "condition": "[greater(length(parameters('dbSecurityGroupName')), 0)]",
            "apiVersion": "2019-02-01",
            "location": "[parameters('location')]",
            "properties": {}
        },
azure.comnetwork-applicationSecurityGroup.json#L375
              "type": "Microsoft.Network/applicationSecurityGroups"
            },
            {
              "id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/applicationSecurityGroups/asg2",
              "location": "westus",
              "name": "asg2",
azuredeployoldold.json#L88
      "type": "Microsoft.Network/applicationSecurityGroups",
      "apiVersion": "2017-10-01",
      "location": "[resourceGroup().location]",
      "properties": {},
      "tags": {
        "displayName": "AsgProdWeb"
azuredeploy.json#L88
      "type": "Microsoft.Network/applicationSecurityGroups",
      "apiVersion": "2017-10-01",
      "location": "[resourceGroup().location]",
      "properties": {},
      "tags": {
        "displayName": "AsgProdWeb"
ApplicationSecurityGroupCreate.json#L17
        "type": "Microsoft.Network/applicationSecurityGroups",
        "location": "westus",
        "properties": {
          "provisioningState": "Succeeded",
          "resourceGuid": "00000000-0000-0000-0000-000000000000"
        }
asg.json#L43
            "type": "Microsoft.Network/applicationSecurityGroups",
            "name": "[parameters('applicationSecurityGroupName')]",
            "location": "[variables('locationName')]"
        },
        {
            "apiVersion": "2019-02-01",
azure.com_network-applicationSecurityGroup_2017-10-01.json#L114
                      "type": "Microsoft.Network/applicationSecurityGroups"
                    },
                    {
                      "id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/applicationSecurityGroups/asg2",
                      "location": "westus",
                      "name": "asg2",
azure.com_network-applicationSecurityGroup_2017-11-01.json#L114
                      "type": "Microsoft.Network/applicationSecurityGroups"
                    },
                    {
                      "id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/applicationSecurityGroups/asg2",
                      "location": "westus",
                      "name": "asg2",

Parameters

  • name required - string
  • type required - string
  • apiVersion required - string
  • location required - string

    Resource location.

  • tags optional - string

    Resource tags.

  • properties required

    Frequently asked questions

    What is Azure Network Interface Application Security Group Association?

    Azure Network Interface Application Security Group Association is a resource for Network of Microsoft Azure. Settings can be wrote in Terraform.

    Where can I find the example code for the Azure Network Interface Application Security Group Association?

    For Terraform, the ksandermann/formkube, nlevee/ca-stack and nlevee/ca-stack source code examples are useful. See the Terraform Example section for further details.

    For Azure Resource Manager, the Pudding124/SwaggerStructure, prasroy/hanaonazurearm and maciejng/azure-linked-templates source code examples are useful. See the Azure Resource Manager Example section for further details.