blob: 95b6ada89cb942bbb8c2c7c005b21256b51c2cd8 [file] [log] [blame]
---
# ----------------------------------------------------------------------------
#
# *** AUTO GENERATED CODE *** Type: MMv1 ***
#
# ----------------------------------------------------------------------------
#
# This file is automatically generated by Magic Modules and manual
# changes will be clobbered when the file is regenerated.
#
# Please read more about how to change this file in
# .github/CONTRIBUTING.md.
#
# ----------------------------------------------------------------------------
subcategory: "Compute Engine"
description: |-
A route policy created in a router
---
# google_compute_router_route_policy
A route policy created in a router
~> **Warning:** This resource is in beta, and should be used with the terraform-provider-google-beta provider.
See [Provider Versions](https://terraform.io/docs/providers/google/guides/provider_versions.html) for more details on beta resources.
To get more information about RouterRoutePolicy, see:
* [API documentation](https://cloud.google.com/compute/docs/reference/rest/v1/routers)
* How-to Guides
* [Google Cloud Router](https://cloud.google.com/router/docs/)
<div class = "oics-button" style="float: right; margin: 0 0 -15px">
<a href="https://console.cloud.google.com/cloudshell/open?cloudshell_git_repo=https%3A%2F%2Fgithub.com%2Fterraform-google-modules%2Fdocs-examples.git&cloudshell_image=gcr.io%2Fcloudshell-images%2Fcloudshell%3Alatest&cloudshell_print=.%2Fmotd&cloudshell_tutorial=.%2Ftutorial.md&cloudshell_working_dir=router_route_policy_export&open_in_editor=main.tf" target="_blank">
<img alt="Open in Cloud Shell" src="//gstatic.com/cloudssh/images/open-btn.svg" style="max-height: 44px; margin: 32px auto; max-width: 100%;">
</a>
</div>
## Example Usage - Router Route Policy Export
```hcl
resource "google_compute_network" "net" {
provider = google-beta
name = "my-network"
auto_create_subnetworks = false
}
resource "google_compute_subnetwork" "subnet" {
provider = google-beta
name = "my-subnetwork"
network = google_compute_network.net.id
ip_cidr_range = "10.0.0.0/16"
region = "us-central1"
}
resource "google_compute_router" "router" {
provider = google-beta
name = "my-router"
region = google_compute_subnetwork.subnet.region
network = google_compute_network.net.id
}
resource "google_compute_router_route_policy" "rp-export" {
provider = google-beta
router = google_compute_router.router.name
region = google_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()"
}
}
}
```
<div class = "oics-button" style="float: right; margin: 0 0 -15px">
<a href="https://console.cloud.google.com/cloudshell/open?cloudshell_git_repo=https%3A%2F%2Fgithub.com%2Fterraform-google-modules%2Fdocs-examples.git&cloudshell_image=gcr.io%2Fcloudshell-images%2Fcloudshell%3Alatest&cloudshell_print=.%2Fmotd&cloudshell_tutorial=.%2Ftutorial.md&cloudshell_working_dir=router_route_policy_import&open_in_editor=main.tf" target="_blank">
<img alt="Open in Cloud Shell" src="//gstatic.com/cloudssh/images/open-btn.svg" style="max-height: 44px; margin: 32px auto; max-width: 100%;">
</a>
</div>
## Example Usage - Router Route Policy Import
```hcl
resource "google_compute_network" "net" {
provider = google-beta
name = "my-network"
auto_create_subnetworks = false
}
resource "google_compute_subnetwork" "subnet" {
provider = google-beta
name = "my-subnetwork"
network = google_compute_network.net.id
ip_cidr_range = "10.0.0.0/16"
region = "us-central1"
}
resource "google_compute_router" "router" {
provider = google-beta
name = "my-router"
region = google_compute_subnetwork.subnet.region
network = google_compute_network.net.id
}
resource "google_compute_router_route_policy" "rp-import" {
provider = google-beta
name = "my-rp2"
router = google_compute_router.router.name
region = google_compute_router.router.region
type = "ROUTE_POLICY_TYPE_IMPORT"
terms {
priority = 2
match {
expression = "destination == '10.0.0.0/12'"
}
actions {
expression = "accept()"
}
}
}
```
## Argument Reference
The following arguments are supported:
* `terms` -
(Required)
List of terms (the order in the list is not important, they are evaluated in order of priority).
Structure is [documented below](#nested_terms).
* `router` -
(Required)
The name of the Cloud Router in which this route policy will be configured.
* `name` -
(Required)
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
<a name="nested_terms"></a>The `terms` block supports:
* `priority` -
(Required)
The evaluation priority for this term, which must be between 0 (inclusive) and 231 (exclusive), and unique within the list.
* `match` -
(Optional)
CEL expression evaluated against a route to determine if this term applies (see Policy Language). When not set, the term applies to all routes.
Structure is [documented below](#nested_match).
* `actions` -
(Optional)
'CEL expressions to evaluate to modify a route when this term matches.'\
Structure is [documented below](#nested_actions).
<a name="nested_match"></a>The `match` block supports:
* `expression` -
(Required)
Textual representation of an expression in Common Expression Language syntax.
* `title` -
(Optional)
Title for the expression, i.e. a short string describing its purpose.
* `description` -
(Optional)
Description of the expression
* `location` -
(Optional)
String indicating the location of the expression for error reporting, e.g. a file name and a position in the file
<a name="nested_actions"></a>The `actions` block supports:
* `expression` -
(Required)
Textual representation of an expression in Common Expression
Language syntax.
* `title` -
(Optional)
Title for the expression, i.e. a short string describing its
purpose.
* `description` -
(Optional)
Description of the expression
* `location` -
(Optional)
String indicating the location of the expression for error
reporting, e.g. a file name and a position in the file
- - -
* `type` -
(Optional)
This is policy's type, which is one of IMPORT or EXPORT
Possible values are: `ROUTE_POLICY_TYPE_IMPORT`, `ROUTE_POLICY_TYPE_EXPORT`.
* `region` -
(Optional)
Region where the router and NAT reside.
* `project` - (Optional) The ID of the project in which the resource belongs.
If it is not provided, the provider project is used.
## Attributes Reference
In addition to the arguments listed above, the following computed attributes are exported:
* `id` - an identifier for the resource with format `{{project}}/{{region}}/{{router}}/routePolicies/{{name}}`
* `fingerprint` -
The fingerprint used for optimistic locking of this resource. Used
internally during updates.
## Timeouts
This resource provides the following
[Timeouts](https://developer.hashicorp.com/terraform/plugin/sdkv2/resources/retries-and-customizable-timeouts) configuration options:
- `create` - Default is 20 minutes.
- `update` - Default is 20 minutes.
- `delete` - Default is 20 minutes.
## 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}}`
In Terraform v1.5.0 and later, use an [`import` block](https://developer.hashicorp.com/terraform/language/import) to import RouterRoutePolicy using one of the formats above. For example:
```tf
import {
id = "{{project}}/{{region}}/{{router}}/routePolicies/{{name}}"
to = google_compute_router_route_policy.default
}
```
When using the [`terraform import` command](https://developer.hashicorp.com/terraform/cli/commands/import), RouterRoutePolicy can be imported using one of the formats above. For example:
```
$ terraform import google_compute_router_route_policy.default {{project}}/{{region}}/{{router}}/routePolicies/{{name}}
$ terraform import google_compute_router_route_policy.default {{project}}/{{region}}/{{router}}/{{name}}
$ terraform import google_compute_router_route_policy.default {{region}}/{{router}}/{{name}}
$ terraform import google_compute_router_route_policy.default {{router}}/{{name}}
```
## User Project Overrides
This resource supports [User Project Overrides](https://registry.terraform.io/providers/hashicorp/google/latest/docs/guides/provider_reference#user_project_override).