All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.pulumi.azurenative.network.kotlin.NetworkSecurityGroupArgs.kt Maven / Gradle / Ivy

Go to download

Build cloud applications and infrastructure by combining the safety and reliability of infrastructure as code with the power of the Kotlin programming language.

There is a newer version: 2.82.0.0
Show newest version
@file:Suppress("NAME_SHADOWING", "DEPRECATION")

package com.pulumi.azurenative.network.kotlin

import com.pulumi.azurenative.network.NetworkSecurityGroupArgs.builder
import com.pulumi.azurenative.network.kotlin.inputs.SecurityRuleArgs
import com.pulumi.azurenative.network.kotlin.inputs.SecurityRuleArgsBuilder
import com.pulumi.core.Output
import com.pulumi.core.Output.of
import com.pulumi.kotlin.ConvertibleToJava
import com.pulumi.kotlin.PulumiTagMarker
import com.pulumi.kotlin.applySuspend
import kotlin.Boolean
import kotlin.Pair
import kotlin.String
import kotlin.Suppress
import kotlin.Unit
import kotlin.collections.List
import kotlin.collections.Map
import kotlin.jvm.JvmName

/**
 * NetworkSecurityGroup resource.
 * Azure REST API version: 2023-02-01. Prior API version in Azure Native 1.x: 2020-11-01.
 * Other available API versions: 2015-05-01-preview, 2016-03-30, 2019-06-01, 2019-08-01, 2023-04-01, 2023-05-01, 2023-06-01, 2023-09-01, 2023-11-01, 2024-01-01.
 * ## Example Usage
 * ### Create network security group
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using AzureNative = Pulumi.AzureNative;
 * return await Deployment.RunAsync(() =>
 * {
 *     var networkSecurityGroup = new AzureNative.Network.NetworkSecurityGroup("networkSecurityGroup", new()
 *     {
 *         Location = "eastus",
 *         NetworkSecurityGroupName = "testnsg",
 *         ResourceGroupName = "rg1",
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	network "github.com/pulumi/pulumi-azure-native-sdk/network/v2"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		_, err := network.NewNetworkSecurityGroup(ctx, "networkSecurityGroup", &network.NetworkSecurityGroupArgs{
 * 			Location:                 pulumi.String("eastus"),
 * 			NetworkSecurityGroupName: pulumi.String("testnsg"),
 * 			ResourceGroupName:        pulumi.String("rg1"),
 * 		})
 * 		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.azurenative.network.NetworkSecurityGroup;
 * import com.pulumi.azurenative.network.NetworkSecurityGroupArgs;
 * 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 networkSecurityGroup = new NetworkSecurityGroup("networkSecurityGroup", NetworkSecurityGroupArgs.builder()
 *             .location("eastus")
 *             .networkSecurityGroupName("testnsg")
 *             .resourceGroupName("rg1")
 *             .build());
 *     }
 * }
 * ```
 * ### Create network security group with rule
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using AzureNative = Pulumi.AzureNative;
 * return await Deployment.RunAsync(() =>
 * {
 *     var networkSecurityGroup = new AzureNative.Network.NetworkSecurityGroup("networkSecurityGroup", new()
 *     {
 *         Location = "eastus",
 *         NetworkSecurityGroupName = "testnsg",
 *         ResourceGroupName = "rg1",
 *         SecurityRules = new[]
 *         {
 *             new AzureNative.Network.Inputs.SecurityRuleArgs
 *             {
 *                 Access = AzureNative.Network.SecurityRuleAccess.Allow,
 *                 DestinationAddressPrefix = "*",
 *                 DestinationPortRange = "80",
 *                 Direction = AzureNative.Network.SecurityRuleDirection.Inbound,
 *                 Name = "rule1",
 *                 Priority = 130,
 *                 Protocol = AzureNative.Network.SecurityRuleProtocol.Asterisk,
 *                 SourceAddressPrefix = "*",
 *                 SourcePortRange = "*",
 *             },
 *         },
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	network "github.com/pulumi/pulumi-azure-native-sdk/network/v2"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		_, err := network.NewNetworkSecurityGroup(ctx, "networkSecurityGroup", &network.NetworkSecurityGroupArgs{
 * 			Location:                 pulumi.String("eastus"),
 * 			NetworkSecurityGroupName: pulumi.String("testnsg"),
 * 			ResourceGroupName:        pulumi.String("rg1"),
 * 			SecurityRules: network.SecurityRuleTypeArray{
 * 				&network.SecurityRuleTypeArgs{
 * 					Access:                   pulumi.String(network.SecurityRuleAccessAllow),
 * 					DestinationAddressPrefix: pulumi.String("*"),
 * 					DestinationPortRange:     pulumi.String("80"),
 * 					Direction:                pulumi.String(network.SecurityRuleDirectionInbound),
 * 					Name:                     pulumi.String("rule1"),
 * 					Priority:                 pulumi.Int(130),
 * 					Protocol:                 pulumi.String(network.SecurityRuleProtocolAsterisk),
 * 					SourceAddressPrefix:      pulumi.String("*"),
 * 					SourcePortRange:          pulumi.String("*"),
 * 				},
 * 			},
 * 		})
 * 		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.azurenative.network.NetworkSecurityGroup;
 * import com.pulumi.azurenative.network.NetworkSecurityGroupArgs;
 * import com.pulumi.azurenative.network.inputs.SecurityRuleArgs;
 * 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 networkSecurityGroup = new NetworkSecurityGroup("networkSecurityGroup", NetworkSecurityGroupArgs.builder()
 *             .location("eastus")
 *             .networkSecurityGroupName("testnsg")
 *             .resourceGroupName("rg1")
 *             .securityRules(SecurityRuleArgs.builder()
 *                 .access("Allow")
 *                 .destinationAddressPrefix("*")
 *                 .destinationPortRange("80")
 *                 .direction("Inbound")
 *                 .name("rule1")
 *                 .priority(130)
 *                 .protocol("*")
 *                 .sourceAddressPrefix("*")
 *                 .sourcePortRange("*")
 *                 .build())
 *             .build());
 *     }
 * }
 * ```
 * ## Import
 * An existing resource can be imported using its type token, name, and identifier, e.g.
 * ```sh
 * $ pulumi import azure-native:network:NetworkSecurityGroup testnsg /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityGroups/{networkSecurityGroupName}
 * ```
 * @property flushConnection When enabled, flows created from Network Security Group connections will be re-evaluated when rules are updates. Initial enablement will trigger re-evaluation.
 * @property id Resource ID.
 * @property location Resource location.
 * @property networkSecurityGroupName The name of the network security group.
 * @property resourceGroupName The name of the resource group.
 * @property securityRules A collection of security rules of the network security group.
 * These are also available as standalone resources. Do not mix inline and standalone resource as they will conflict with each other, leading to resources deletion.
 * @property tags Resource tags.
 */
public data class NetworkSecurityGroupArgs(
    public val flushConnection: Output? = null,
    public val id: Output? = null,
    public val location: Output? = null,
    public val networkSecurityGroupName: Output? = null,
    public val resourceGroupName: Output? = null,
    public val securityRules: Output>? = null,
    public val tags: Output>? = null,
) : ConvertibleToJava {
    override fun toJava(): com.pulumi.azurenative.network.NetworkSecurityGroupArgs =
        com.pulumi.azurenative.network.NetworkSecurityGroupArgs.builder()
            .flushConnection(flushConnection?.applyValue({ args0 -> args0 }))
            .id(id?.applyValue({ args0 -> args0 }))
            .location(location?.applyValue({ args0 -> args0 }))
            .networkSecurityGroupName(networkSecurityGroupName?.applyValue({ args0 -> args0 }))
            .resourceGroupName(resourceGroupName?.applyValue({ args0 -> args0 }))
            .securityRules(
                securityRules?.applyValue({ args0 ->
                    args0.map({ args0 ->
                        args0.let({ args0 ->
                            args0.toJava()
                        })
                    })
                }),
            )
            .tags(
                tags?.applyValue({ args0 ->
                    args0.map({ args0 ->
                        args0.key.to(args0.value)
                    }).toMap()
                }),
            ).build()
}

/**
 * Builder for [NetworkSecurityGroupArgs].
 */
@PulumiTagMarker
public class NetworkSecurityGroupArgsBuilder internal constructor() {
    private var flushConnection: Output? = null

    private var id: Output? = null

    private var location: Output? = null

    private var networkSecurityGroupName: Output? = null

    private var resourceGroupName: Output? = null

    private var securityRules: Output>? = null

    private var tags: Output>? = null

    /**
     * @param value When enabled, flows created from Network Security Group connections will be re-evaluated when rules are updates. Initial enablement will trigger re-evaluation.
     */
    @JvmName("jsxqvysyvwlpjhxr")
    public suspend fun flushConnection(`value`: Output) {
        this.flushConnection = value
    }

    /**
     * @param value Resource ID.
     */
    @JvmName("jjpcgckwkqruxrex")
    public suspend fun id(`value`: Output) {
        this.id = value
    }

    /**
     * @param value Resource location.
     */
    @JvmName("qiyilgpvwhefroua")
    public suspend fun location(`value`: Output) {
        this.location = value
    }

    /**
     * @param value The name of the network security group.
     */
    @JvmName("bdgxeetebkkadomh")
    public suspend fun networkSecurityGroupName(`value`: Output) {
        this.networkSecurityGroupName = value
    }

    /**
     * @param value The name of the resource group.
     */
    @JvmName("ubgvijmgdwxrsdyc")
    public suspend fun resourceGroupName(`value`: Output) {
        this.resourceGroupName = value
    }

    /**
     * @param value A collection of security rules of the network security group.
     * These are also available as standalone resources. Do not mix inline and standalone resource as they will conflict with each other, leading to resources deletion.
     */
    @JvmName("ouwfoclcqfhlylhg")
    public suspend fun securityRules(`value`: Output>) {
        this.securityRules = value
    }

    @JvmName("hecbogvjyataqdnc")
    public suspend fun securityRules(vararg values: Output) {
        this.securityRules = Output.all(values.asList())
    }

    /**
     * @param values A collection of security rules of the network security group.
     * These are also available as standalone resources. Do not mix inline and standalone resource as they will conflict with each other, leading to resources deletion.
     */
    @JvmName("icjntccfteedlubk")
    public suspend fun securityRules(values: List>) {
        this.securityRules = Output.all(values)
    }

    /**
     * @param value Resource tags.
     */
    @JvmName("lxusnisjtfxmqlsw")
    public suspend fun tags(`value`: Output>) {
        this.tags = value
    }

    /**
     * @param value When enabled, flows created from Network Security Group connections will be re-evaluated when rules are updates. Initial enablement will trigger re-evaluation.
     */
    @JvmName("jlutwnnufkvifria")
    public suspend fun flushConnection(`value`: Boolean?) {
        val toBeMapped = value
        val mapped = toBeMapped?.let({ args0 -> of(args0) })
        this.flushConnection = mapped
    }

    /**
     * @param value Resource ID.
     */
    @JvmName("oppmxitnpajutusj")
    public suspend fun id(`value`: String?) {
        val toBeMapped = value
        val mapped = toBeMapped?.let({ args0 -> of(args0) })
        this.id = mapped
    }

    /**
     * @param value Resource location.
     */
    @JvmName("srslolnltobvhdcg")
    public suspend fun location(`value`: String?) {
        val toBeMapped = value
        val mapped = toBeMapped?.let({ args0 -> of(args0) })
        this.location = mapped
    }

    /**
     * @param value The name of the network security group.
     */
    @JvmName("tdjedmxbivrncscl")
    public suspend fun networkSecurityGroupName(`value`: String?) {
        val toBeMapped = value
        val mapped = toBeMapped?.let({ args0 -> of(args0) })
        this.networkSecurityGroupName = mapped
    }

    /**
     * @param value The name of the resource group.
     */
    @JvmName("ewsutrqfiowofsqa")
    public suspend fun resourceGroupName(`value`: String?) {
        val toBeMapped = value
        val mapped = toBeMapped?.let({ args0 -> of(args0) })
        this.resourceGroupName = mapped
    }

    /**
     * @param value A collection of security rules of the network security group.
     * These are also available as standalone resources. Do not mix inline and standalone resource as they will conflict with each other, leading to resources deletion.
     */
    @JvmName("yasgqgjwrxwpnabq")
    public suspend fun securityRules(`value`: List?) {
        val toBeMapped = value
        val mapped = toBeMapped?.let({ args0 -> of(args0) })
        this.securityRules = mapped
    }

    /**
     * @param argument A collection of security rules of the network security group.
     * These are also available as standalone resources. Do not mix inline and standalone resource as they will conflict with each other, leading to resources deletion.
     */
    @JvmName("fxqovccibmsxrlqm")
    public suspend fun securityRules(argument: List Unit>) {
        val toBeMapped = argument.toList().map {
            SecurityRuleArgsBuilder().applySuspend { it() }.build()
        }
        val mapped = of(toBeMapped)
        this.securityRules = mapped
    }

    /**
     * @param argument A collection of security rules of the network security group.
     * These are also available as standalone resources. Do not mix inline and standalone resource as they will conflict with each other, leading to resources deletion.
     */
    @JvmName("uxogdkuiloqyqkst")
    public suspend fun securityRules(vararg argument: suspend SecurityRuleArgsBuilder.() -> Unit) {
        val toBeMapped = argument.toList().map {
            SecurityRuleArgsBuilder().applySuspend { it() }.build()
        }
        val mapped = of(toBeMapped)
        this.securityRules = mapped
    }

    /**
     * @param argument A collection of security rules of the network security group.
     * These are also available as standalone resources. Do not mix inline and standalone resource as they will conflict with each other, leading to resources deletion.
     */
    @JvmName("ptvemlnqtvjvdiiq")
    public suspend fun securityRules(argument: suspend SecurityRuleArgsBuilder.() -> Unit) {
        val toBeMapped = listOf(SecurityRuleArgsBuilder().applySuspend { argument() }.build())
        val mapped = of(toBeMapped)
        this.securityRules = mapped
    }

    /**
     * @param values A collection of security rules of the network security group.
     * These are also available as standalone resources. Do not mix inline and standalone resource as they will conflict with each other, leading to resources deletion.
     */
    @JvmName("evtjkcxrflrlfcas")
    public suspend fun securityRules(vararg values: SecurityRuleArgs) {
        val toBeMapped = values.toList()
        val mapped = toBeMapped.let({ args0 -> of(args0) })
        this.securityRules = mapped
    }

    /**
     * @param value Resource tags.
     */
    @JvmName("whpuqxvmujsqmmax")
    public suspend fun tags(`value`: Map?) {
        val toBeMapped = value
        val mapped = toBeMapped?.let({ args0 -> of(args0) })
        this.tags = mapped
    }

    /**
     * @param values Resource tags.
     */
    @JvmName("jlcrfyscqkwmkmwa")
    public fun tags(vararg values: Pair) {
        val toBeMapped = values.toMap()
        val mapped = toBeMapped.let({ args0 -> of(args0) })
        this.tags = mapped
    }

    internal fun build(): NetworkSecurityGroupArgs = NetworkSecurityGroupArgs(
        flushConnection = flushConnection,
        id = id,
        location = location,
        networkSecurityGroupName = networkSecurityGroupName,
        resourceGroupName = resourceGroupName,
        securityRules = securityRules,
        tags = tags,
    )
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy