com.pulumi.gcp.networkconnectivity.kotlin.PolicyBasedRoute.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of pulumi-gcp-kotlin Show documentation
Show all versions of pulumi-gcp-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.gcp.networkconnectivity.kotlin
import com.pulumi.core.Output
import com.pulumi.gcp.networkconnectivity.kotlin.outputs.PolicyBasedRouteFilter
import com.pulumi.gcp.networkconnectivity.kotlin.outputs.PolicyBasedRouteInterconnectAttachment
import com.pulumi.gcp.networkconnectivity.kotlin.outputs.PolicyBasedRouteVirtualMachine
import com.pulumi.gcp.networkconnectivity.kotlin.outputs.PolicyBasedRouteWarning
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
import kotlin.collections.Map
import com.pulumi.gcp.networkconnectivity.kotlin.outputs.PolicyBasedRouteFilter.Companion.toKotlin as policyBasedRouteFilterToKotlin
import com.pulumi.gcp.networkconnectivity.kotlin.outputs.PolicyBasedRouteInterconnectAttachment.Companion.toKotlin as policyBasedRouteInterconnectAttachmentToKotlin
import com.pulumi.gcp.networkconnectivity.kotlin.outputs.PolicyBasedRouteVirtualMachine.Companion.toKotlin as policyBasedRouteVirtualMachineToKotlin
import com.pulumi.gcp.networkconnectivity.kotlin.outputs.PolicyBasedRouteWarning.Companion.toKotlin as policyBasedRouteWarningToKotlin
/**
* Builder for [PolicyBasedRoute].
*/
@PulumiTagMarker
public class PolicyBasedRouteResourceBuilder internal constructor() {
public var name: String? = null
public var args: PolicyBasedRouteArgs = PolicyBasedRouteArgs()
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 PolicyBasedRouteArgsBuilder.() -> Unit) {
val builder = PolicyBasedRouteArgsBuilder()
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(): PolicyBasedRoute {
val builtJavaResource =
com.pulumi.gcp.networkconnectivity.PolicyBasedRoute(
this.name,
this.args.toJava(),
this.opts.toJava(),
)
return PolicyBasedRoute(builtJavaResource)
}
}
/**
* Policy-based Routes are more powerful routes that route L4 network traffic based on not just destination IP, but also source IP, protocol and more. A Policy-based Route always take precedence when it conflicts with other types of routes.
* To get more information about PolicyBasedRoute, see:
* * [API documentation](https://cloud.google.com/network-connectivity/docs/reference/networkconnectivity/rest/v1/projects.locations.global.policyBasedRoutes)
* * How-to Guides
* * [Use policy-based routes](https://cloud.google.com/vpc/docs/use-policy-based-routes#api)
* ## Example Usage
* ### Network Connectivity Policy Based Route Basic
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
* const myNetwork = new gcp.compute.Network("my_network", {
* name: "my-network",
* autoCreateSubnetworks: false,
* });
* const _default = new gcp.networkconnectivity.PolicyBasedRoute("default", {
* name: "my-pbr",
* network: myNetwork.id,
* filter: {
* protocolVersion: "IPV4",
* },
* nextHopOtherRoutes: "DEFAULT_ROUTING",
* });
* ```
* ```python
* import pulumi
* import pulumi_gcp as gcp
* my_network = gcp.compute.Network("my_network",
* name="my-network",
* auto_create_subnetworks=False)
* default = gcp.networkconnectivity.PolicyBasedRoute("default",
* name="my-pbr",
* network=my_network.id,
* filter=gcp.networkconnectivity.PolicyBasedRouteFilterArgs(
* protocol_version="IPV4",
* ),
* next_hop_other_routes="DEFAULT_ROUTING")
* ```
* ```csharp
* using System.Collections.Generic;
* using System.Linq;
* using Pulumi;
* using Gcp = Pulumi.Gcp;
* return await Deployment.RunAsync(() =>
* {
* var myNetwork = new Gcp.Compute.Network("my_network", new()
* {
* Name = "my-network",
* AutoCreateSubnetworks = false,
* });
* var @default = new Gcp.NetworkConnectivity.PolicyBasedRoute("default", new()
* {
* Name = "my-pbr",
* Network = myNetwork.Id,
* Filter = new Gcp.NetworkConnectivity.Inputs.PolicyBasedRouteFilterArgs
* {
* ProtocolVersion = "IPV4",
* },
* NextHopOtherRoutes = "DEFAULT_ROUTING",
* });
* });
* ```
* ```go
* package main
* import (
* "github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/compute"
* "github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/networkconnectivity"
* "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
* )
* func main() {
* pulumi.Run(func(ctx *pulumi.Context) error {
* myNetwork, err := compute.NewNetwork(ctx, "my_network", &compute.NetworkArgs{
* Name: pulumi.String("my-network"),
* AutoCreateSubnetworks: pulumi.Bool(false),
* })
* if err != nil {
* return err
* }
* _, err = networkconnectivity.NewPolicyBasedRoute(ctx, "default", &networkconnectivity.PolicyBasedRouteArgs{
* Name: pulumi.String("my-pbr"),
* Network: myNetwork.ID(),
* Filter: &networkconnectivity.PolicyBasedRouteFilterArgs{
* ProtocolVersion: pulumi.String("IPV4"),
* },
* NextHopOtherRoutes: pulumi.String("DEFAULT_ROUTING"),
* })
* 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.gcp.compute.Network;
* import com.pulumi.gcp.compute.NetworkArgs;
* import com.pulumi.gcp.networkconnectivity.PolicyBasedRoute;
* import com.pulumi.gcp.networkconnectivity.PolicyBasedRouteArgs;
* import com.pulumi.gcp.networkconnectivity.inputs.PolicyBasedRouteFilterArgs;
* 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 myNetwork = new Network("myNetwork", NetworkArgs.builder()
* .name("my-network")
* .autoCreateSubnetworks(false)
* .build());
* var default_ = new PolicyBasedRoute("default", PolicyBasedRouteArgs.builder()
* .name("my-pbr")
* .network(myNetwork.id())
* .filter(PolicyBasedRouteFilterArgs.builder()
* .protocolVersion("IPV4")
* .build())
* .nextHopOtherRoutes("DEFAULT_ROUTING")
* .build());
* }
* }
* ```
* ```yaml
* resources:
* default:
* type: gcp:networkconnectivity:PolicyBasedRoute
* properties:
* name: my-pbr
* network: ${myNetwork.id}
* filter:
* protocolVersion: IPV4
* nextHopOtherRoutes: DEFAULT_ROUTING
* myNetwork:
* type: gcp:compute:Network
* name: my_network
* properties:
* name: my-network
* autoCreateSubnetworks: false
* ```
*
* ### Network Connectivity Policy Based Route Full
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
* const myNetwork = new gcp.compute.Network("my_network", {
* name: "my-network",
* autoCreateSubnetworks: false,
* });
* // This example substitutes an arbitrary internal IP for an internal network
* // load balancer for brevity. Consult https://cloud.google.com/load-balancing/docs/internal
* // to set one up.
* const ilb = new gcp.compute.GlobalAddress("ilb", {name: "my-ilb"});
* const _default = new gcp.networkconnectivity.PolicyBasedRoute("default", {
* name: "my-pbr",
* description: "My routing policy",
* network: myNetwork.id,
* priority: 2302,
* filter: {
* protocolVersion: "IPV4",
* ipProtocol: "UDP",
* srcRange: "10.0.0.0/24",
* destRange: "0.0.0.0/0",
* },
* nextHopIlbIp: ilb.address,
* virtualMachine: {
* tags: ["restricted"],
* },
* labels: {
* env: "default",
* },
* });
* ```
* ```python
* import pulumi
* import pulumi_gcp as gcp
* my_network = gcp.compute.Network("my_network",
* name="my-network",
* auto_create_subnetworks=False)
* # This example substitutes an arbitrary internal IP for an internal network
* # load balancer for brevity. Consult https://cloud.google.com/load-balancing/docs/internal
* # to set one up.
* ilb = gcp.compute.GlobalAddress("ilb", name="my-ilb")
* default = gcp.networkconnectivity.PolicyBasedRoute("default",
* name="my-pbr",
* description="My routing policy",
* network=my_network.id,
* priority=2302,
* filter=gcp.networkconnectivity.PolicyBasedRouteFilterArgs(
* protocol_version="IPV4",
* ip_protocol="UDP",
* src_range="10.0.0.0/24",
* dest_range="0.0.0.0/0",
* ),
* next_hop_ilb_ip=ilb.address,
* virtual_machine=gcp.networkconnectivity.PolicyBasedRouteVirtualMachineArgs(
* tags=["restricted"],
* ),
* labels={
* "env": "default",
* })
* ```
* ```csharp
* using System.Collections.Generic;
* using System.Linq;
* using Pulumi;
* using Gcp = Pulumi.Gcp;
* return await Deployment.RunAsync(() =>
* {
* var myNetwork = new Gcp.Compute.Network("my_network", new()
* {
* Name = "my-network",
* AutoCreateSubnetworks = false,
* });
* // This example substitutes an arbitrary internal IP for an internal network
* // load balancer for brevity. Consult https://cloud.google.com/load-balancing/docs/internal
* // to set one up.
* var ilb = new Gcp.Compute.GlobalAddress("ilb", new()
* {
* Name = "my-ilb",
* });
* var @default = new Gcp.NetworkConnectivity.PolicyBasedRoute("default", new()
* {
* Name = "my-pbr",
* Description = "My routing policy",
* Network = myNetwork.Id,
* Priority = 2302,
* Filter = new Gcp.NetworkConnectivity.Inputs.PolicyBasedRouteFilterArgs
* {
* ProtocolVersion = "IPV4",
* IpProtocol = "UDP",
* SrcRange = "10.0.0.0/24",
* DestRange = "0.0.0.0/0",
* },
* NextHopIlbIp = ilb.Address,
* VirtualMachine = new Gcp.NetworkConnectivity.Inputs.PolicyBasedRouteVirtualMachineArgs
* {
* Tags = new[]
* {
* "restricted",
* },
* },
* Labels =
* {
* { "env", "default" },
* },
* });
* });
* ```
* ```go
* package main
* import (
* "github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/compute"
* "github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/networkconnectivity"
* "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
* )
* func main() {
* pulumi.Run(func(ctx *pulumi.Context) error {
* myNetwork, err := compute.NewNetwork(ctx, "my_network", &compute.NetworkArgs{
* Name: pulumi.String("my-network"),
* AutoCreateSubnetworks: pulumi.Bool(false),
* })
* if err != nil {
* return err
* }
* // This example substitutes an arbitrary internal IP for an internal network
* // load balancer for brevity. Consult https://cloud.google.com/load-balancing/docs/internal
* // to set one up.
* ilb, err := compute.NewGlobalAddress(ctx, "ilb", &compute.GlobalAddressArgs{
* Name: pulumi.String("my-ilb"),
* })
* if err != nil {
* return err
* }
* _, err = networkconnectivity.NewPolicyBasedRoute(ctx, "default", &networkconnectivity.PolicyBasedRouteArgs{
* Name: pulumi.String("my-pbr"),
* Description: pulumi.String("My routing policy"),
* Network: myNetwork.ID(),
* Priority: pulumi.Int(2302),
* Filter: &networkconnectivity.PolicyBasedRouteFilterArgs{
* ProtocolVersion: pulumi.String("IPV4"),
* IpProtocol: pulumi.String("UDP"),
* SrcRange: pulumi.String("10.0.0.0/24"),
* DestRange: pulumi.String("0.0.0.0/0"),
* },
* NextHopIlbIp: ilb.Address,
* VirtualMachine: &networkconnectivity.PolicyBasedRouteVirtualMachineArgs{
* Tags: pulumi.StringArray{
* pulumi.String("restricted"),
* },
* },
* Labels: pulumi.StringMap{
* "env": pulumi.String("default"),
* },
* })
* 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.gcp.compute.Network;
* import com.pulumi.gcp.compute.NetworkArgs;
* import com.pulumi.gcp.compute.GlobalAddress;
* import com.pulumi.gcp.compute.GlobalAddressArgs;
* import com.pulumi.gcp.networkconnectivity.PolicyBasedRoute;
* import com.pulumi.gcp.networkconnectivity.PolicyBasedRouteArgs;
* import com.pulumi.gcp.networkconnectivity.inputs.PolicyBasedRouteFilterArgs;
* import com.pulumi.gcp.networkconnectivity.inputs.PolicyBasedRouteVirtualMachineArgs;
* 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 myNetwork = new Network("myNetwork", NetworkArgs.builder()
* .name("my-network")
* .autoCreateSubnetworks(false)
* .build());
* // This example substitutes an arbitrary internal IP for an internal network
* // load balancer for brevity. Consult https://cloud.google.com/load-balancing/docs/internal
* // to set one up.
* var ilb = new GlobalAddress("ilb", GlobalAddressArgs.builder()
* .name("my-ilb")
* .build());
* var default_ = new PolicyBasedRoute("default", PolicyBasedRouteArgs.builder()
* .name("my-pbr")
* .description("My routing policy")
* .network(myNetwork.id())
* .priority(2302)
* .filter(PolicyBasedRouteFilterArgs.builder()
* .protocolVersion("IPV4")
* .ipProtocol("UDP")
* .srcRange("10.0.0.0/24")
* .destRange("0.0.0.0/0")
* .build())
* .nextHopIlbIp(ilb.address())
* .virtualMachine(PolicyBasedRouteVirtualMachineArgs.builder()
* .tags("restricted")
* .build())
* .labels(Map.of("env", "default"))
* .build());
* }
* }
* ```
* ```yaml
* resources:
* default:
* type: gcp:networkconnectivity:PolicyBasedRoute
* properties:
* name: my-pbr
* description: My routing policy
* network: ${myNetwork.id}
* priority: 2302
* filter:
* protocolVersion: IPV4
* ipProtocol: UDP
* srcRange: 10.0.0.0/24
* destRange: 0.0.0.0/0
* nextHopIlbIp: ${ilb.address}
* virtualMachine:
* tags:
* - restricted
* labels:
* env: default
* myNetwork:
* type: gcp:compute:Network
* name: my_network
* properties:
* name: my-network
* autoCreateSubnetworks: false
* # This example substitutes an arbitrary internal IP for an internal network
* # load balancer for brevity. Consult https://cloud.google.com/load-balancing/docs/internal
* # to set one up.
* ilb:
* type: gcp:compute:GlobalAddress
* properties:
* name: my-ilb
* ```
*
* ## Import
* PolicyBasedRoute can be imported using any of these accepted formats:
* * `projects/{{project}}/locations/global/policyBasedRoutes/{{name}}`
* * `{{project}}/{{name}}`
* * `{{name}}`
* When using the `pulumi import` command, PolicyBasedRoute can be imported using one of the formats above. For example:
* ```sh
* $ pulumi import gcp:networkconnectivity/policyBasedRoute:PolicyBasedRoute default projects/{{project}}/locations/global/policyBasedRoutes/{{name}}
* ```
* ```sh
* $ pulumi import gcp:networkconnectivity/policyBasedRoute:PolicyBasedRoute default {{project}}/{{name}}
* ```
* ```sh
* $ pulumi import gcp:networkconnectivity/policyBasedRoute:PolicyBasedRoute default {{name}}
* ```
*/
public class PolicyBasedRoute internal constructor(
override val javaResource: com.pulumi.gcp.networkconnectivity.PolicyBasedRoute,
) : KotlinCustomResource(javaResource, PolicyBasedRouteMapper) {
/**
* Time when the policy-based route was created.
*/
public val createTime: Output
get() = javaResource.createTime().applyValue({ args0 -> args0 })
/**
* An optional description of this resource.
*/
public val description: Output?
get() = javaResource.description().applyValue({ args0 ->
args0.map({ args0 ->
args0
}).orElse(null)
})
/**
* All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Pulumi, other clients and services.
*/
public val effectiveLabels: Output
© 2015 - 2025 Weber Informatics LLC | Privacy Policy