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

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

@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 [Route].
 */
@PulumiTagMarker
public class RouteResourceBuilder internal constructor() {
    public var name: String? = null

    public var args: RouteArgs = RouteArgs()

    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 RouteArgsBuilder.() -> Unit) {
        val builder = RouteArgsBuilder()
        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(): Route {
        val builtJavaResource = com.pulumi.azure.network.Route(
            this.name,
            this.args.toJava(),
            this.opts.toJava(),
        )
        return Route(builtJavaResource)
    }
}

/**
 * Manages a Route within a Route Table.
 * > **NOTE on Route Tables and Routes:** This provider currently
 * provides both a standalone Route resource, and allows for Routes to be defined in-line within the Route Table resource.
 * At this time you cannot use a Route Table with in-line Routes in conjunction with any Route resources. Doing so will cause a conflict of Route configurations and will overwrite Routes.
 * ## 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 exampleRouteTable = new azure.network.RouteTable("example", {
 *     name: "acceptanceTestRouteTable1",
 *     location: example.location,
 *     resourceGroupName: example.name,
 * });
 * const exampleRoute = new azure.network.Route("example", {
 *     name: "acceptanceTestRoute1",
 *     resourceGroupName: example.name,
 *     routeTableName: exampleRouteTable.name,
 *     addressPrefix: "10.1.0.0/16",
 *     nextHopType: "VnetLocal",
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_azure as azure
 * example = azure.core.ResourceGroup("example",
 *     name="example-resources",
 *     location="West Europe")
 * example_route_table = azure.network.RouteTable("example",
 *     name="acceptanceTestRouteTable1",
 *     location=example.location,
 *     resource_group_name=example.name)
 * example_route = azure.network.Route("example",
 *     name="acceptanceTestRoute1",
 *     resource_group_name=example.name,
 *     route_table_name=example_route_table.name,
 *     address_prefix="10.1.0.0/16",
 *     next_hop_type="VnetLocal")
 * ```
 * ```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 exampleRouteTable = new Azure.Network.RouteTable("example", new()
 *     {
 *         Name = "acceptanceTestRouteTable1",
 *         Location = example.Location,
 *         ResourceGroupName = example.Name,
 *     });
 *     var exampleRoute = new Azure.Network.Route("example", new()
 *     {
 *         Name = "acceptanceTestRoute1",
 *         ResourceGroupName = example.Name,
 *         RouteTableName = exampleRouteTable.Name,
 *         AddressPrefix = "10.1.0.0/16",
 *         NextHopType = "VnetLocal",
 *     });
 * });
 * ```
 * ```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
 * 		}
 * 		exampleRouteTable, err := network.NewRouteTable(ctx, "example", &network.RouteTableArgs{
 * 			Name:              pulumi.String("acceptanceTestRouteTable1"),
 * 			Location:          example.Location,
 * 			ResourceGroupName: example.Name,
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = network.NewRoute(ctx, "example", &network.RouteArgs{
 * 			Name:              pulumi.String("acceptanceTestRoute1"),
 * 			ResourceGroupName: example.Name,
 * 			RouteTableName:    exampleRouteTable.Name,
 * 			AddressPrefix:     pulumi.String("10.1.0.0/16"),
 * 			NextHopType:       pulumi.String("VnetLocal"),
 * 		})
 * 		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.RouteTable;
 * import com.pulumi.azure.network.RouteTableArgs;
 * import com.pulumi.azure.network.Route;
 * import com.pulumi.azure.network.RouteArgs;
 * 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 exampleRouteTable = new RouteTable("exampleRouteTable", RouteTableArgs.builder()
 *             .name("acceptanceTestRouteTable1")
 *             .location(example.location())
 *             .resourceGroupName(example.name())
 *             .build());
 *         var exampleRoute = new Route("exampleRoute", RouteArgs.builder()
 *             .name("acceptanceTestRoute1")
 *             .resourceGroupName(example.name())
 *             .routeTableName(exampleRouteTable.name())
 *             .addressPrefix("10.1.0.0/16")
 *             .nextHopType("VnetLocal")
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   example:
 *     type: azure:core:ResourceGroup
 *     properties:
 *       name: example-resources
 *       location: West Europe
 *   exampleRouteTable:
 *     type: azure:network:RouteTable
 *     name: example
 *     properties:
 *       name: acceptanceTestRouteTable1
 *       location: ${example.location}
 *       resourceGroupName: ${example.name}
 *   exampleRoute:
 *     type: azure:network:Route
 *     name: example
 *     properties:
 *       name: acceptanceTestRoute1
 *       resourceGroupName: ${example.name}
 *       routeTableName: ${exampleRouteTable.name}
 *       addressPrefix: 10.1.0.0/16
 *       nextHopType: VnetLocal
 * ```
 * 
 * ## Import
 * Routes can be imported using the `resource id`, e.g.
 * ```sh
 * $ pulumi import azure:network/route:Route exampleRoute /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.Network/routeTables/mytable1/routes/myroute1
 * ```
 */
public class Route internal constructor(
    override val javaResource: com.pulumi.azure.network.Route,
) : KotlinCustomResource(javaResource, RouteMapper) {
    /**
     * The destination to which the route applies. Can be CIDR (such as `10.1.0.0/16`) or [Azure Service Tag](https://docs.microsoft.com/azure/virtual-network/service-tags-overview) (such as `ApiManagement`, `AzureBackup` or `AzureMonitor`) format.
     */
    public val addressPrefix: Output
        get() = javaResource.addressPrefix().applyValue({ args0 -> args0 })

    /**
     * The name of the route. Changing this forces a new resource to be created.
     */
    public val name: Output
        get() = javaResource.name().applyValue({ args0 -> args0 })

    /**
     * Contains the IP address packets should be forwarded to. Next hop values are only allowed in routes where the next hop type is `VirtualAppliance`.
     */
    public val nextHopInIpAddress: Output?
        get() = javaResource.nextHopInIpAddress().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * The type of Azure hop the packet should be sent to. Possible values are `VirtualNetworkGateway`, `VnetLocal`, `Internet`, `VirtualAppliance` and `None`.
     */
    public val nextHopType: Output
        get() = javaResource.nextHopType().applyValue({ args0 -> args0 })

    /**
     * The name of the resource group in which to create the route. Changing this forces a new resource to be created.
     */
    public val resourceGroupName: Output
        get() = javaResource.resourceGroupName().applyValue({ args0 -> args0 })

    /**
     * The name of the route table within which create the route. Changing this forces a new resource to be created.
     */
    public val routeTableName: Output
        get() = javaResource.routeTableName().applyValue({ args0 -> args0 })
}

public object RouteMapper : ResourceMapper {
    override fun supportsMappingOfType(javaResource: Resource): Boolean =
        com.pulumi.azure.network.Route::class == javaResource::class

    override fun map(javaResource: Resource): Route = Route(
        javaResource as
            com.pulumi.azure.network.Route,
    )
}

/**
 * @see [Route].
 * @param name The _unique_ name of the resulting resource.
 * @param block Builder for [Route].
 */
public suspend fun route(name: String, block: suspend RouteResourceBuilder.() -> Unit): Route {
    val builder = RouteResourceBuilder()
    builder.name(name)
    block(builder)
    return builder.build()
}

/**
 * @see [Route].
 * @param name The _unique_ name of the resulting resource.
 */
public fun route(name: String): Route {
    val builder = RouteResourceBuilder()
    builder.name(name)
    return builder.build()
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy