RouterRoutePolicy class
A route policy created in a router
To get more information about RouterRoutePolicy, see:
- API documentation
- How-to Guides
- Google Cloud Router
Example Usage
Router Route Policy Export
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";
const net = new gcp.compute.Network("net", {
name: "my-network",
autoCreateSubnetworks: false,
});
const subnet = new gcp.compute.Subnetwork("subnet", {
name: "my-subnetwork",
network: net.id,
ipCidrRange: "10.0.0.0/16",
region: "us-central1",
});
const router = new gcp.compute.Router("router", {
name: "my-router",
region: subnet.region,
network: net.id,
});
const rp_export = new gcp.compute.RouterRoutePolicy("rp-export", {
router: router.name,
region: router.region,
name: "my-rp1",
type: "ROUTE_POLICY_TYPE_EXPORT",
terms: [{
priority: 1,
match: {
expression: "destination == '10.0.0.0/12'",
},
actions: [{
expression: "accept()",
}],
}],
});
import pulumi
import pulumi_gcp as gcp
net = gcp.compute.Network("net",
name="my-network",
auto_create_subnetworks=False)
subnet = gcp.compute.Subnetwork("subnet",
name="my-subnetwork",
network=net.id,
ip_cidr_range="10.0.0.0/16",
region="us-central1")
router = gcp.compute.Router("router",
name="my-router",
region=subnet.region,
network=net.id)
rp_export = gcp.compute.RouterRoutePolicy("rp-export",
router=router.name,
region=router.region,
name="my-rp1",
type="ROUTE_POLICY_TYPE_EXPORT",
terms=[{
"priority": 1,
"match": {
"expression": "destination == '10.0.0.0/12'",
},
"actions": [{
"expression": "accept()",
}],
}])
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Gcp = Pulumi.Gcp;
return await Deployment.RunAsync(() =>
{
var net = new Gcp.Compute.Network("net", new()
{
Name = "my-network",
AutoCreateSubnetworks = false,
});
var subnet = new Gcp.Compute.Subnetwork("subnet", new()
{
Name = "my-subnetwork",
Network = net.Id,
IpCidrRange = "10.0.0.0/16",
Region = "us-central1",
});
var router = new Gcp.Compute.Router("router", new()
{
Name = "my-router",
Region = subnet.Region,
Network = net.Id,
});
var rp_export = new Gcp.Compute.RouterRoutePolicy("rp-export", new()
{
Router = router.Name,
Region = router.Region,
Name = "my-rp1",
Type = "ROUTE_POLICY_TYPE_EXPORT",
Terms = new[]
{
new Gcp.Compute.Inputs.RouterRoutePolicyTermArgs
{
Priority = 1,
Match = new Gcp.Compute.Inputs.RouterRoutePolicyTermMatchArgs
{
Expression = "destination == '10.0.0.0/12'",
},
Actions = new[]
{
new Gcp.Compute.Inputs.RouterRoutePolicyTermActionArgs
{
Expression = "accept()",
},
},
},
},
});
});
package main
import (
"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/compute"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
net, err := compute.NewNetwork(ctx, "net", &compute.NetworkArgs{
Name: pulumi.String("my-network"),
AutoCreateSubnetworks: pulumi.Bool(false),
})
if err != nil {
return err
}
subnet, err := compute.NewSubnetwork(ctx, "subnet", &compute.SubnetworkArgs{
Name: pulumi.String("my-subnetwork"),
Network: net.ID().ToIDOutput().ToStringOutput(),
IpCidrRange: pulumi.String("10.0.0.0/16"),
Region: pulumi.String("us-central1"),
})
if err != nil {
return err
}
router, err := compute.NewRouter(ctx, "router", &compute.RouterArgs{
Name: pulumi.String("my-router"),
Region: subnet.Region,
Network: net.ID().ToIDOutput().ToStringOutput(),
})
if err != nil {
return err
}
_, err = compute.NewRouterRoutePolicy(ctx, "rp-export", &compute.RouterRoutePolicyArgs{
Router: router.Name,
Region: router.Region,
Name: pulumi.String("my-rp1"),
Type: pulumi.String("ROUTE_POLICY_TYPE_EXPORT"),
Terms: compute.RouterRoutePolicyTermArray{
&compute.RouterRoutePolicyTermArgs{
Priority: pulumi.Int(1),
Match: &compute.RouterRoutePolicyTermMatchArgs{
Expression: pulumi.String("destination == '10.0.0.0/12'"),
},
Actions: compute.RouterRoutePolicyTermActionArray{
&compute.RouterRoutePolicyTermActionArgs{
Expression: pulumi.String("accept()"),
},
},
},
},
})
if err != nil {
return err
}
return nil
})
}
pulumi {
required_providers {
gcp = {
source = "pulumi/gcp"
}
}
}
resource "gcp_compute_network" "net" {
name = "my-network"
auto_create_subnetworks = false
}
resource "gcp_compute_subnetwork" "subnet" {
name = "my-subnetwork"
network = gcp_compute_network.net.id
ip_cidr_range = "10.0.0.0/16"
region = "us-central1"
}
resource "gcp_compute_router" "router" {
name = "my-router"
region = gcp_compute_subnetwork.subnet.region
network = gcp_compute_network.net.id
}
resource "gcp_compute_routerroutepolicy" "rp-export" {
router = gcp_compute_router.router.name
region = gcp_compute_router.router.region
name = "my-rp1"
type = "ROUTE_POLICY_TYPE_EXPORT"
terms {
priority = 1
match = {
expression = "destination == '10.0.0.0/12'"
}
actions {
expression = "accept()"
}
}
}
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.Subnetwork;
import com.pulumi.gcp.compute.SubnetworkArgs;
import com.pulumi.gcp.compute.Router;
import com.pulumi.gcp.compute.RouterArgs;
import com.pulumi.gcp.compute.RouterRoutePolicy;
import com.pulumi.gcp.compute.RouterRoutePolicyArgs;
import com.pulumi.gcp.compute.inputs.RouterRoutePolicyTermArgs;
import com.pulumi.gcp.compute.inputs.RouterRoutePolicyTermMatchArgs;
import com.pulumi.gcp.compute.inputs.RouterRoutePolicyTermActionArgs;
import java.util.ArrayList;
import java.util.Arrays;
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 net = new Network("net", NetworkArgs.builder()
.name("my-network")
.autoCreateSubnetworks(false)
.build());
var subnet = new Subnetwork("subnet", SubnetworkArgs.builder()
.name("my-subnetwork")
.network(net.id())
.ipCidrRange("10.0.0.0/16")
.region("us-central1")
.build());
var router = new Router("router", RouterArgs.builder()
.name("my-router")
.region(subnet.region())
.network(net.id())
.build());
var rp_export = new RouterRoutePolicy("rp-export", RouterRoutePolicyArgs.builder()
.router(router.name())
.region(router.region())
.name("my-rp1")
.type("ROUTE_POLICY_TYPE_EXPORT")
.terms(RouterRoutePolicyTermArgs.builder()
.priority(1)
.match(RouterRoutePolicyTermMatchArgs.builder()
.expression("destination == '10.0.0.0/12'")
.build())
.actions(RouterRoutePolicyTermActionArgs.builder()
.expression("accept()")
.build())
.build())
.build());
}
}
resources:
net:
type: gcp:compute:Network
properties:
name: my-network
autoCreateSubnetworks: false
subnet:
type: gcp:compute:Subnetwork
properties:
name: my-subnetwork
network: ${net.id}
ipCidrRange: 10.0.0.0/16
region: us-central1
router:
type: gcp:compute:Router
properties:
name: my-router
region: ${subnet.region}
network: ${net.id}
rp-export:
type: gcp:compute:RouterRoutePolicy
properties:
router: ${router.name}
region: ${router.region}
name: my-rp1
type: ROUTE_POLICY_TYPE_EXPORT
terms:
- priority: 1
match:
expression: destination == '10.0.0.0/12'
actions:
- expression: accept()
Router Route Policy Import
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";
const net = new gcp.compute.Network("net", {
name: "my-network",
autoCreateSubnetworks: false,
});
const subnet = new gcp.compute.Subnetwork("subnet", {
name: "my-subnetwork",
network: net.id,
ipCidrRange: "10.0.0.0/16",
region: "us-central1",
});
const router = new gcp.compute.Router("router", {
name: "my-router",
region: subnet.region,
network: net.id,
});
const rp_import = new gcp.compute.RouterRoutePolicy("rp-import", {
name: "my-rp2",
router: router.name,
region: router.region,
type: "ROUTE_POLICY_TYPE_IMPORT",
terms: [{
priority: 2,
match: {
expression: "destination == '10.0.0.0/12'",
},
actions: [{
expression: "accept()",
}],
}],
});
import pulumi
import pulumi_gcp as gcp
net = gcp.compute.Network("net",
name="my-network",
auto_create_subnetworks=False)
subnet = gcp.compute.Subnetwork("subnet",
name="my-subnetwork",
network=net.id,
ip_cidr_range="10.0.0.0/16",
region="us-central1")
router = gcp.compute.Router("router",
name="my-router",
region=subnet.region,
network=net.id)
rp_import = gcp.compute.RouterRoutePolicy("rp-import",
name="my-rp2",
router=router.name,
region=router.region,
type="ROUTE_POLICY_TYPE_IMPORT",
terms=[{
"priority": 2,
"match": {
"expression": "destination == '10.0.0.0/12'",
},
"actions": [{
"expression": "accept()",
}],
}])
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Gcp = Pulumi.Gcp;
return await Deployment.RunAsync(() =>
{
var net = new Gcp.Compute.Network("net", new()
{
Name = "my-network",
AutoCreateSubnetworks = false,
});
var subnet = new Gcp.Compute.Subnetwork("subnet", new()
{
Name = "my-subnetwork",
Network = net.Id,
IpCidrRange = "10.0.0.0/16",
Region = "us-central1",
});
var router = new Gcp.Compute.Router("router", new()
{
Name = "my-router",
Region = subnet.Region,
Network = net.Id,
});
var rp_import = new Gcp.Compute.RouterRoutePolicy("rp-import", new()
{
Name = "my-rp2",
Router = router.Name,
Region = router.Region,
Type = "ROUTE_POLICY_TYPE_IMPORT",
Terms = new[]
{
new Gcp.Compute.Inputs.RouterRoutePolicyTermArgs
{
Priority = 2,
Match = new Gcp.Compute.Inputs.RouterRoutePolicyTermMatchArgs
{
Expression = "destination == '10.0.0.0/12'",
},
Actions = new[]
{
new Gcp.Compute.Inputs.RouterRoutePolicyTermActionArgs
{
Expression = "accept()",
},
},
},
},
});
});
package main
import (
"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/compute"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
net, err := compute.NewNetwork(ctx, "net", &compute.NetworkArgs{
Name: pulumi.String("my-network"),
AutoCreateSubnetworks: pulumi.Bool(false),
})
if err != nil {
return err
}
subnet, err := compute.NewSubnetwork(ctx, "subnet", &compute.SubnetworkArgs{
Name: pulumi.String("my-subnetwork"),
Network: net.ID().ToIDOutput().ToStringOutput(),
IpCidrRange: pulumi.String("10.0.0.0/16"),
Region: pulumi.String("us-central1"),
})
if err != nil {
return err
}
router, err := compute.NewRouter(ctx, "router", &compute.RouterArgs{
Name: pulumi.String("my-router"),
Region: subnet.Region,
Network: net.ID().ToIDOutput().ToStringOutput(),
})
if err != nil {
return err
}
_, err = compute.NewRouterRoutePolicy(ctx, "rp-import", &compute.RouterRoutePolicyArgs{
Name: pulumi.String("my-rp2"),
Router: router.Name,
Region: router.Region,
Type: pulumi.String("ROUTE_POLICY_TYPE_IMPORT"),
Terms: compute.RouterRoutePolicyTermArray{
&compute.RouterRoutePolicyTermArgs{
Priority: pulumi.Int(2),
Match: &compute.RouterRoutePolicyTermMatchArgs{
Expression: pulumi.String("destination == '10.0.0.0/12'"),
},
Actions: compute.RouterRoutePolicyTermActionArray{
&compute.RouterRoutePolicyTermActionArgs{
Expression: pulumi.String("accept()"),
},
},
},
},
})
if err != nil {
return err
}
return nil
})
}
pulumi {
required_providers {
gcp = {
source = "pulumi/gcp"
}
}
}
resource "gcp_compute_network" "net" {
name = "my-network"
auto_create_subnetworks = false
}
resource "gcp_compute_subnetwork" "subnet" {
name = "my-subnetwork"
network = gcp_compute_network.net.id
ip_cidr_range = "10.0.0.0/16"
region = "us-central1"
}
resource "gcp_compute_router" "router" {
name = "my-router"
region = gcp_compute_subnetwork.subnet.region
network = gcp_compute_network.net.id
}
resource "gcp_compute_routerroutepolicy" "rp-import" {
name = "my-rp2"
router = gcp_compute_router.router.name
region = gcp_compute_router.router.region
type = "ROUTE_POLICY_TYPE_IMPORT"
terms {
priority = 2
match = {
expression = "destination == '10.0.0.0/12'"
}
actions {
expression = "accept()"
}
}
}
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.Subnetwork;
import com.pulumi.gcp.compute.SubnetworkArgs;
import com.pulumi.gcp.compute.Router;
import com.pulumi.gcp.compute.RouterArgs;
import com.pulumi.gcp.compute.RouterRoutePolicy;
import com.pulumi.gcp.compute.RouterRoutePolicyArgs;
import com.pulumi.gcp.compute.inputs.RouterRoutePolicyTermArgs;
import com.pulumi.gcp.compute.inputs.RouterRoutePolicyTermMatchArgs;
import com.pulumi.gcp.compute.inputs.RouterRoutePolicyTermActionArgs;
import java.util.ArrayList;
import java.util.Arrays;
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 net = new Network("net", NetworkArgs.builder()
.name("my-network")
.autoCreateSubnetworks(false)
.build());
var subnet = new Subnetwork("subnet", SubnetworkArgs.builder()
.name("my-subnetwork")
.network(net.id())
.ipCidrRange("10.0.0.0/16")
.region("us-central1")
.build());
var router = new Router("router", RouterArgs.builder()
.name("my-router")
.region(subnet.region())
.network(net.id())
.build());
var rp_import = new RouterRoutePolicy("rp-import", RouterRoutePolicyArgs.builder()
.name("my-rp2")
.router(router.name())
.region(router.region())
.type("ROUTE_POLICY_TYPE_IMPORT")
.terms(RouterRoutePolicyTermArgs.builder()
.priority(2)
.match(RouterRoutePolicyTermMatchArgs.builder()
.expression("destination == '10.0.0.0/12'")
.build())
.actions(RouterRoutePolicyTermActionArgs.builder()
.expression("accept()")
.build())
.build())
.build());
}
}
resources:
net:
type: gcp:compute:Network
properties:
name: my-network
autoCreateSubnetworks: false
subnet:
type: gcp:compute:Subnetwork
properties:
name: my-subnetwork
network: ${net.id}
ipCidrRange: 10.0.0.0/16
region: us-central1
router:
type: gcp:compute:Router
properties:
name: my-router
region: ${subnet.region}
network: ${net.id}
rp-import:
type: gcp:compute:RouterRoutePolicy
properties:
name: my-rp2
router: ${router.name}
region: ${router.region}
type: ROUTE_POLICY_TYPE_IMPORT
terms:
- priority: 2
match:
expression: destination == '10.0.0.0/12'
actions:
- expression: accept()
Import
RouterRoutePolicy can be imported using any of these accepted formats:
{{project}}/{{region}}/{{router}}/routePolicies/{{name}}{{project}}/{{region}}/{{router}}/{{name}}{{region}}/{{router}}/{{name}}{{router}}/{{name}}
When using the pulumi import command, RouterRoutePolicy can be imported using one of the formats above. For example:
$ pulumi import gcp:compute/routerRoutePolicy:RouterRoutePolicy default {{project}}/{{region}}/{{router}}/routePolicies/{{name}}
$ pulumi import gcp:compute/routerRoutePolicy:RouterRoutePolicy default {{project}}/{{region}}/{{router}}/{{name}}
$ pulumi import gcp:compute/routerRoutePolicy:RouterRoutePolicy default {{region}}/{{router}}/{{name}}
$ pulumi import gcp:compute/routerRoutePolicy:RouterRoutePolicy default {{router}}/{{name}}
Constructors
- RouterRoutePolicy(String name, {RouterRoutePolicyArgs? args, CustomResourceOptions? options})
-
Creates a new RouterRoutePolicy.
nameThe Pulumi resource name.argsArguments used to configure this RouterRoutePolicy. The set of arguments for RouterRoutePolicy.optionsResource options controlling this resource's behavior. - RouterRoutePolicy.reference(String urn)
- Creates a typed reference to an existing RouterRoutePolicy resource.
Properties
-
childResources
→ Set<
Resource> -
finalinherited
-
completionSources
↔ Map<
String, IOutputCompletionSource> -
latefinalinherited
-
deletionPolicy
↔ Output<
String> -
Whether Terraform will be prevented from destroying the resource. Defaults to DELETE.
When a 'terraform destroy' or 'pulumi up' would delete the resource,
the command will fail if this field is set to "PREVENT" in Terraform state.
When set to "ABANDON", the command will remove the resource from Terraform
management without updating or deleting the resource in the API.
When set to "DELETE", deleting the resource is allowed.
latefinal
-
fingerprint
↔ Output<
String> -
The fingerprint used for optimistic locking of this resource. Used
internally during updates.
latefinal
- hashCode → int
-
The hash code for this object.
no setterinherited
-
id
↔ Output<
String> -
getter/setter pairinherited
- isCustom → bool
-
Returns whether this resource is provider-managed.
no setterinherited
- isProtected → bool
-
Returns whether this resource is protected from deletion.
no setterinherited
- isRemote → bool
-
Whether this resource is registered as remote.
no setterinherited
- isResourceReference → bool
-
Whether this instance represents a resource value returned over RPC.
finalinherited
-
name
↔ Output<
String> -
Name of the route policy. This policy's name, which must be a resource ID segment and unique within all policies owned by the Router
latefinal
-
project
↔ Output<
String> -
The ID of the project in which the resource belongs.
If it is not provided, the provider project is used.
latefinal
-
region
↔ Output<
String> -
Region where the router and NAT reside.
latefinal
-
resourceTransforms
→ List<
ResourceTransform> -
Inherited/explicit async transforms.
no setterinherited
-
router
↔ Output<
String> -
The name of the Cloud Router in which this route policy will be configured.
latefinal
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
terms
↔ Output<
List< RouterRoutePolicyTerm> > -
List of terms (the order in the list is not important, they are evaluated in order of priority).
Structure is documented below.
latefinal
-
transformations
→ List<
ResourceTransformation> -
Inherited/explicit legacy transformations.
no setterinherited
-
type
↔ Output<
String?> -
This is policy's type, which is one of IMPORT or EXPORT
Possible values are:
ROUTE_POLICY_TYPE_IMPORT,ROUTE_POLICY_TYPE_EXPORT.latefinal -
urn
↔ Output<
String> -
latefinalinherited
Methods
-
failId(
Object error) → void -
Completes this resource ID with an error when registration fails.
inherited
-
failOutputs(
Object error) → void -
Completes all output properties with
error.inherited -
failUrn(
Object error) → void -
Completes this resource URN with an error when registration fails.
inherited
-
getProvider(
String moduleMember) → ProviderResource? -
Returns provider for
moduleMember's package, if configured.inherited -
getResourceName(
) → String -
Returns this resource's logical name.
inherited
-
getResourceType(
) → String -
Returns this resource's Pulumi type token.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
registerOutput<
T> (String propertyName, {Object? decoder(Object?)?, bool isSecret = false}) → Output< T> -
Registers a dynamic output property for this resource.
inherited
-
resolveId(
String? value, {required bool isKnown}) → void -
Resolves the provider-assigned ID for this resource.
inherited
-
resolveOutputs(
Struct outputs) → void -
Resolves all output properties from a monitor response payload.
inherited
-
resolveUrn(
String value) → void -
Resolves this resource's URN once assigned by the engine.
inherited
-
serializeProperties(
Map< String, dynamic> properties) → Future<Struct> -
Serializes resource properties for RPC transmission.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
get(
String name, Input< String> id, {RouterRoutePolicyState? state, CustomResourceOptions? options}) → RouterRoutePolicy -
Gets an existing RouterRoutePolicy resource's state with the given
nameandid.