We recommend using Azure Native.
azure.network.NetworkSecurityRule
Explore with Pulumi AI
Manages a Network Security Rule.
NOTE on Network Security Groups and Network Security Rules: This provider currently provides both a standalone Network Security Rule resource, and allows for Network Security Rules to be defined in-line within the Network Security Group resource. At this time you cannot use a Network Security Group with in-line Network Security Rules in conjunction with any Network Security Rule resources. Doing so will cause a conflict of rule settings and will overwrite rules.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as azure from "@pulumi/azure";
const example = new azure.core.ResourceGroup("example", {
name: "example-resources",
location: "West Europe",
});
const exampleNetworkSecurityGroup = new azure.network.NetworkSecurityGroup("example", {
name: "acceptanceTestSecurityGroup1",
location: example.location,
resourceGroupName: example.name,
});
const exampleNetworkSecurityRule = new azure.network.NetworkSecurityRule("example", {
name: "test123",
priority: 100,
direction: "Outbound",
access: "Allow",
protocol: "Tcp",
sourcePortRange: "*",
destinationPortRange: "*",
sourceAddressPrefix: "*",
destinationAddressPrefix: "*",
resourceGroupName: example.name,
networkSecurityGroupName: exampleNetworkSecurityGroup.name,
});
import pulumi
import pulumi_azure as azure
example = azure.core.ResourceGroup("example",
name="example-resources",
location="West Europe")
example_network_security_group = azure.network.NetworkSecurityGroup("example",
name="acceptanceTestSecurityGroup1",
location=example.location,
resource_group_name=example.name)
example_network_security_rule = azure.network.NetworkSecurityRule("example",
name="test123",
priority=100,
direction="Outbound",
access="Allow",
protocol="Tcp",
source_port_range="*",
destination_port_range="*",
source_address_prefix="*",
destination_address_prefix="*",
resource_group_name=example.name,
network_security_group_name=example_network_security_group.name)
package main
import (
"github.com/pulumi/pulumi-azure/sdk/v6/go/azure/core"
"github.com/pulumi/pulumi-azure/sdk/v6/go/azure/network"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
example, err := core.NewResourceGroup(ctx, "example", &core.ResourceGroupArgs{
Name: pulumi.String("example-resources"),
Location: pulumi.String("West Europe"),
})
if err != nil {
return err
}
exampleNetworkSecurityGroup, err := network.NewNetworkSecurityGroup(ctx, "example", &network.NetworkSecurityGroupArgs{
Name: pulumi.String("acceptanceTestSecurityGroup1"),
Location: example.Location,
ResourceGroupName: example.Name,
})
if err != nil {
return err
}
_, err = network.NewNetworkSecurityRule(ctx, "example", &network.NetworkSecurityRuleArgs{
Name: pulumi.String("test123"),
Priority: pulumi.Int(100),
Direction: pulumi.String("Outbound"),
Access: pulumi.String("Allow"),
Protocol: pulumi.String("Tcp"),
SourcePortRange: pulumi.String("*"),
DestinationPortRange: pulumi.String("*"),
SourceAddressPrefix: pulumi.String("*"),
DestinationAddressPrefix: pulumi.String("*"),
ResourceGroupName: example.Name,
NetworkSecurityGroupName: exampleNetworkSecurityGroup.Name,
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Azure = Pulumi.Azure;
return await Deployment.RunAsync(() =>
{
var example = new Azure.Core.ResourceGroup("example", new()
{
Name = "example-resources",
Location = "West Europe",
});
var exampleNetworkSecurityGroup = new Azure.Network.NetworkSecurityGroup("example", new()
{
Name = "acceptanceTestSecurityGroup1",
Location = example.Location,
ResourceGroupName = example.Name,
});
var exampleNetworkSecurityRule = new Azure.Network.NetworkSecurityRule("example", new()
{
Name = "test123",
Priority = 100,
Direction = "Outbound",
Access = "Allow",
Protocol = "Tcp",
SourcePortRange = "*",
DestinationPortRange = "*",
SourceAddressPrefix = "*",
DestinationAddressPrefix = "*",
ResourceGroupName = example.Name,
NetworkSecurityGroupName = exampleNetworkSecurityGroup.Name,
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.azure.core.ResourceGroup;
import com.pulumi.azure.core.ResourceGroupArgs;
import com.pulumi.azure.network.NetworkSecurityGroup;
import com.pulumi.azure.network.NetworkSecurityGroupArgs;
import com.pulumi.azure.network.NetworkSecurityRule;
import com.pulumi.azure.network.NetworkSecurityRuleArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var example = new ResourceGroup("example", ResourceGroupArgs.builder()
.name("example-resources")
.location("West Europe")
.build());
var exampleNetworkSecurityGroup = new NetworkSecurityGroup("exampleNetworkSecurityGroup", NetworkSecurityGroupArgs.builder()
.name("acceptanceTestSecurityGroup1")
.location(example.location())
.resourceGroupName(example.name())
.build());
var exampleNetworkSecurityRule = new NetworkSecurityRule("exampleNetworkSecurityRule", NetworkSecurityRuleArgs.builder()
.name("test123")
.priority(100)
.direction("Outbound")
.access("Allow")
.protocol("Tcp")
.sourcePortRange("*")
.destinationPortRange("*")
.sourceAddressPrefix("*")
.destinationAddressPrefix("*")
.resourceGroupName(example.name())
.networkSecurityGroupName(exampleNetworkSecurityGroup.name())
.build());
}
}
resources:
example:
type: azure:core:ResourceGroup
properties:
name: example-resources
location: West Europe
exampleNetworkSecurityGroup:
type: azure:network:NetworkSecurityGroup
name: example
properties:
name: acceptanceTestSecurityGroup1
location: ${example.location}
resourceGroupName: ${example.name}
exampleNetworkSecurityRule:
type: azure:network:NetworkSecurityRule
name: example
properties:
name: test123
priority: 100
direction: Outbound
access: Allow
protocol: Tcp
sourcePortRange: '*'
destinationPortRange: '*'
sourceAddressPrefix: '*'
destinationAddressPrefix: '*'
resourceGroupName: ${example.name}
networkSecurityGroupName: ${exampleNetworkSecurityGroup.name}
Create NetworkSecurityRule Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new NetworkSecurityRule(name: string, args: NetworkSecurityRuleArgs, opts?: CustomResourceOptions);
@overload
def NetworkSecurityRule(resource_name: str,
args: NetworkSecurityRuleArgs,
opts: Optional[ResourceOptions] = None)
@overload
def NetworkSecurityRule(resource_name: str,
opts: Optional[ResourceOptions] = None,
direction: Optional[str] = None,
resource_group_name: Optional[str] = None,
protocol: Optional[str] = None,
priority: Optional[int] = None,
access: Optional[str] = None,
network_security_group_name: Optional[str] = None,
destination_application_security_group_ids: Optional[str] = None,
destination_port_ranges: Optional[Sequence[str]] = None,
name: Optional[str] = None,
destination_port_range: Optional[str] = None,
destination_address_prefixes: Optional[Sequence[str]] = None,
destination_address_prefix: Optional[str] = None,
description: Optional[str] = None,
source_address_prefix: Optional[str] = None,
source_address_prefixes: Optional[Sequence[str]] = None,
source_application_security_group_ids: Optional[str] = None,
source_port_range: Optional[str] = None,
source_port_ranges: Optional[Sequence[str]] = None)
func NewNetworkSecurityRule(ctx *Context, name string, args NetworkSecurityRuleArgs, opts ...ResourceOption) (*NetworkSecurityRule, error)
public NetworkSecurityRule(string name, NetworkSecurityRuleArgs args, CustomResourceOptions? opts = null)
public NetworkSecurityRule(String name, NetworkSecurityRuleArgs args)
public NetworkSecurityRule(String name, NetworkSecurityRuleArgs args, CustomResourceOptions options)
type: azure:network:NetworkSecurityRule
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.
Parameters
- name string
- The unique name of the resource.
- args NetworkSecurityRuleArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- resource_name str
- The unique name of the resource.
- args NetworkSecurityRuleArgs
- The arguments to resource properties.
- opts ResourceOptions
- Bag of options to control resource's behavior.
- ctx Context
- Context object for the current deployment.
- name string
- The unique name of the resource.
- args NetworkSecurityRuleArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args NetworkSecurityRuleArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args NetworkSecurityRuleArgs
- The arguments to resource properties.
- options CustomResourceOptions
- Bag of options to control resource's behavior.
Constructor example
The following reference example uses placeholder values for all input properties.
var networkSecurityRuleResource = new Azure.Network.NetworkSecurityRule("networkSecurityRuleResource", new()
{
Direction = "string",
ResourceGroupName = "string",
Protocol = "string",
Priority = 0,
Access = "string",
NetworkSecurityGroupName = "string",
DestinationApplicationSecurityGroupIds = "string",
DestinationPortRanges = new[]
{
"string",
},
Name = "string",
DestinationPortRange = "string",
DestinationAddressPrefixes = new[]
{
"string",
},
DestinationAddressPrefix = "string",
Description = "string",
SourceAddressPrefix = "string",
SourceAddressPrefixes = new[]
{
"string",
},
SourceApplicationSecurityGroupIds = "string",
SourcePortRange = "string",
SourcePortRanges = new[]
{
"string",
},
});
example, err := network.NewNetworkSecurityRule(ctx, "networkSecurityRuleResource", &network.NetworkSecurityRuleArgs{
Direction: pulumi.String("string"),
ResourceGroupName: pulumi.String("string"),
Protocol: pulumi.String("string"),
Priority: pulumi.Int(0),
Access: pulumi.String("string"),
NetworkSecurityGroupName: pulumi.String("string"),
DestinationApplicationSecurityGroupIds: pulumi.String("string"),
DestinationPortRanges: pulumi.StringArray{
pulumi.String("string"),
},
Name: pulumi.String("string"),
DestinationPortRange: pulumi.String("string"),
DestinationAddressPrefixes: pulumi.StringArray{
pulumi.String("string"),
},
DestinationAddressPrefix: pulumi.String("string"),
Description: pulumi.String("string"),
SourceAddressPrefix: pulumi.String("string"),
SourceAddressPrefixes: pulumi.StringArray{
pulumi.String("string"),
},
SourceApplicationSecurityGroupIds: pulumi.String("string"),
SourcePortRange: pulumi.String("string"),
SourcePortRanges: pulumi.StringArray{
pulumi.String("string"),
},
})
var networkSecurityRuleResource = new NetworkSecurityRule("networkSecurityRuleResource", NetworkSecurityRuleArgs.builder()
.direction("string")
.resourceGroupName("string")
.protocol("string")
.priority(0)
.access("string")
.networkSecurityGroupName("string")
.destinationApplicationSecurityGroupIds("string")
.destinationPortRanges("string")
.name("string")
.destinationPortRange("string")
.destinationAddressPrefixes("string")
.destinationAddressPrefix("string")
.description("string")
.sourceAddressPrefix("string")
.sourceAddressPrefixes("string")
.sourceApplicationSecurityGroupIds("string")
.sourcePortRange("string")
.sourcePortRanges("string")
.build());
network_security_rule_resource = azure.network.NetworkSecurityRule("networkSecurityRuleResource",
direction="string",
resource_group_name="string",
protocol="string",
priority=0,
access="string",
network_security_group_name="string",
destination_application_security_group_ids="string",
destination_port_ranges=["string"],
name="string",
destination_port_range="string",
destination_address_prefixes=["string"],
destination_address_prefix="string",
description="string",
source_address_prefix="string",
source_address_prefixes=["string"],
source_application_security_group_ids="string",
source_port_range="string",
source_port_ranges=["string"])
const networkSecurityRuleResource = new azure.network.NetworkSecurityRule("networkSecurityRuleResource", {
direction: "string",
resourceGroupName: "string",
protocol: "string",
priority: 0,
access: "string",
networkSecurityGroupName: "string",
destinationApplicationSecurityGroupIds: "string",
destinationPortRanges: ["string"],
name: "string",
destinationPortRange: "string",
destinationAddressPrefixes: ["string"],
destinationAddressPrefix: "string",
description: "string",
sourceAddressPrefix: "string",
sourceAddressPrefixes: ["string"],
sourceApplicationSecurityGroupIds: "string",
sourcePortRange: "string",
sourcePortRanges: ["string"],
});
type: azure:network:NetworkSecurityRule
properties:
access: string
description: string
destinationAddressPrefix: string
destinationAddressPrefixes:
- string
destinationApplicationSecurityGroupIds: string
destinationPortRange: string
destinationPortRanges:
- string
direction: string
name: string
networkSecurityGroupName: string
priority: 0
protocol: string
resourceGroupName: string
sourceAddressPrefix: string
sourceAddressPrefixes:
- string
sourceApplicationSecurityGroupIds: string
sourcePortRange: string
sourcePortRanges:
- string
NetworkSecurityRule Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.
Inputs
In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.
The NetworkSecurityRule resource accepts the following input properties:
- Access string
- Specifies whether network traffic is allowed or denied. Possible values are
Allow
andDeny
. - Direction string
- The direction specifies if rule will be evaluated on incoming or outgoing traffic. Possible values are
Inbound
andOutbound
. - Network
Security stringGroup Name - The name of the Network Security Group that we want to attach the rule to. Changing this forces a new resource to be created.
- Priority int
- Specifies the priority of the rule. The value can be between 100 and 4096. The priority number must be unique for each rule in the collection. The lower the priority number, the higher the priority of the rule.
- Protocol string
- Network protocol this rule applies to. Possible values include
Tcp
,Udp
,Icmp
,Esp
,Ah
or*
(which matches all). - Resource
Group stringName - The name of the resource group in which to create the Network Security Rule. Changing this forces a new resource to be created.
- Description string
- A description for this rule. Restricted to 140 characters.
- Destination
Address stringPrefix - CIDR or destination IP range or * to match any IP. Tags such as
VirtualNetwork
,AzureLoadBalancer
andInternet
can also be used. Besides, it also supports all available Service Tags like ‘Sql.WestEurope‘, ‘Storage.EastUS‘, etc. You can list the available service tags with the CLI:shell az network list-service-tags --location westcentralus
. For further information please see Azure CLI - az network list-service-tags. This is required ifdestination_address_prefixes
is not specified. - Destination
Address List<string>Prefixes - List of destination address prefixes. Tags may not be used. This is required if
destination_address_prefix
is not specified. - Destination
Application stringSecurity Group Ids - A List of destination Application Security Group IDs
- Destination
Port stringRange - Destination Port or Range. Integer or range between
0
and65535
or*
to match any. This is required ifdestination_port_ranges
is not specified. - Destination
Port List<string>Ranges - List of destination ports or port ranges. This is required if
destination_port_range
is not specified. - Name string
- The name of the security rule. This needs to be unique across all Rules in the Network Security Group. Changing this forces a new resource to be created.
- Source
Address stringPrefix - CIDR or source IP range or * to match any IP. Tags such as
VirtualNetwork
,AzureLoadBalancer
andInternet
can also be used. This is required ifsource_address_prefixes
is not specified. - Source
Address List<string>Prefixes - List of source address prefixes. Tags may not be used. This is required if
source_address_prefix
is not specified. - Source
Application stringSecurity Group Ids - A List of source Application Security Group IDs
- Source
Port stringRange - Source Port or Range. Integer or range between
0
and65535
or*
to match any. This is required ifsource_port_ranges
is not specified. - Source
Port List<string>Ranges - List of source ports or port ranges. This is required if
source_port_range
is not specified.
- Access string
- Specifies whether network traffic is allowed or denied. Possible values are
Allow
andDeny
. - Direction string
- The direction specifies if rule will be evaluated on incoming or outgoing traffic. Possible values are
Inbound
andOutbound
. - Network
Security stringGroup Name - The name of the Network Security Group that we want to attach the rule to. Changing this forces a new resource to be created.
- Priority int
- Specifies the priority of the rule. The value can be between 100 and 4096. The priority number must be unique for each rule in the collection. The lower the priority number, the higher the priority of the rule.
- Protocol string
- Network protocol this rule applies to. Possible values include
Tcp
,Udp
,Icmp
,Esp
,Ah
or*
(which matches all). - Resource
Group stringName - The name of the resource group in which to create the Network Security Rule. Changing this forces a new resource to be created.
- Description string
- A description for this rule. Restricted to 140 characters.
- Destination
Address stringPrefix - CIDR or destination IP range or * to match any IP. Tags such as
VirtualNetwork
,AzureLoadBalancer
andInternet
can also be used. Besides, it also supports all available Service Tags like ‘Sql.WestEurope‘, ‘Storage.EastUS‘, etc. You can list the available service tags with the CLI:shell az network list-service-tags --location westcentralus
. For further information please see Azure CLI - az network list-service-tags. This is required ifdestination_address_prefixes
is not specified. - Destination
Address []stringPrefixes - List of destination address prefixes. Tags may not be used. This is required if
destination_address_prefix
is not specified. - Destination
Application stringSecurity Group Ids - A List of destination Application Security Group IDs
- Destination
Port stringRange - Destination Port or Range. Integer or range between
0
and65535
or*
to match any. This is required ifdestination_port_ranges
is not specified. - Destination
Port []stringRanges - List of destination ports or port ranges. This is required if
destination_port_range
is not specified. - Name string
- The name of the security rule. This needs to be unique across all Rules in the Network Security Group. Changing this forces a new resource to be created.
- Source
Address stringPrefix - CIDR or source IP range or * to match any IP. Tags such as
VirtualNetwork
,AzureLoadBalancer
andInternet
can also be used. This is required ifsource_address_prefixes
is not specified. - Source
Address []stringPrefixes - List of source address prefixes. Tags may not be used. This is required if
source_address_prefix
is not specified. - Source
Application stringSecurity Group Ids - A List of source Application Security Group IDs
- Source
Port stringRange - Source Port or Range. Integer or range between
0
and65535
or*
to match any. This is required ifsource_port_ranges
is not specified. - Source
Port []stringRanges - List of source ports or port ranges. This is required if
source_port_range
is not specified.
- access String
- Specifies whether network traffic is allowed or denied. Possible values are
Allow
andDeny
. - direction String
- The direction specifies if rule will be evaluated on incoming or outgoing traffic. Possible values are
Inbound
andOutbound
. - network
Security StringGroup Name - The name of the Network Security Group that we want to attach the rule to. Changing this forces a new resource to be created.
- priority Integer
- Specifies the priority of the rule. The value can be between 100 and 4096. The priority number must be unique for each rule in the collection. The lower the priority number, the higher the priority of the rule.
- protocol String
- Network protocol this rule applies to. Possible values include
Tcp
,Udp
,Icmp
,Esp
,Ah
or*
(which matches all). - resource
Group StringName - The name of the resource group in which to create the Network Security Rule. Changing this forces a new resource to be created.
- description String
- A description for this rule. Restricted to 140 characters.
- destination
Address StringPrefix - CIDR or destination IP range or * to match any IP. Tags such as
VirtualNetwork
,AzureLoadBalancer
andInternet
can also be used. Besides, it also supports all available Service Tags like ‘Sql.WestEurope‘, ‘Storage.EastUS‘, etc. You can list the available service tags with the CLI:shell az network list-service-tags --location westcentralus
. For further information please see Azure CLI - az network list-service-tags. This is required ifdestination_address_prefixes
is not specified. - destination
Address List<String>Prefixes - List of destination address prefixes. Tags may not be used. This is required if
destination_address_prefix
is not specified. - destination
Application StringSecurity Group Ids - A List of destination Application Security Group IDs
- destination
Port StringRange - Destination Port or Range. Integer or range between
0
and65535
or*
to match any. This is required ifdestination_port_ranges
is not specified. - destination
Port List<String>Ranges - List of destination ports or port ranges. This is required if
destination_port_range
is not specified. - name String
- The name of the security rule. This needs to be unique across all Rules in the Network Security Group. Changing this forces a new resource to be created.
- source
Address StringPrefix - CIDR or source IP range or * to match any IP. Tags such as
VirtualNetwork
,AzureLoadBalancer
andInternet
can also be used. This is required ifsource_address_prefixes
is not specified. - source
Address List<String>Prefixes - List of source address prefixes. Tags may not be used. This is required if
source_address_prefix
is not specified. - source
Application StringSecurity Group Ids - A List of source Application Security Group IDs
- source
Port StringRange - Source Port or Range. Integer or range between
0
and65535
or*
to match any. This is required ifsource_port_ranges
is not specified. - source
Port List<String>Ranges - List of source ports or port ranges. This is required if
source_port_range
is not specified.
- access string
- Specifies whether network traffic is allowed or denied. Possible values are
Allow
andDeny
. - direction string
- The direction specifies if rule will be evaluated on incoming or outgoing traffic. Possible values are
Inbound
andOutbound
. - network
Security stringGroup Name - The name of the Network Security Group that we want to attach the rule to. Changing this forces a new resource to be created.
- priority number
- Specifies the priority of the rule. The value can be between 100 and 4096. The priority number must be unique for each rule in the collection. The lower the priority number, the higher the priority of the rule.
- protocol string
- Network protocol this rule applies to. Possible values include
Tcp
,Udp
,Icmp
,Esp
,Ah
or*
(which matches all). - resource
Group stringName - The name of the resource group in which to create the Network Security Rule. Changing this forces a new resource to be created.
- description string
- A description for this rule. Restricted to 140 characters.
- destination
Address stringPrefix - CIDR or destination IP range or * to match any IP. Tags such as
VirtualNetwork
,AzureLoadBalancer
andInternet
can also be used. Besides, it also supports all available Service Tags like ‘Sql.WestEurope‘, ‘Storage.EastUS‘, etc. You can list the available service tags with the CLI:shell az network list-service-tags --location westcentralus
. For further information please see Azure CLI - az network list-service-tags. This is required ifdestination_address_prefixes
is not specified. - destination
Address string[]Prefixes - List of destination address prefixes. Tags may not be used. This is required if
destination_address_prefix
is not specified. - destination
Application stringSecurity Group Ids - A List of destination Application Security Group IDs
- destination
Port stringRange - Destination Port or Range. Integer or range between
0
and65535
or*
to match any. This is required ifdestination_port_ranges
is not specified. - destination
Port string[]Ranges - List of destination ports or port ranges. This is required if
destination_port_range
is not specified. - name string
- The name of the security rule. This needs to be unique across all Rules in the Network Security Group. Changing this forces a new resource to be created.
- source
Address stringPrefix - CIDR or source IP range or * to match any IP. Tags such as
VirtualNetwork
,AzureLoadBalancer
andInternet
can also be used. This is required ifsource_address_prefixes
is not specified. - source
Address string[]Prefixes - List of source address prefixes. Tags may not be used. This is required if
source_address_prefix
is not specified. - source
Application stringSecurity Group Ids - A List of source Application Security Group IDs
- source
Port stringRange - Source Port or Range. Integer or range between
0
and65535
or*
to match any. This is required ifsource_port_ranges
is not specified. - source
Port string[]Ranges - List of source ports or port ranges. This is required if
source_port_range
is not specified.
- access str
- Specifies whether network traffic is allowed or denied. Possible values are
Allow
andDeny
. - direction str
- The direction specifies if rule will be evaluated on incoming or outgoing traffic. Possible values are
Inbound
andOutbound
. - network_
security_ strgroup_ name - The name of the Network Security Group that we want to attach the rule to. Changing this forces a new resource to be created.
- priority int
- Specifies the priority of the rule. The value can be between 100 and 4096. The priority number must be unique for each rule in the collection. The lower the priority number, the higher the priority of the rule.
- protocol str
- Network protocol this rule applies to. Possible values include
Tcp
,Udp
,Icmp
,Esp
,Ah
or*
(which matches all). - resource_
group_ strname - The name of the resource group in which to create the Network Security Rule. Changing this forces a new resource to be created.
- description str
- A description for this rule. Restricted to 140 characters.
- destination_
address_ strprefix - CIDR or destination IP range or * to match any IP. Tags such as
VirtualNetwork
,AzureLoadBalancer
andInternet
can also be used. Besides, it also supports all available Service Tags like ‘Sql.WestEurope‘, ‘Storage.EastUS‘, etc. You can list the available service tags with the CLI:shell az network list-service-tags --location westcentralus
. For further information please see Azure CLI - az network list-service-tags. This is required ifdestination_address_prefixes
is not specified. - destination_
address_ Sequence[str]prefixes - List of destination address prefixes. Tags may not be used. This is required if
destination_address_prefix
is not specified. - destination_
application_ strsecurity_ group_ ids - A List of destination Application Security Group IDs
- destination_
port_ strrange - Destination Port or Range. Integer or range between
0
and65535
or*
to match any. This is required ifdestination_port_ranges
is not specified. - destination_
port_ Sequence[str]ranges - List of destination ports or port ranges. This is required if
destination_port_range
is not specified. - name str
- The name of the security rule. This needs to be unique across all Rules in the Network Security Group. Changing this forces a new resource to be created.
- source_
address_ strprefix - CIDR or source IP range or * to match any IP. Tags such as
VirtualNetwork
,AzureLoadBalancer
andInternet
can also be used. This is required ifsource_address_prefixes
is not specified. - source_
address_ Sequence[str]prefixes - List of source address prefixes. Tags may not be used. This is required if
source_address_prefix
is not specified. - source_
application_ strsecurity_ group_ ids - A List of source Application Security Group IDs
- source_
port_ strrange - Source Port or Range. Integer or range between
0
and65535
or*
to match any. This is required ifsource_port_ranges
is not specified. - source_
port_ Sequence[str]ranges - List of source ports or port ranges. This is required if
source_port_range
is not specified.
- access String
- Specifies whether network traffic is allowed or denied. Possible values are
Allow
andDeny
. - direction String
- The direction specifies if rule will be evaluated on incoming or outgoing traffic. Possible values are
Inbound
andOutbound
. - network
Security StringGroup Name - The name of the Network Security Group that we want to attach the rule to. Changing this forces a new resource to be created.
- priority Number
- Specifies the priority of the rule. The value can be between 100 and 4096. The priority number must be unique for each rule in the collection. The lower the priority number, the higher the priority of the rule.
- protocol String
- Network protocol this rule applies to. Possible values include
Tcp
,Udp
,Icmp
,Esp
,Ah
or*
(which matches all). - resource
Group StringName - The name of the resource group in which to create the Network Security Rule. Changing this forces a new resource to be created.
- description String
- A description for this rule. Restricted to 140 characters.
- destination
Address StringPrefix - CIDR or destination IP range or * to match any IP. Tags such as
VirtualNetwork
,AzureLoadBalancer
andInternet
can also be used. Besides, it also supports all available Service Tags like ‘Sql.WestEurope‘, ‘Storage.EastUS‘, etc. You can list the available service tags with the CLI:shell az network list-service-tags --location westcentralus
. For further information please see Azure CLI - az network list-service-tags. This is required ifdestination_address_prefixes
is not specified. - destination
Address List<String>Prefixes - List of destination address prefixes. Tags may not be used. This is required if
destination_address_prefix
is not specified. - destination
Application StringSecurity Group Ids - A List of destination Application Security Group IDs
- destination
Port StringRange - Destination Port or Range. Integer or range between
0
and65535
or*
to match any. This is required ifdestination_port_ranges
is not specified. - destination
Port List<String>Ranges - List of destination ports or port ranges. This is required if
destination_port_range
is not specified. - name String
- The name of the security rule. This needs to be unique across all Rules in the Network Security Group. Changing this forces a new resource to be created.
- source
Address StringPrefix - CIDR or source IP range or * to match any IP. Tags such as
VirtualNetwork
,AzureLoadBalancer
andInternet
can also be used. This is required ifsource_address_prefixes
is not specified. - source
Address List<String>Prefixes - List of source address prefixes. Tags may not be used. This is required if
source_address_prefix
is not specified. - source
Application StringSecurity Group Ids - A List of source Application Security Group IDs
- source
Port StringRange - Source Port or Range. Integer or range between
0
and65535
or*
to match any. This is required ifsource_port_ranges
is not specified. - source
Port List<String>Ranges - List of source ports or port ranges. This is required if
source_port_range
is not specified.
Outputs
All input properties are implicitly available as output properties. Additionally, the NetworkSecurityRule resource produces the following output properties:
- Id string
- The provider-assigned unique ID for this managed resource.
- Id string
- The provider-assigned unique ID for this managed resource.
- id String
- The provider-assigned unique ID for this managed resource.
- id string
- The provider-assigned unique ID for this managed resource.
- id str
- The provider-assigned unique ID for this managed resource.
- id String
- The provider-assigned unique ID for this managed resource.
Look up Existing NetworkSecurityRule Resource
Get an existing NetworkSecurityRule resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.
public static get(name: string, id: Input<ID>, state?: NetworkSecurityRuleState, opts?: CustomResourceOptions): NetworkSecurityRule
@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
access: Optional[str] = None,
description: Optional[str] = None,
destination_address_prefix: Optional[str] = None,
destination_address_prefixes: Optional[Sequence[str]] = None,
destination_application_security_group_ids: Optional[str] = None,
destination_port_range: Optional[str] = None,
destination_port_ranges: Optional[Sequence[str]] = None,
direction: Optional[str] = None,
name: Optional[str] = None,
network_security_group_name: Optional[str] = None,
priority: Optional[int] = None,
protocol: Optional[str] = None,
resource_group_name: Optional[str] = None,
source_address_prefix: Optional[str] = None,
source_address_prefixes: Optional[Sequence[str]] = None,
source_application_security_group_ids: Optional[str] = None,
source_port_range: Optional[str] = None,
source_port_ranges: Optional[Sequence[str]] = None) -> NetworkSecurityRule
func GetNetworkSecurityRule(ctx *Context, name string, id IDInput, state *NetworkSecurityRuleState, opts ...ResourceOption) (*NetworkSecurityRule, error)
public static NetworkSecurityRule Get(string name, Input<string> id, NetworkSecurityRuleState? state, CustomResourceOptions? opts = null)
public static NetworkSecurityRule get(String name, Output<String> id, NetworkSecurityRuleState state, CustomResourceOptions options)
Resource lookup is not supported in YAML
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- resource_name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- Access string
- Specifies whether network traffic is allowed or denied. Possible values are
Allow
andDeny
. - Description string
- A description for this rule. Restricted to 140 characters.
- Destination
Address stringPrefix - CIDR or destination IP range or * to match any IP. Tags such as
VirtualNetwork
,AzureLoadBalancer
andInternet
can also be used. Besides, it also supports all available Service Tags like ‘Sql.WestEurope‘, ‘Storage.EastUS‘, etc. You can list the available service tags with the CLI:shell az network list-service-tags --location westcentralus
. For further information please see Azure CLI - az network list-service-tags. This is required ifdestination_address_prefixes
is not specified. - Destination
Address List<string>Prefixes - List of destination address prefixes. Tags may not be used. This is required if
destination_address_prefix
is not specified. - Destination
Application stringSecurity Group Ids - A List of destination Application Security Group IDs
- Destination
Port stringRange - Destination Port or Range. Integer or range between
0
and65535
or*
to match any. This is required ifdestination_port_ranges
is not specified. - Destination
Port List<string>Ranges - List of destination ports or port ranges. This is required if
destination_port_range
is not specified. - Direction string
- The direction specifies if rule will be evaluated on incoming or outgoing traffic. Possible values are
Inbound
andOutbound
. - Name string
- The name of the security rule. This needs to be unique across all Rules in the Network Security Group. Changing this forces a new resource to be created.
- Network
Security stringGroup Name - The name of the Network Security Group that we want to attach the rule to. Changing this forces a new resource to be created.
- Priority int
- Specifies the priority of the rule. The value can be between 100 and 4096. The priority number must be unique for each rule in the collection. The lower the priority number, the higher the priority of the rule.
- Protocol string
- Network protocol this rule applies to. Possible values include
Tcp
,Udp
,Icmp
,Esp
,Ah
or*
(which matches all). - Resource
Group stringName - The name of the resource group in which to create the Network Security Rule. Changing this forces a new resource to be created.
- Source
Address stringPrefix - CIDR or source IP range or * to match any IP. Tags such as
VirtualNetwork
,AzureLoadBalancer
andInternet
can also be used. This is required ifsource_address_prefixes
is not specified. - Source
Address List<string>Prefixes - List of source address prefixes. Tags may not be used. This is required if
source_address_prefix
is not specified. - Source
Application stringSecurity Group Ids - A List of source Application Security Group IDs
- Source
Port stringRange - Source Port or Range. Integer or range between
0
and65535
or*
to match any. This is required ifsource_port_ranges
is not specified. - Source
Port List<string>Ranges - List of source ports or port ranges. This is required if
source_port_range
is not specified.
- Access string
- Specifies whether network traffic is allowed or denied. Possible values are
Allow
andDeny
. - Description string
- A description for this rule. Restricted to 140 characters.
- Destination
Address stringPrefix - CIDR or destination IP range or * to match any IP. Tags such as
VirtualNetwork
,AzureLoadBalancer
andInternet
can also be used. Besides, it also supports all available Service Tags like ‘Sql.WestEurope‘, ‘Storage.EastUS‘, etc. You can list the available service tags with the CLI:shell az network list-service-tags --location westcentralus
. For further information please see Azure CLI - az network list-service-tags. This is required ifdestination_address_prefixes
is not specified. - Destination
Address []stringPrefixes - List of destination address prefixes. Tags may not be used. This is required if
destination_address_prefix
is not specified. - Destination
Application stringSecurity Group Ids - A List of destination Application Security Group IDs
- Destination
Port stringRange - Destination Port or Range. Integer or range between
0
and65535
or*
to match any. This is required ifdestination_port_ranges
is not specified. - Destination
Port []stringRanges - List of destination ports or port ranges. This is required if
destination_port_range
is not specified. - Direction string
- The direction specifies if rule will be evaluated on incoming or outgoing traffic. Possible values are
Inbound
andOutbound
. - Name string
- The name of the security rule. This needs to be unique across all Rules in the Network Security Group. Changing this forces a new resource to be created.
- Network
Security stringGroup Name - The name of the Network Security Group that we want to attach the rule to. Changing this forces a new resource to be created.
- Priority int
- Specifies the priority of the rule. The value can be between 100 and 4096. The priority number must be unique for each rule in the collection. The lower the priority number, the higher the priority of the rule.
- Protocol string
- Network protocol this rule applies to. Possible values include
Tcp
,Udp
,Icmp
,Esp
,Ah
or*
(which matches all). - Resource
Group stringName - The name of the resource group in which to create the Network Security Rule. Changing this forces a new resource to be created.
- Source
Address stringPrefix - CIDR or source IP range or * to match any IP. Tags such as
VirtualNetwork
,AzureLoadBalancer
andInternet
can also be used. This is required ifsource_address_prefixes
is not specified. - Source
Address []stringPrefixes - List of source address prefixes. Tags may not be used. This is required if
source_address_prefix
is not specified. - Source
Application stringSecurity Group Ids - A List of source Application Security Group IDs
- Source
Port stringRange - Source Port or Range. Integer or range between
0
and65535
or*
to match any. This is required ifsource_port_ranges
is not specified. - Source
Port []stringRanges - List of source ports or port ranges. This is required if
source_port_range
is not specified.
- access String
- Specifies whether network traffic is allowed or denied. Possible values are
Allow
andDeny
. - description String
- A description for this rule. Restricted to 140 characters.
- destination
Address StringPrefix - CIDR or destination IP range or * to match any IP. Tags such as
VirtualNetwork
,AzureLoadBalancer
andInternet
can also be used. Besides, it also supports all available Service Tags like ‘Sql.WestEurope‘, ‘Storage.EastUS‘, etc. You can list the available service tags with the CLI:shell az network list-service-tags --location westcentralus
. For further information please see Azure CLI - az network list-service-tags. This is required ifdestination_address_prefixes
is not specified. - destination
Address List<String>Prefixes - List of destination address prefixes. Tags may not be used. This is required if
destination_address_prefix
is not specified. - destination
Application StringSecurity Group Ids - A List of destination Application Security Group IDs
- destination
Port StringRange - Destination Port or Range. Integer or range between
0
and65535
or*
to match any. This is required ifdestination_port_ranges
is not specified. - destination
Port List<String>Ranges - List of destination ports or port ranges. This is required if
destination_port_range
is not specified. - direction String
- The direction specifies if rule will be evaluated on incoming or outgoing traffic. Possible values are
Inbound
andOutbound
. - name String
- The name of the security rule. This needs to be unique across all Rules in the Network Security Group. Changing this forces a new resource to be created.
- network
Security StringGroup Name - The name of the Network Security Group that we want to attach the rule to. Changing this forces a new resource to be created.
- priority Integer
- Specifies the priority of the rule. The value can be between 100 and 4096. The priority number must be unique for each rule in the collection. The lower the priority number, the higher the priority of the rule.
- protocol String
- Network protocol this rule applies to. Possible values include
Tcp
,Udp
,Icmp
,Esp
,Ah
or*
(which matches all). - resource
Group StringName - The name of the resource group in which to create the Network Security Rule. Changing this forces a new resource to be created.
- source
Address StringPrefix - CIDR or source IP range or * to match any IP. Tags such as
VirtualNetwork
,AzureLoadBalancer
andInternet
can also be used. This is required ifsource_address_prefixes
is not specified. - source
Address List<String>Prefixes - List of source address prefixes. Tags may not be used. This is required if
source_address_prefix
is not specified. - source
Application StringSecurity Group Ids - A List of source Application Security Group IDs
- source
Port StringRange - Source Port or Range. Integer or range between
0
and65535
or*
to match any. This is required ifsource_port_ranges
is not specified. - source
Port List<String>Ranges - List of source ports or port ranges. This is required if
source_port_range
is not specified.
- access string
- Specifies whether network traffic is allowed or denied. Possible values are
Allow
andDeny
. - description string
- A description for this rule. Restricted to 140 characters.
- destination
Address stringPrefix - CIDR or destination IP range or * to match any IP. Tags such as
VirtualNetwork
,AzureLoadBalancer
andInternet
can also be used. Besides, it also supports all available Service Tags like ‘Sql.WestEurope‘, ‘Storage.EastUS‘, etc. You can list the available service tags with the CLI:shell az network list-service-tags --location westcentralus
. For further information please see Azure CLI - az network list-service-tags. This is required ifdestination_address_prefixes
is not specified. - destination
Address string[]Prefixes - List of destination address prefixes. Tags may not be used. This is required if
destination_address_prefix
is not specified. - destination
Application stringSecurity Group Ids - A List of destination Application Security Group IDs
- destination
Port stringRange - Destination Port or Range. Integer or range between
0
and65535
or*
to match any. This is required ifdestination_port_ranges
is not specified. - destination
Port string[]Ranges - List of destination ports or port ranges. This is required if
destination_port_range
is not specified. - direction string
- The direction specifies if rule will be evaluated on incoming or outgoing traffic. Possible values are
Inbound
andOutbound
. - name string
- The name of the security rule. This needs to be unique across all Rules in the Network Security Group. Changing this forces a new resource to be created.
- network
Security stringGroup Name - The name of the Network Security Group that we want to attach the rule to. Changing this forces a new resource to be created.
- priority number
- Specifies the priority of the rule. The value can be between 100 and 4096. The priority number must be unique for each rule in the collection. The lower the priority number, the higher the priority of the rule.
- protocol string
- Network protocol this rule applies to. Possible values include
Tcp
,Udp
,Icmp
,Esp
,Ah
or*
(which matches all). - resource
Group stringName - The name of the resource group in which to create the Network Security Rule. Changing this forces a new resource to be created.
- source
Address stringPrefix - CIDR or source IP range or * to match any IP. Tags such as
VirtualNetwork
,AzureLoadBalancer
andInternet
can also be used. This is required ifsource_address_prefixes
is not specified. - source
Address string[]Prefixes - List of source address prefixes. Tags may not be used. This is required if
source_address_prefix
is not specified. - source
Application stringSecurity Group Ids - A List of source Application Security Group IDs
- source
Port stringRange - Source Port or Range. Integer or range between
0
and65535
or*
to match any. This is required ifsource_port_ranges
is not specified. - source
Port string[]Ranges - List of source ports or port ranges. This is required if
source_port_range
is not specified.
- access str
- Specifies whether network traffic is allowed or denied. Possible values are
Allow
andDeny
. - description str
- A description for this rule. Restricted to 140 characters.
- destination_
address_ strprefix - CIDR or destination IP range or * to match any IP. Tags such as
VirtualNetwork
,AzureLoadBalancer
andInternet
can also be used. Besides, it also supports all available Service Tags like ‘Sql.WestEurope‘, ‘Storage.EastUS‘, etc. You can list the available service tags with the CLI:shell az network list-service-tags --location westcentralus
. For further information please see Azure CLI - az network list-service-tags. This is required ifdestination_address_prefixes
is not specified. - destination_
address_ Sequence[str]prefixes - List of destination address prefixes. Tags may not be used. This is required if
destination_address_prefix
is not specified. - destination_
application_ strsecurity_ group_ ids - A List of destination Application Security Group IDs
- destination_
port_ strrange - Destination Port or Range. Integer or range between
0
and65535
or*
to match any. This is required ifdestination_port_ranges
is not specified. - destination_
port_ Sequence[str]ranges - List of destination ports or port ranges. This is required if
destination_port_range
is not specified. - direction str
- The direction specifies if rule will be evaluated on incoming or outgoing traffic. Possible values are
Inbound
andOutbound
. - name str
- The name of the security rule. This needs to be unique across all Rules in the Network Security Group. Changing this forces a new resource to be created.
- network_
security_ strgroup_ name - The name of the Network Security Group that we want to attach the rule to. Changing this forces a new resource to be created.
- priority int
- Specifies the priority of the rule. The value can be between 100 and 4096. The priority number must be unique for each rule in the collection. The lower the priority number, the higher the priority of the rule.
- protocol str
- Network protocol this rule applies to. Possible values include
Tcp
,Udp
,Icmp
,Esp
,Ah
or*
(which matches all). - resource_
group_ strname - The name of the resource group in which to create the Network Security Rule. Changing this forces a new resource to be created.
- source_
address_ strprefix - CIDR or source IP range or * to match any IP. Tags such as
VirtualNetwork
,AzureLoadBalancer
andInternet
can also be used. This is required ifsource_address_prefixes
is not specified. - source_
address_ Sequence[str]prefixes - List of source address prefixes. Tags may not be used. This is required if
source_address_prefix
is not specified. - source_
application_ strsecurity_ group_ ids - A List of source Application Security Group IDs
- source_
port_ strrange - Source Port or Range. Integer or range between
0
and65535
or*
to match any. This is required ifsource_port_ranges
is not specified. - source_
port_ Sequence[str]ranges - List of source ports or port ranges. This is required if
source_port_range
is not specified.
- access String
- Specifies whether network traffic is allowed or denied. Possible values are
Allow
andDeny
. - description String
- A description for this rule. Restricted to 140 characters.
- destination
Address StringPrefix - CIDR or destination IP range or * to match any IP. Tags such as
VirtualNetwork
,AzureLoadBalancer
andInternet
can also be used. Besides, it also supports all available Service Tags like ‘Sql.WestEurope‘, ‘Storage.EastUS‘, etc. You can list the available service tags with the CLI:shell az network list-service-tags --location westcentralus
. For further information please see Azure CLI - az network list-service-tags. This is required ifdestination_address_prefixes
is not specified. - destination
Address List<String>Prefixes - List of destination address prefixes. Tags may not be used. This is required if
destination_address_prefix
is not specified. - destination
Application StringSecurity Group Ids - A List of destination Application Security Group IDs
- destination
Port StringRange - Destination Port or Range. Integer or range between
0
and65535
or*
to match any. This is required ifdestination_port_ranges
is not specified. - destination
Port List<String>Ranges - List of destination ports or port ranges. This is required if
destination_port_range
is not specified. - direction String
- The direction specifies if rule will be evaluated on incoming or outgoing traffic. Possible values are
Inbound
andOutbound
. - name String
- The name of the security rule. This needs to be unique across all Rules in the Network Security Group. Changing this forces a new resource to be created.
- network
Security StringGroup Name - The name of the Network Security Group that we want to attach the rule to. Changing this forces a new resource to be created.
- priority Number
- Specifies the priority of the rule. The value can be between 100 and 4096. The priority number must be unique for each rule in the collection. The lower the priority number, the higher the priority of the rule.
- protocol String
- Network protocol this rule applies to. Possible values include
Tcp
,Udp
,Icmp
,Esp
,Ah
or*
(which matches all). - resource
Group StringName - The name of the resource group in which to create the Network Security Rule. Changing this forces a new resource to be created.
- source
Address StringPrefix - CIDR or source IP range or * to match any IP. Tags such as
VirtualNetwork
,AzureLoadBalancer
andInternet
can also be used. This is required ifsource_address_prefixes
is not specified. - source
Address List<String>Prefixes - List of source address prefixes. Tags may not be used. This is required if
source_address_prefix
is not specified. - source
Application StringSecurity Group Ids - A List of source Application Security Group IDs
- source
Port StringRange - Source Port or Range. Integer or range between
0
and65535
or*
to match any. This is required ifsource_port_ranges
is not specified. - source
Port List<String>Ranges - List of source ports or port ranges. This is required if
source_port_range
is not specified.
Import
Network Security Rules can be imported using the resource id
, e.g.
$ pulumi import azure:network/networkSecurityRule:NetworkSecurityRule rule1 /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.Network/networkSecurityGroups/mySecurityGroup/securityRules/rule1
To learn more about importing existing cloud resources, see Importing resources.
Package Details
- Repository
- Azure Classic pulumi/pulumi-azure
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
azurerm
Terraform Provider.