Azure Network Application Security Group
This page shows how to write Terraform and Azure Resource Manager for Network Application Security Group and write them securely.
azurerm_application_security_group (Terraform)
The Application Security Group in Network can be configured in Terraform with the resource name azurerm_application_security_group
. The following sections describe 8 examples of how to use the resource and its parameters.
Example Usage from GitHub
resource "azurerm_application_security_group" "application_security_group-asg-appservers" {
name = "AppServers"
location = azurerm_resource_group.application_security_group-rg.location
resource_group_name = azurerm_resource_group.application_security_group-rg.name
}
resource "azurerm_application_security_group" "application_security_group-asg-appservers" {
name = "AppServers"
location = azurerm_resource_group.application_security_group-rg.location
resource_group_name = azurerm_resource_group.application_security_group-rg.name
}
resource "azurerm_application_security_group" "controller_asg" {
name = local.controller_asg
location = var.location
resource_group_name = azurerm_resource_group.boundary.name
}
resource "azurerm_application_security_group" "application_security_group-asg-appservers" {
name = "AppServers"
location = azurerm_resource_group.application_security_group-rg.location
resource_group_name = azurerm_resource_group.application_security_group-rg.name
}
resource "azurerm_application_security_group" "common" {
location = azurerm_resource_group.hello_azure.location
resource_group_name = azurerm_resource_group.hello_azure.name
name = "common"
}
resource "azurerm_application_security_group" "app_sec_group" {
for_each = toset(var.groups)
name = each.key
location = var.location
resource_group_name = var.rg_name
tags = var.tags
resource "azurerm_application_security_group" "first" {
name = "xpc-test1"
location = "westeurope"
resource_group_name = var.resource_group_name
}
resource "azurerm_application_security_group" "common" {
location = azurerm_resource_group.hello_azure.location
resource_group_name = azurerm_resource_group.hello_azure.name
name = "common"
}
Parameters
-
id
optional computed - string -
location
required - string -
name
required - string -
resource_group_name
required - string -
tags
optional - map from string to string -
timeouts
single block
Explanation in Terraform Registry
Manages an 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.
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.
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.
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.
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
"type": "Microsoft.Network/applicationSecurityGroups"
},
{
"id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/applicationSecurityGroups/asg2",
"location": "westus",
"name": "asg2",
"type": "Microsoft.Network/applicationSecurityGroups",
"name": "[parameters('applicationSecurityGroupName')]",
"location": "[variables('locationName')]"
},
{
"apiVersion": "2019-02-01",
"type": "Microsoft.Network/applicationSecurityGroups",
"condition": "[greater(length(parameters('dbSecurityGroupName')), 0)]",
"apiVersion": "2019-02-01",
"location": "[parameters('location')]",
"properties": {}
},
"type": "Microsoft.Network/applicationSecurityGroups"
},
{
"id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/applicationSecurityGroups/asg2",
"location": "westus",
"name": "asg2",
"type": "Microsoft.Network/applicationSecurityGroups",
"apiVersion": "2017-10-01",
"location": "[resourceGroup().location]",
"properties": {},
"tags": {
"displayName": "AsgProdWeb"
"type": "Microsoft.Network/applicationSecurityGroups",
"apiVersion": "2017-10-01",
"location": "[resourceGroup().location]",
"properties": {},
"tags": {
"displayName": "AsgProdWeb"
"type": "Microsoft.Network/applicationSecurityGroups",
"location": "westus",
"properties": {
"provisioningState": "Succeeded",
"resourceGuid": "00000000-0000-0000-0000-000000000000"
}
"type": "Microsoft.Network/applicationSecurityGroups",
"name": "[parameters('applicationSecurityGroupName')]",
"location": "[variables('locationName')]"
},
{
"apiVersion": "2019-02-01",
"type": "Microsoft.Network/applicationSecurityGroups"
},
{
"id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/applicationSecurityGroups/asg2",
"location": "westus",
"name": "asg2",
"type": "Microsoft.Network/applicationSecurityGroups"
},
{
"id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/applicationSecurityGroups/asg2",
"location": "westus",
"name": "asg2",
Parameters
name
required - stringtype
required - stringapiVersion
required - stringlocation
required - stringResource location.
tags
optional - stringResource tags.
properties
required
Frequently asked questions
What is Azure Network Application Security Group?
Azure Network Application Security Group 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 Application Security Group?
For Terraform, the ComputerNiagara/devopspertise, ComputerNiagara/devopspertise and hashicorp/boundary-reference-architecture 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.