
com.pulumi.azure.network.kotlin.SubnetNatGatewayAssociation.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.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.String
import kotlin.Suppress
import kotlin.Unit
/**
* Builder for [SubnetNatGatewayAssociation].
*/
@PulumiTagMarker
public class SubnetNatGatewayAssociationResourceBuilder internal constructor() {
public var name: String? = null
public var args: SubnetNatGatewayAssociationArgs = SubnetNatGatewayAssociationArgs()
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 SubnetNatGatewayAssociationArgsBuilder.() -> Unit) {
val builder = SubnetNatGatewayAssociationArgsBuilder()
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(): SubnetNatGatewayAssociation {
val builtJavaResource =
com.pulumi.azure.network.SubnetNatGatewayAssociation(
this.name,
this.args.toJava(),
this.opts.toJava(),
)
return SubnetNatGatewayAssociation(builtJavaResource)
}
}
/**
* Associates a NAT Gateway with a Subnet within a Virtual Network.
* ## Example Usage
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as azure from "@pulumi/azure";
* const example = new azure.core.ResourceGroup("example", {
* name: "example-nat-gateway-rg",
* location: "West Europe",
* });
* const exampleVirtualNetwork = new azure.network.VirtualNetwork("example", {
* name: "example-network",
* addressSpaces: ["10.0.0.0/16"],
* location: example.location,
* resourceGroupName: example.name,
* });
* const exampleSubnet = new azure.network.Subnet("example", {
* name: "example-subnet",
* resourceGroupName: example.name,
* virtualNetworkName: exampleVirtualNetwork.name,
* addressPrefixes: ["10.0.2.0/24"],
* });
* const exampleNatGateway = new azure.network.NatGateway("example", {
* name: "example-natgateway",
* location: example.location,
* resourceGroupName: example.name,
* });
* const exampleSubnetNatGatewayAssociation = new azure.network.SubnetNatGatewayAssociation("example", {
* subnetId: exampleSubnet.id,
* natGatewayId: exampleNatGateway.id,
* });
* ```
* ```python
* import pulumi
* import pulumi_azure as azure
* example = azure.core.ResourceGroup("example",
* name="example-nat-gateway-rg",
* location="West Europe")
* example_virtual_network = azure.network.VirtualNetwork("example",
* name="example-network",
* address_spaces=["10.0.0.0/16"],
* location=example.location,
* resource_group_name=example.name)
* example_subnet = azure.network.Subnet("example",
* name="example-subnet",
* resource_group_name=example.name,
* virtual_network_name=example_virtual_network.name,
* address_prefixes=["10.0.2.0/24"])
* example_nat_gateway = azure.network.NatGateway("example",
* name="example-natgateway",
* location=example.location,
* resource_group_name=example.name)
* example_subnet_nat_gateway_association = azure.network.SubnetNatGatewayAssociation("example",
* subnet_id=example_subnet.id,
* nat_gateway_id=example_nat_gateway.id)
* ```
* ```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-nat-gateway-rg",
* Location = "West Europe",
* });
* var exampleVirtualNetwork = new Azure.Network.VirtualNetwork("example", new()
* {
* Name = "example-network",
* AddressSpaces = new[]
* {
* "10.0.0.0/16",
* },
* Location = example.Location,
* ResourceGroupName = example.Name,
* });
* var exampleSubnet = new Azure.Network.Subnet("example", new()
* {
* Name = "example-subnet",
* ResourceGroupName = example.Name,
* VirtualNetworkName = exampleVirtualNetwork.Name,
* AddressPrefixes = new[]
* {
* "10.0.2.0/24",
* },
* });
* var exampleNatGateway = new Azure.Network.NatGateway("example", new()
* {
* Name = "example-natgateway",
* Location = example.Location,
* ResourceGroupName = example.Name,
* });
* var exampleSubnetNatGatewayAssociation = new Azure.Network.SubnetNatGatewayAssociation("example", new()
* {
* SubnetId = exampleSubnet.Id,
* NatGatewayId = exampleNatGateway.Id,
* });
* });
* ```
* ```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-nat-gateway-rg"),
* Location: pulumi.String("West Europe"),
* })
* if err != nil {
* return err
* }
* exampleVirtualNetwork, err := network.NewVirtualNetwork(ctx, "example", &network.VirtualNetworkArgs{
* Name: pulumi.String("example-network"),
* 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("example-subnet"),
* ResourceGroupName: example.Name,
* VirtualNetworkName: exampleVirtualNetwork.Name,
* AddressPrefixes: pulumi.StringArray{
* pulumi.String("10.0.2.0/24"),
* },
* })
* if err != nil {
* return err
* }
* exampleNatGateway, err := network.NewNatGateway(ctx, "example", &network.NatGatewayArgs{
* Name: pulumi.String("example-natgateway"),
* Location: example.Location,
* ResourceGroupName: example.Name,
* })
* if err != nil {
* return err
* }
* _, err = network.NewSubnetNatGatewayAssociation(ctx, "example", &network.SubnetNatGatewayAssociationArgs{
* SubnetId: exampleSubnet.ID(),
* NatGatewayId: exampleNatGateway.ID(),
* })
* 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.NatGateway;
* import com.pulumi.azure.network.NatGatewayArgs;
* import com.pulumi.azure.network.SubnetNatGatewayAssociation;
* import com.pulumi.azure.network.SubnetNatGatewayAssociationArgs;
* 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-nat-gateway-rg")
* .location("West Europe")
* .build());
* var exampleVirtualNetwork = new VirtualNetwork("exampleVirtualNetwork", VirtualNetworkArgs.builder()
* .name("example-network")
* .addressSpaces("10.0.0.0/16")
* .location(example.location())
* .resourceGroupName(example.name())
* .build());
* var exampleSubnet = new Subnet("exampleSubnet", SubnetArgs.builder()
* .name("example-subnet")
* .resourceGroupName(example.name())
* .virtualNetworkName(exampleVirtualNetwork.name())
* .addressPrefixes("10.0.2.0/24")
* .build());
* var exampleNatGateway = new NatGateway("exampleNatGateway", NatGatewayArgs.builder()
* .name("example-natgateway")
* .location(example.location())
* .resourceGroupName(example.name())
* .build());
* var exampleSubnetNatGatewayAssociation = new SubnetNatGatewayAssociation("exampleSubnetNatGatewayAssociation", SubnetNatGatewayAssociationArgs.builder()
* .subnetId(exampleSubnet.id())
* .natGatewayId(exampleNatGateway.id())
* .build());
* }
* }
* ```
* ```yaml
* resources:
* example:
* type: azure:core:ResourceGroup
* properties:
* name: example-nat-gateway-rg
* location: West Europe
* exampleVirtualNetwork:
* type: azure:network:VirtualNetwork
* name: example
* properties:
* name: example-network
* addressSpaces:
* - 10.0.0.0/16
* location: ${example.location}
* resourceGroupName: ${example.name}
* exampleSubnet:
* type: azure:network:Subnet
* name: example
* properties:
* name: example-subnet
* resourceGroupName: ${example.name}
* virtualNetworkName: ${exampleVirtualNetwork.name}
* addressPrefixes:
* - 10.0.2.0/24
* exampleNatGateway:
* type: azure:network:NatGateway
* name: example
* properties:
* name: example-natgateway
* location: ${example.location}
* resourceGroupName: ${example.name}
* exampleSubnetNatGatewayAssociation:
* type: azure:network:SubnetNatGatewayAssociation
* name: example
* properties:
* subnetId: ${exampleSubnet.id}
* natGatewayId: ${exampleNatGateway.id}
* ```
*
* ## Import
* Subnet NAT Gateway Associations can be imported using the `resource id` of the Subnet, e.g.
* ```sh
* $ pulumi import azure:network/subnetNatGatewayAssociation:SubnetNatGatewayAssociation association1 /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.Network/virtualNetworks/myvnet1/subnets/mysubnet1
* ```
*/
public class SubnetNatGatewayAssociation internal constructor(
override val javaResource: com.pulumi.azure.network.SubnetNatGatewayAssociation,
) : KotlinCustomResource(javaResource, SubnetNatGatewayAssociationMapper) {
/**
* The ID of the NAT Gateway which should be associated with the Subnet. Changing this forces a new resource to be created.
*/
public val natGatewayId: Output
get() = javaResource.natGatewayId().applyValue({ args0 -> args0 })
/**
* The ID of the Subnet. Changing this forces a new resource to be created.
*/
public val subnetId: Output
get() = javaResource.subnetId().applyValue({ args0 -> args0 })
}
public object SubnetNatGatewayAssociationMapper : ResourceMapper {
override fun supportsMappingOfType(javaResource: Resource): Boolean =
com.pulumi.azure.network.SubnetNatGatewayAssociation::class == javaResource::class
override fun map(javaResource: Resource): SubnetNatGatewayAssociation =
SubnetNatGatewayAssociation(
javaResource as
com.pulumi.azure.network.SubnetNatGatewayAssociation,
)
}
/**
* @see [SubnetNatGatewayAssociation].
* @param name The _unique_ name of the resulting resource.
* @param block Builder for [SubnetNatGatewayAssociation].
*/
public suspend fun subnetNatGatewayAssociation(
name: String,
block: suspend SubnetNatGatewayAssociationResourceBuilder.() -> Unit,
):
SubnetNatGatewayAssociation {
val builder = SubnetNatGatewayAssociationResourceBuilder()
builder.name(name)
block(builder)
return builder.build()
}
/**
* @see [SubnetNatGatewayAssociation].
* @param name The _unique_ name of the resulting resource.
*/
public fun subnetNatGatewayAssociation(name: String): SubnetNatGatewayAssociation {
val builder = SubnetNatGatewayAssociationResourceBuilder()
builder.name(name)
return builder.build()
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy