![JAR search and dependency download from the Maven repository](/logo.png)
com.pulumi.azure.network.kotlin.NetworkSecurityRuleArgs.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of pulumi-azure-kotlin Show documentation
Show all versions of pulumi-azure-kotlin Show documentation
Build cloud applications and infrastructure by combining the safety and reliability of infrastructure as code with the power of the Kotlin programming language.
@file:Suppress("NAME_SHADOWING", "DEPRECATION")
package com.pulumi.azure.network.kotlin
import com.pulumi.azure.network.NetworkSecurityRuleArgs.builder
import com.pulumi.core.Output
import com.pulumi.core.Output.of
import com.pulumi.kotlin.ConvertibleToJava
import com.pulumi.kotlin.PulumiTagMarker
import kotlin.Int
import kotlin.String
import kotlin.Suppress
import kotlin.collections.List
import kotlin.jvm.JvmName
/**
* 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
*
* ```typescript
* 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,
* });
* ```
* ```python
* 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)
* ```
* ```csharp
* 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,
* });
* });
* ```
* ```go
* package main
* import (
* "github.com/pulumi/pulumi-azure/sdk/v5/go/azure/core"
* "github.com/pulumi/pulumi-azure/sdk/v5/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
* })
* }
* ```
* ```java
* 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());
* }
* }
* ```
* ```yaml
* 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}
* ```
*
* ## Import
* Network Security Rules can be imported using the `resource id`, e.g.
* ```sh
* $ pulumi import azure:network/networkSecurityRule:NetworkSecurityRule rule1 /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.Network/networkSecurityGroups/mySecurityGroup/securityRules/rule1
* ```
* @property access Specifies whether network traffic is allowed or denied. Possible values are `Allow` and `Deny`.
* @property description A description for this rule. Restricted to 140 characters.
* @property destinationAddressPrefix CIDR or destination IP range or * to match any IP. Tags such as `VirtualNetwork`, `AzureLoadBalancer` and `Internet` 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](https://docs.microsoft.com/cli/azure/network?view=azure-cli-latest#az-network-list-service-tags). This is required if `destination_address_prefixes` is not specified.
* @property destinationAddressPrefixes List of destination address prefixes. Tags may not be used. This is required if `destination_address_prefix` is not specified.
* @property destinationApplicationSecurityGroupIds A List of destination Application Security Group IDs
* @property destinationPortRange Destination Port or Range. Integer or range between `0` and `65535` or `*` to match any. This is required if `destination_port_ranges` is not specified.
* @property destinationPortRanges List of destination ports or port ranges. This is required if `destination_port_range` is not specified.
* @property direction The direction specifies if rule will be evaluated on incoming or outgoing traffic. Possible values are `Inbound` and `Outbound`.
* @property name 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.
* @property networkSecurityGroupName The name of the Network Security Group that we want to attach the rule to. Changing this forces a new resource to be created.
* @property priority 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.
* @property protocol Network protocol this rule applies to. Possible values include `Tcp`, `Udp`, `Icmp`, `Esp`, `Ah` or `*` (which matches all).
* @property resourceGroupName The name of the resource group in which to create the Network Security Rule. Changing this forces a new resource to be created.
* @property sourceAddressPrefix CIDR or source IP range or * to match any IP. Tags such as `VirtualNetwork`, `AzureLoadBalancer` and `Internet` can also be used. This is required if `source_address_prefixes` is not specified.
* @property sourceAddressPrefixes List of source address prefixes. Tags may not be used. This is required if `source_address_prefix` is not specified.
* @property sourceApplicationSecurityGroupIds A List of source Application Security Group IDs
* @property sourcePortRange Source Port or Range. Integer or range between `0` and `65535` or `*` to match any. This is required if `source_port_ranges` is not specified.
* @property sourcePortRanges List of source ports or port ranges. This is required if `source_port_range` is not specified.
*/
public data class NetworkSecurityRuleArgs(
public val access: Output? = null,
public val description: Output? = null,
public val destinationAddressPrefix: Output? = null,
public val destinationAddressPrefixes: Output>? = null,
public val destinationApplicationSecurityGroupIds: Output? = null,
public val destinationPortRange: Output? = null,
public val destinationPortRanges: Output>? = null,
public val direction: Output? = null,
public val name: Output? = null,
public val networkSecurityGroupName: Output? = null,
public val priority: Output? = null,
public val protocol: Output? = null,
public val resourceGroupName: Output? = null,
public val sourceAddressPrefix: Output? = null,
public val sourceAddressPrefixes: Output>? = null,
public val sourceApplicationSecurityGroupIds: Output? = null,
public val sourcePortRange: Output? = null,
public val sourcePortRanges: Output>? = null,
) : ConvertibleToJava {
override fun toJava(): com.pulumi.azure.network.NetworkSecurityRuleArgs =
com.pulumi.azure.network.NetworkSecurityRuleArgs.builder()
.access(access?.applyValue({ args0 -> args0 }))
.description(description?.applyValue({ args0 -> args0 }))
.destinationAddressPrefix(destinationAddressPrefix?.applyValue({ args0 -> args0 }))
.destinationAddressPrefixes(
destinationAddressPrefixes?.applyValue({ args0 ->
args0.map({ args0 ->
args0
})
}),
)
.destinationApplicationSecurityGroupIds(
destinationApplicationSecurityGroupIds?.applyValue({ args0 ->
args0
}),
)
.destinationPortRange(destinationPortRange?.applyValue({ args0 -> args0 }))
.destinationPortRanges(destinationPortRanges?.applyValue({ args0 -> args0.map({ args0 -> args0 }) }))
.direction(direction?.applyValue({ args0 -> args0 }))
.name(name?.applyValue({ args0 -> args0 }))
.networkSecurityGroupName(networkSecurityGroupName?.applyValue({ args0 -> args0 }))
.priority(priority?.applyValue({ args0 -> args0 }))
.protocol(protocol?.applyValue({ args0 -> args0 }))
.resourceGroupName(resourceGroupName?.applyValue({ args0 -> args0 }))
.sourceAddressPrefix(sourceAddressPrefix?.applyValue({ args0 -> args0 }))
.sourceAddressPrefixes(sourceAddressPrefixes?.applyValue({ args0 -> args0.map({ args0 -> args0 }) }))
.sourceApplicationSecurityGroupIds(
sourceApplicationSecurityGroupIds?.applyValue({ args0 ->
args0
}),
)
.sourcePortRange(sourcePortRange?.applyValue({ args0 -> args0 }))
.sourcePortRanges(sourcePortRanges?.applyValue({ args0 -> args0.map({ args0 -> args0 }) })).build()
}
/**
* Builder for [NetworkSecurityRuleArgs].
*/
@PulumiTagMarker
public class NetworkSecurityRuleArgsBuilder internal constructor() {
private var access: Output? = null
private var description: Output? = null
private var destinationAddressPrefix: Output? = null
private var destinationAddressPrefixes: Output>? = null
private var destinationApplicationSecurityGroupIds: Output? = null
private var destinationPortRange: Output? = null
private var destinationPortRanges: Output>? = null
private var direction: Output? = null
private var name: Output? = null
private var networkSecurityGroupName: Output? = null
private var priority: Output? = null
private var protocol: Output? = null
private var resourceGroupName: Output? = null
private var sourceAddressPrefix: Output? = null
private var sourceAddressPrefixes: Output>? = null
private var sourceApplicationSecurityGroupIds: Output? = null
private var sourcePortRange: Output? = null
private var sourcePortRanges: Output>? = null
/**
* @param value Specifies whether network traffic is allowed or denied. Possible values are `Allow` and `Deny`.
*/
@JvmName("kvtmqjmksjelmjtq")
public suspend fun access(`value`: Output) {
this.access = value
}
/**
* @param value A description for this rule. Restricted to 140 characters.
*/
@JvmName("pjnyjsesdpvooaaw")
public suspend fun description(`value`: Output) {
this.description = value
}
/**
* @param value CIDR or destination IP range or * to match any IP. Tags such as `VirtualNetwork`, `AzureLoadBalancer` and `Internet` 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](https://docs.microsoft.com/cli/azure/network?view=azure-cli-latest#az-network-list-service-tags). This is required if `destination_address_prefixes` is not specified.
*/
@JvmName("umbftuxrvxehblus")
public suspend fun destinationAddressPrefix(`value`: Output) {
this.destinationAddressPrefix = value
}
/**
* @param value List of destination address prefixes. Tags may not be used. This is required if `destination_address_prefix` is not specified.
*/
@JvmName("idrpdielwyigwjxh")
public suspend fun destinationAddressPrefixes(`value`: Output>) {
this.destinationAddressPrefixes = value
}
@JvmName("nnxdrioutgugetbl")
public suspend fun destinationAddressPrefixes(vararg values: Output) {
this.destinationAddressPrefixes = Output.all(values.asList())
}
/**
* @param values List of destination address prefixes. Tags may not be used. This is required if `destination_address_prefix` is not specified.
*/
@JvmName("ckbniljdqcusisob")
public suspend fun destinationAddressPrefixes(values: List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy