com.pulumi.azure.network.kotlin.FirewallNatRuleCollection.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.kotlin.outputs.FirewallNatRuleCollectionRule
import com.pulumi.azure.network.kotlin.outputs.FirewallNatRuleCollectionRule.Companion.toKotlin
import com.pulumi.core.Output
import com.pulumi.kotlin.KotlinCustomResource
import com.pulumi.kotlin.PulumiTagMarker
import com.pulumi.kotlin.ResourceMapper
import com.pulumi.kotlin.options.CustomResourceOptions
import com.pulumi.kotlin.options.CustomResourceOptionsBuilder
import com.pulumi.resources.Resource
import kotlin.Boolean
import kotlin.Int
import kotlin.String
import kotlin.Suppress
import kotlin.Unit
import kotlin.collections.List
/**
* Builder for [FirewallNatRuleCollection].
*/
@PulumiTagMarker
public class FirewallNatRuleCollectionResourceBuilder internal constructor() {
public var name: String? = null
public var args: FirewallNatRuleCollectionArgs = FirewallNatRuleCollectionArgs()
public var opts: CustomResourceOptions = CustomResourceOptions()
/**
* @param name The _unique_ name of the resulting resource.
*/
public fun name(`value`: String) {
this.name = value
}
/**
* @param block The arguments to use to populate this resource's properties.
*/
public suspend fun args(block: suspend FirewallNatRuleCollectionArgsBuilder.() -> Unit) {
val builder = FirewallNatRuleCollectionArgsBuilder()
block(builder)
this.args = builder.build()
}
/**
* @param block A bag of options that control this resource's behavior.
*/
public suspend fun opts(block: suspend CustomResourceOptionsBuilder.() -> Unit) {
this.opts = com.pulumi.kotlin.options.CustomResourceOptions.opts(block)
}
internal fun build(): FirewallNatRuleCollection {
val builtJavaResource =
com.pulumi.azure.network.FirewallNatRuleCollection(
this.name,
this.args.toJava(),
this.opts.toJava(),
)
return FirewallNatRuleCollection(builtJavaResource)
}
}
/**
* Manages a NAT Rule Collection within an Azure Firewall.
* ## 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 exampleVirtualNetwork = new azure.network.VirtualNetwork("example", {
* name: "testvnet",
* addressSpaces: ["10.0.0.0/16"],
* location: example.location,
* resourceGroupName: example.name,
* });
* const exampleSubnet = new azure.network.Subnet("example", {
* name: "AzureFirewallSubnet",
* resourceGroupName: example.name,
* virtualNetworkName: exampleVirtualNetwork.name,
* addressPrefixes: ["10.0.1.0/24"],
* });
* const examplePublicIp = new azure.network.PublicIp("example", {
* name: "testpip",
* location: example.location,
* resourceGroupName: example.name,
* allocationMethod: "Static",
* sku: "Standard",
* });
* const exampleFirewall = new azure.network.Firewall("example", {
* name: "testfirewall",
* location: example.location,
* resourceGroupName: example.name,
* skuName: "AZFW_VNet",
* skuTier: "Standard",
* ipConfigurations: [{
* name: "configuration",
* subnetId: exampleSubnet.id,
* publicIpAddressId: examplePublicIp.id,
* }],
* });
* const exampleFirewallNatRuleCollection = new azure.network.FirewallNatRuleCollection("example", {
* name: "testcollection",
* azureFirewallName: exampleFirewall.name,
* resourceGroupName: example.name,
* priority: 100,
* action: "Dnat",
* rules: [{
* name: "testrule",
* sourceAddresses: ["10.0.0.0/16"],
* destinationPorts: ["53"],
* destinationAddresses: [examplePublicIp.ipAddress],
* translatedPort: "53",
* translatedAddress: "8.8.8.8",
* protocols: [
* "TCP",
* "UDP",
* ],
* }],
* });
* ```
* ```python
* import pulumi
* import pulumi_azure as azure
* example = azure.core.ResourceGroup("example",
* name="example-resources",
* location="West Europe")
* example_virtual_network = azure.network.VirtualNetwork("example",
* name="testvnet",
* address_spaces=["10.0.0.0/16"],
* location=example.location,
* resource_group_name=example.name)
* example_subnet = azure.network.Subnet("example",
* name="AzureFirewallSubnet",
* resource_group_name=example.name,
* virtual_network_name=example_virtual_network.name,
* address_prefixes=["10.0.1.0/24"])
* example_public_ip = azure.network.PublicIp("example",
* name="testpip",
* location=example.location,
* resource_group_name=example.name,
* allocation_method="Static",
* sku="Standard")
* example_firewall = azure.network.Firewall("example",
* name="testfirewall",
* location=example.location,
* resource_group_name=example.name,
* sku_name="AZFW_VNet",
* sku_tier="Standard",
* ip_configurations=[azure.network.FirewallIpConfigurationArgs(
* name="configuration",
* subnet_id=example_subnet.id,
* public_ip_address_id=example_public_ip.id,
* )])
* example_firewall_nat_rule_collection = azure.network.FirewallNatRuleCollection("example",
* name="testcollection",
* azure_firewall_name=example_firewall.name,
* resource_group_name=example.name,
* priority=100,
* action="Dnat",
* rules=[azure.network.FirewallNatRuleCollectionRuleArgs(
* name="testrule",
* source_addresses=["10.0.0.0/16"],
* destination_ports=["53"],
* destination_addresses=[example_public_ip.ip_address],
* translated_port="53",
* translated_address="8.8.8.8",
* protocols=[
* "TCP",
* "UDP",
* ],
* )])
* ```
* ```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 exampleVirtualNetwork = new Azure.Network.VirtualNetwork("example", new()
* {
* Name = "testvnet",
* AddressSpaces = new[]
* {
* "10.0.0.0/16",
* },
* Location = example.Location,
* ResourceGroupName = example.Name,
* });
* var exampleSubnet = new Azure.Network.Subnet("example", new()
* {
* Name = "AzureFirewallSubnet",
* ResourceGroupName = example.Name,
* VirtualNetworkName = exampleVirtualNetwork.Name,
* AddressPrefixes = new[]
* {
* "10.0.1.0/24",
* },
* });
* var examplePublicIp = new Azure.Network.PublicIp("example", new()
* {
* Name = "testpip",
* Location = example.Location,
* ResourceGroupName = example.Name,
* AllocationMethod = "Static",
* Sku = "Standard",
* });
* var exampleFirewall = new Azure.Network.Firewall("example", new()
* {
* Name = "testfirewall",
* Location = example.Location,
* ResourceGroupName = example.Name,
* SkuName = "AZFW_VNet",
* SkuTier = "Standard",
* IpConfigurations = new[]
* {
* new Azure.Network.Inputs.FirewallIpConfigurationArgs
* {
* Name = "configuration",
* SubnetId = exampleSubnet.Id,
* PublicIpAddressId = examplePublicIp.Id,
* },
* },
* });
* var exampleFirewallNatRuleCollection = new Azure.Network.FirewallNatRuleCollection("example", new()
* {
* Name = "testcollection",
* AzureFirewallName = exampleFirewall.Name,
* ResourceGroupName = example.Name,
* Priority = 100,
* Action = "Dnat",
* Rules = new[]
* {
* new Azure.Network.Inputs.FirewallNatRuleCollectionRuleArgs
* {
* Name = "testrule",
* SourceAddresses = new[]
* {
* "10.0.0.0/16",
* },
* DestinationPorts = new[]
* {
* "53",
* },
* DestinationAddresses = new[]
* {
* examplePublicIp.IpAddress,
* },
* TranslatedPort = "53",
* TranslatedAddress = "8.8.8.8",
* Protocols = new[]
* {
* "TCP",
* "UDP",
* },
* },
* },
* });
* });
* ```
* ```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
* }
* exampleVirtualNetwork, err := network.NewVirtualNetwork(ctx, "example", &network.VirtualNetworkArgs{
* Name: pulumi.String("testvnet"),
* AddressSpaces: pulumi.StringArray{
* pulumi.String("10.0.0.0/16"),
* },
* Location: example.Location,
* ResourceGroupName: example.Name,
* })
* if err != nil {
* return err
* }
* exampleSubnet, err := network.NewSubnet(ctx, "example", &network.SubnetArgs{
* Name: pulumi.String("AzureFirewallSubnet"),
* ResourceGroupName: example.Name,
* VirtualNetworkName: exampleVirtualNetwork.Name,
* AddressPrefixes: pulumi.StringArray{
* pulumi.String("10.0.1.0/24"),
* },
* })
* if err != nil {
* return err
* }
* examplePublicIp, err := network.NewPublicIp(ctx, "example", &network.PublicIpArgs{
* Name: pulumi.String("testpip"),
* Location: example.Location,
* ResourceGroupName: example.Name,
* AllocationMethod: pulumi.String("Static"),
* Sku: pulumi.String("Standard"),
* })
* if err != nil {
* return err
* }
* exampleFirewall, err := network.NewFirewall(ctx, "example", &network.FirewallArgs{
* Name: pulumi.String("testfirewall"),
* Location: example.Location,
* ResourceGroupName: example.Name,
* SkuName: pulumi.String("AZFW_VNet"),
* SkuTier: pulumi.String("Standard"),
* IpConfigurations: network.FirewallIpConfigurationArray{
* &network.FirewallIpConfigurationArgs{
* Name: pulumi.String("configuration"),
* SubnetId: exampleSubnet.ID(),
* PublicIpAddressId: examplePublicIp.ID(),
* },
* },
* })
* if err != nil {
* return err
* }
* _, err = network.NewFirewallNatRuleCollection(ctx, "example", &network.FirewallNatRuleCollectionArgs{
* Name: pulumi.String("testcollection"),
* AzureFirewallName: exampleFirewall.Name,
* ResourceGroupName: example.Name,
* Priority: pulumi.Int(100),
* Action: pulumi.String("Dnat"),
* Rules: network.FirewallNatRuleCollectionRuleArray{
* &network.FirewallNatRuleCollectionRuleArgs{
* Name: pulumi.String("testrule"),
* SourceAddresses: pulumi.StringArray{
* pulumi.String("10.0.0.0/16"),
* },
* DestinationPorts: pulumi.StringArray{
* pulumi.String("53"),
* },
* DestinationAddresses: pulumi.StringArray{
* examplePublicIp.IpAddress,
* },
* TranslatedPort: pulumi.String("53"),
* TranslatedAddress: pulumi.String("8.8.8.8"),
* Protocols: pulumi.StringArray{
* pulumi.String("TCP"),
* pulumi.String("UDP"),
* },
* },
* },
* })
* 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.VirtualNetwork;
* import com.pulumi.azure.network.VirtualNetworkArgs;
* import com.pulumi.azure.network.Subnet;
* import com.pulumi.azure.network.SubnetArgs;
* import com.pulumi.azure.network.PublicIp;
* import com.pulumi.azure.network.PublicIpArgs;
* import com.pulumi.azure.network.Firewall;
* import com.pulumi.azure.network.FirewallArgs;
* import com.pulumi.azure.network.inputs.FirewallIpConfigurationArgs;
* import com.pulumi.azure.network.FirewallNatRuleCollection;
* import com.pulumi.azure.network.FirewallNatRuleCollectionArgs;
* import com.pulumi.azure.network.inputs.FirewallNatRuleCollectionRuleArgs;
* 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 exampleVirtualNetwork = new VirtualNetwork("exampleVirtualNetwork", VirtualNetworkArgs.builder()
* .name("testvnet")
* .addressSpaces("10.0.0.0/16")
* .location(example.location())
* .resourceGroupName(example.name())
* .build());
* var exampleSubnet = new Subnet("exampleSubnet", SubnetArgs.builder()
* .name("AzureFirewallSubnet")
* .resourceGroupName(example.name())
* .virtualNetworkName(exampleVirtualNetwork.name())
* .addressPrefixes("10.0.1.0/24")
* .build());
* var examplePublicIp = new PublicIp("examplePublicIp", PublicIpArgs.builder()
* .name("testpip")
* .location(example.location())
* .resourceGroupName(example.name())
* .allocationMethod("Static")
* .sku("Standard")
* .build());
* var exampleFirewall = new Firewall("exampleFirewall", FirewallArgs.builder()
* .name("testfirewall")
* .location(example.location())
* .resourceGroupName(example.name())
* .skuName("AZFW_VNet")
* .skuTier("Standard")
* .ipConfigurations(FirewallIpConfigurationArgs.builder()
* .name("configuration")
* .subnetId(exampleSubnet.id())
* .publicIpAddressId(examplePublicIp.id())
* .build())
* .build());
* var exampleFirewallNatRuleCollection = new FirewallNatRuleCollection("exampleFirewallNatRuleCollection", FirewallNatRuleCollectionArgs.builder()
* .name("testcollection")
* .azureFirewallName(exampleFirewall.name())
* .resourceGroupName(example.name())
* .priority(100)
* .action("Dnat")
* .rules(FirewallNatRuleCollectionRuleArgs.builder()
* .name("testrule")
* .sourceAddresses("10.0.0.0/16")
* .destinationPorts("53")
* .destinationAddresses(examplePublicIp.ipAddress())
* .translatedPort(53)
* .translatedAddress("8.8.8.8")
* .protocols(
* "TCP",
* "UDP")
* .build())
* .build());
* }
* }
* ```
* ```yaml
* resources:
* example:
* type: azure:core:ResourceGroup
* properties:
* name: example-resources
* location: West Europe
* exampleVirtualNetwork:
* type: azure:network:VirtualNetwork
* name: example
* properties:
* name: testvnet
* addressSpaces:
* - 10.0.0.0/16
* location: ${example.location}
* resourceGroupName: ${example.name}
* exampleSubnet:
* type: azure:network:Subnet
* name: example
* properties:
* name: AzureFirewallSubnet
* resourceGroupName: ${example.name}
* virtualNetworkName: ${exampleVirtualNetwork.name}
* addressPrefixes:
* - 10.0.1.0/24
* examplePublicIp:
* type: azure:network:PublicIp
* name: example
* properties:
* name: testpip
* location: ${example.location}
* resourceGroupName: ${example.name}
* allocationMethod: Static
* sku: Standard
* exampleFirewall:
* type: azure:network:Firewall
* name: example
* properties:
* name: testfirewall
* location: ${example.location}
* resourceGroupName: ${example.name}
* skuName: AZFW_VNet
* skuTier: Standard
* ipConfigurations:
* - name: configuration
* subnetId: ${exampleSubnet.id}
* publicIpAddressId: ${examplePublicIp.id}
* exampleFirewallNatRuleCollection:
* type: azure:network:FirewallNatRuleCollection
* name: example
* properties:
* name: testcollection
* azureFirewallName: ${exampleFirewall.name}
* resourceGroupName: ${example.name}
* priority: 100
* action: Dnat
* rules:
* - name: testrule
* sourceAddresses:
* - 10.0.0.0/16
* destinationPorts:
* - '53'
* destinationAddresses:
* - ${examplePublicIp.ipAddress}
* translatedPort: 53
* translatedAddress: 8.8.8.8
* protocols:
* - TCP
* - UDP
* ```
*
* ## Import
* Azure Firewall NAT Rule Collections can be imported using the `resource id`, e.g.
* ```sh
* $ pulumi import azure:network/firewallNatRuleCollection:FirewallNatRuleCollection example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.Network/azureFirewalls/myfirewall/natRuleCollections/mycollection
* ```
*/
public class FirewallNatRuleCollection internal constructor(
override val javaResource: com.pulumi.azure.network.FirewallNatRuleCollection,
) : KotlinCustomResource(javaResource, FirewallNatRuleCollectionMapper) {
/**
* Specifies the action the rule will apply to matching traffic. Possible values are `Dnat` and `Snat`.
*/
public val action: Output
get() = javaResource.action().applyValue({ args0 -> args0 })
/**
* Specifies the name of the Firewall in which the NAT Rule Collection should be created. Changing this forces a new resource to be created.
*/
public val azureFirewallName: Output
get() = javaResource.azureFirewallName().applyValue({ args0 -> args0 })
/**
* Specifies the name of the NAT Rule Collection which must be unique within the Firewall. Changing this forces a new resource to be created.
*/
public val name: Output
get() = javaResource.name().applyValue({ args0 -> args0 })
/**
* Specifies the priority of the rule collection. Possible values are between `100` - `65000`.
*/
public val priority: Output
get() = javaResource.priority().applyValue({ args0 -> args0 })
/**
* Specifies the name of the Resource Group in which the Firewall exists. Changing this forces a new resource to be created.
*/
public val resourceGroupName: Output
get() = javaResource.resourceGroupName().applyValue({ args0 -> args0 })
/**
* One or more `rule` blocks as defined below.
*/
public val rules: Output>
get() = javaResource.rules().applyValue({ args0 ->
args0.map({ args0 ->
args0.let({ args0 ->
toKotlin(args0)
})
})
})
}
public object FirewallNatRuleCollectionMapper : ResourceMapper {
override fun supportsMappingOfType(javaResource: Resource): Boolean =
com.pulumi.azure.network.FirewallNatRuleCollection::class == javaResource::class
override fun map(javaResource: Resource): FirewallNatRuleCollection =
FirewallNatRuleCollection(javaResource as com.pulumi.azure.network.FirewallNatRuleCollection)
}
/**
* @see [FirewallNatRuleCollection].
* @param name The _unique_ name of the resulting resource.
* @param block Builder for [FirewallNatRuleCollection].
*/
public suspend fun firewallNatRuleCollection(
name: String,
block: suspend FirewallNatRuleCollectionResourceBuilder.() -> Unit,
): FirewallNatRuleCollection {
val builder = FirewallNatRuleCollectionResourceBuilder()
builder.name(name)
block(builder)
return builder.build()
}
/**
* @see [FirewallNatRuleCollection].
* @param name The _unique_ name of the resulting resource.
*/
public fun firewallNatRuleCollection(name: String): FirewallNatRuleCollection {
val builder = FirewallNatRuleCollectionResourceBuilder()
builder.name(name)
return builder.build()
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy