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

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

@file:Suppress("NAME_SHADOWING", "DEPRECATION")

package com.pulumi.azure.network.kotlin

import com.pulumi.azure.network.NetworkSecurityGroupArgs.builder
import com.pulumi.azure.network.kotlin.inputs.NetworkSecurityGroupSecurityRuleArgs
import com.pulumi.azure.network.kotlin.inputs.NetworkSecurityGroupSecurityRuleArgsBuilder
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.Pair
import kotlin.String
import kotlin.Suppress
import kotlin.Unit
import kotlin.collections.List
import kotlin.collections.Map
import kotlin.jvm.JvmName

/**
 * Manages a network security group that contains a list of network security rules.  Network security groups enable inbound or outbound traffic to be enabled or denied.
 * > **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,
 *     securityRules: [{
 *         name: "test123",
 *         priority: 100,
 *         direction: "Inbound",
 *         access: "Allow",
 *         protocol: "Tcp",
 *         sourcePortRange: "*",
 *         destinationPortRange: "*",
 *         sourceAddressPrefix: "*",
 *         destinationAddressPrefix: "*",
 *     }],
 *     tags: {
 *         environment: "Production",
 *     },
 * });
 * ```
 * ```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,
 *     security_rules=[{
 *         "name": "test123",
 *         "priority": 100,
 *         "direction": "Inbound",
 *         "access": "Allow",
 *         "protocol": "Tcp",
 *         "source_port_range": "*",
 *         "destination_port_range": "*",
 *         "source_address_prefix": "*",
 *         "destination_address_prefix": "*",
 *     }],
 *     tags={
 *         "environment": "Production",
 *     })
 * ```
 * ```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,
 *         SecurityRules = new[]
 *         {
 *             new Azure.Network.Inputs.NetworkSecurityGroupSecurityRuleArgs
 *             {
 *                 Name = "test123",
 *                 Priority = 100,
 *                 Direction = "Inbound",
 *                 Access = "Allow",
 *                 Protocol = "Tcp",
 *                 SourcePortRange = "*",
 *                 DestinationPortRange = "*",
 *                 SourceAddressPrefix = "*",
 *                 DestinationAddressPrefix = "*",
 *             },
 *         },
 *         Tags =
 *         {
 *             { "environment", "Production" },
 *         },
 *     });
 * });
 * ```
 * ```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
 * 		}
 * 		_, err = network.NewNetworkSecurityGroup(ctx, "example", &network.NetworkSecurityGroupArgs{
 * 			Name:              pulumi.String("acceptanceTestSecurityGroup1"),
 * 			Location:          example.Location,
 * 			ResourceGroupName: example.Name,
 * 			SecurityRules: network.NetworkSecurityGroupSecurityRuleArray{
 * 				&network.NetworkSecurityGroupSecurityRuleArgs{
 * 					Name:                     pulumi.String("test123"),
 * 					Priority:                 pulumi.Int(100),
 * 					Direction:                pulumi.String("Inbound"),
 * 					Access:                   pulumi.String("Allow"),
 * 					Protocol:                 pulumi.String("Tcp"),
 * 					SourcePortRange:          pulumi.String("*"),
 * 					DestinationPortRange:     pulumi.String("*"),
 * 					SourceAddressPrefix:      pulumi.String("*"),
 * 					DestinationAddressPrefix: pulumi.String("*"),
 * 				},
 * 			},
 * 			Tags: pulumi.StringMap{
 * 				"environment": pulumi.String("Production"),
 * 			},
 * 		})
 * 		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.inputs.NetworkSecurityGroupSecurityRuleArgs;
 * 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())
 *             .securityRules(NetworkSecurityGroupSecurityRuleArgs.builder()
 *                 .name("test123")
 *                 .priority(100)
 *                 .direction("Inbound")
 *                 .access("Allow")
 *                 .protocol("Tcp")
 *                 .sourcePortRange("*")
 *                 .destinationPortRange("*")
 *                 .sourceAddressPrefix("*")
 *                 .destinationAddressPrefix("*")
 *                 .build())
 *             .tags(Map.of("environment", "Production"))
 *             .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}
 *       securityRules:
 *         - name: test123
 *           priority: 100
 *           direction: Inbound
 *           access: Allow
 *           protocol: Tcp
 *           sourcePortRange: '*'
 *           destinationPortRange: '*'
 *           sourceAddressPrefix: '*'
 *           destinationAddressPrefix: '*'
 *       tags:
 *         environment: Production
 * ```
 * 
 * ## Import
 * Network Security Groups can be imported using the `resource id`, e.g.
 * ```sh
 * $ pulumi import azure:network/networkSecurityGroup:NetworkSecurityGroup group1 /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.Network/networkSecurityGroups/mySecurityGroup
 * ```
 * @property location Specifies the supported Azure location where the resource exists. Changing this forces a new resource to be created.
 * @property name The name of the security rule.
 * @property resourceGroupName The name of the resource group in which to create the network security group. Changing this forces a new resource to be created.
 * @property securityRules A list of objects representing security rules, as defined below.
 * > **NOTE** Since `security_rule` can be configured both inline and via the separate `azure.network.NetworkSecurityRule` resource, we have to explicitly set it to empty slice (`[]`) to remove it.
 * @property tags A mapping of tags to assign to the resource.
 */
public data class NetworkSecurityGroupArgs(
    public val location: Output? = null,
    public val name: Output? = null,
    public val resourceGroupName: Output? = null,
    public val securityRules: Output>? = null,
    public val tags: Output>? = null,
) : ConvertibleToJava {
    override fun toJava(): com.pulumi.azure.network.NetworkSecurityGroupArgs =
        com.pulumi.azure.network.NetworkSecurityGroupArgs.builder()
            .location(location?.applyValue({ args0 -> args0 }))
            .name(name?.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 location: Output? = null

    private var name: Output? = null

    private var resourceGroupName: Output? = null

    private var securityRules: Output>? = null

    private var tags: Output>? = null

    /**
     * @param value Specifies the supported Azure location where the resource exists. Changing this forces a new resource to be created.
     */
    @JvmName("xrckhaxfdkvqaaih")
    public suspend fun location(`value`: Output) {
        this.location = value
    }

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

    /**
     * @param value The name of the resource group in which to create the network security group. Changing this forces a new resource to be created.
     */
    @JvmName("vhvkmwemaeuwfkac")
    public suspend fun resourceGroupName(`value`: Output) {
        this.resourceGroupName = value
    }

    /**
     * @param value A list of objects representing security rules, as defined below.
     * > **NOTE** Since `security_rule` can be configured both inline and via the separate `azure.network.NetworkSecurityRule` resource, we have to explicitly set it to empty slice (`[]`) to remove it.
     */
    @JvmName("vqteokmlxglgbail")
    public suspend fun securityRules(`value`: Output>) {
        this.securityRules = value
    }

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

    /**
     * @param values A list of objects representing security rules, as defined below.
     * > **NOTE** Since `security_rule` can be configured both inline and via the separate `azure.network.NetworkSecurityRule` resource, we have to explicitly set it to empty slice (`[]`) to remove it.
     */
    @JvmName("vrpfvguilryjuhmo")
    public suspend fun securityRules(values: List>) {
        this.securityRules = Output.all(values)
    }

    /**
     * @param value A mapping of tags to assign to the resource.
     */
    @JvmName("fkyhmwuudrsifefm")
    public suspend fun tags(`value`: Output>) {
        this.tags = value
    }

    /**
     * @param value Specifies the supported Azure location where the resource exists. Changing this forces a new resource to be created.
     */
    @JvmName("ikuslcxfcmbtnckq")
    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 security rule.
     */
    @JvmName("hgmwaftfnffmtegd")
    public suspend fun name(`value`: String?) {
        val toBeMapped = value
        val mapped = toBeMapped?.let({ args0 -> of(args0) })
        this.name = mapped
    }

    /**
     * @param value The name of the resource group in which to create the network security group. Changing this forces a new resource to be created.
     */
    @JvmName("ecsijxtaedavsseh")
    public suspend fun resourceGroupName(`value`: String?) {
        val toBeMapped = value
        val mapped = toBeMapped?.let({ args0 -> of(args0) })
        this.resourceGroupName = mapped
    }

    /**
     * @param value A list of objects representing security rules, as defined below.
     * > **NOTE** Since `security_rule` can be configured both inline and via the separate `azure.network.NetworkSecurityRule` resource, we have to explicitly set it to empty slice (`[]`) to remove it.
     */
    @JvmName("iiqjktbsmkejrkbk")
    public suspend fun securityRules(`value`: List?) {
        val toBeMapped = value
        val mapped = toBeMapped?.let({ args0 -> of(args0) })
        this.securityRules = mapped
    }

    /**
     * @param argument A list of objects representing security rules, as defined below.
     * > **NOTE** Since `security_rule` can be configured both inline and via the separate `azure.network.NetworkSecurityRule` resource, we have to explicitly set it to empty slice (`[]`) to remove it.
     */
    @JvmName("nuristltlheubuhl")
    public suspend fun securityRules(argument: List Unit>) {
        val toBeMapped = argument.toList().map {
            NetworkSecurityGroupSecurityRuleArgsBuilder().applySuspend { it() }.build()
        }
        val mapped = of(toBeMapped)
        this.securityRules = mapped
    }

    /**
     * @param argument A list of objects representing security rules, as defined below.
     * > **NOTE** Since `security_rule` can be configured both inline and via the separate `azure.network.NetworkSecurityRule` resource, we have to explicitly set it to empty slice (`[]`) to remove it.
     */
    @JvmName("qyjmlrvsmifgotlw")
    public suspend fun securityRules(vararg argument: suspend NetworkSecurityGroupSecurityRuleArgsBuilder.() -> Unit) {
        val toBeMapped = argument.toList().map {
            NetworkSecurityGroupSecurityRuleArgsBuilder().applySuspend { it() }.build()
        }
        val mapped = of(toBeMapped)
        this.securityRules = mapped
    }

    /**
     * @param argument A list of objects representing security rules, as defined below.
     * > **NOTE** Since `security_rule` can be configured both inline and via the separate `azure.network.NetworkSecurityRule` resource, we have to explicitly set it to empty slice (`[]`) to remove it.
     */
    @JvmName("jbpsdmiwtdvkpwki")
    public suspend fun securityRules(argument: suspend NetworkSecurityGroupSecurityRuleArgsBuilder.() -> Unit) {
        val toBeMapped = listOf(
            NetworkSecurityGroupSecurityRuleArgsBuilder().applySuspend {
                argument()
            }.build(),
        )
        val mapped = of(toBeMapped)
        this.securityRules = mapped
    }

    /**
     * @param values A list of objects representing security rules, as defined below.
     * > **NOTE** Since `security_rule` can be configured both inline and via the separate `azure.network.NetworkSecurityRule` resource, we have to explicitly set it to empty slice (`[]`) to remove it.
     */
    @JvmName("nwhgvsrvevmuwwvr")
    public suspend fun securityRules(vararg values: NetworkSecurityGroupSecurityRuleArgs) {
        val toBeMapped = values.toList()
        val mapped = toBeMapped.let({ args0 -> of(args0) })
        this.securityRules = mapped
    }

    /**
     * @param value A mapping of tags to assign to the resource.
     */
    @JvmName("dixbvciypsivsdun")
    public suspend fun tags(`value`: Map?) {
        val toBeMapped = value
        val mapped = toBeMapped?.let({ args0 -> of(args0) })
        this.tags = mapped
    }

    /**
     * @param values A mapping of tags to assign to the resource.
     */
    @JvmName("rebykaaresailnkg")
    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(
        location = location,
        name = name,
        resourceGroupName = resourceGroupName,
        securityRules = securityRules,
        tags = tags,
    )
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy