| --- |
| # ---------------------------------------------------------------------------- |
| # |
| # *** 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: |- |
| Represents a Router resource. |
| --- |
| |
| # google\_compute\_router |
| |
| Represents a Router resource. |
| |
| |
| To get more information about Router, 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_working_dir=router_basic&cloudshell_image=gcr.io%2Fcloudshell-images%2Fcloudshell%3Alatest&open_in_editor=main.tf&cloudshell_print=.%2Fmotd&cloudshell_tutorial=.%2Ftutorial.md" 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 Basic |
| |
| |
| ```hcl |
| resource "google_compute_router" "foobar" { |
| name = "my-router" |
| network = google_compute_network.foobar.name |
| bgp { |
| asn = 64514 |
| advertise_mode = "CUSTOM" |
| advertised_groups = ["ALL_SUBNETS"] |
| advertised_ip_ranges { |
| range = "1.2.3.4" |
| } |
| advertised_ip_ranges { |
| range = "6.7.0.0/16" |
| } |
| } |
| } |
| |
| resource "google_compute_network" "foobar" { |
| name = "my-network" |
| auto_create_subnetworks = false |
| } |
| ``` |
| <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_working_dir=compute_router_encrypted_interconnect&cloudshell_image=gcr.io%2Fcloudshell-images%2Fcloudshell%3Alatest&open_in_editor=main.tf&cloudshell_print=.%2Fmotd&cloudshell_tutorial=.%2Ftutorial.md" 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 - Compute Router Encrypted Interconnect |
| |
| |
| ```hcl |
| resource "google_compute_router" "encrypted-interconnect-router" { |
| name = "test-router" |
| network = google_compute_network.network.name |
| encrypted_interconnect_router = true |
| bgp { |
| asn = 64514 |
| } |
| } |
| |
| resource "google_compute_network" "network" { |
| name = "test-network" |
| auto_create_subnetworks = false |
| } |
| ``` |
| |
| ## Argument Reference |
| |
| The following arguments are supported: |
| |
| |
| * `name` - |
| (Required) |
| Name of the resource. The name must be 1-63 characters long, and |
| comply with RFC1035. Specifically, the name must be 1-63 characters |
| long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` |
| which means the first character must be a lowercase letter, and all |
| following characters must be a dash, lowercase letter, or digit, |
| except the last character, which cannot be a dash. |
| |
| * `network` - |
| (Required) |
| A reference to the network to which this router belongs. |
| |
| |
| - - - |
| |
| |
| * `description` - |
| (Optional) |
| An optional description of this resource. |
| |
| * `bgp` - |
| (Optional) |
| BGP information specific to this router. |
| Structure is [documented below](#nested_bgp). |
| |
| * `encrypted_interconnect_router` - |
| (Optional) |
| Indicates if a router is dedicated for use with encrypted VLAN |
| attachments (interconnectAttachments). |
| |
| * `region` - |
| (Optional) |
| Region where the router resides. |
| |
| * `project` - (Optional) The ID of the project in which the resource belongs. |
| If it is not provided, the provider project is used. |
| |
| |
| <a name="nested_bgp"></a>The `bgp` block supports: |
| |
| * `asn` - |
| (Required) |
| Local BGP Autonomous System Number (ASN). Must be an RFC6996 |
| private ASN, either 16-bit or 32-bit. The value will be fixed for |
| this router resource. All VPN tunnels that link to this router |
| will have the same local ASN. |
| |
| * `advertise_mode` - |
| (Optional) |
| User-specified flag to indicate which mode to use for advertisement. |
| Default value is `DEFAULT`. |
| Possible values are: `DEFAULT`, `CUSTOM`. |
| |
| * `advertised_groups` - |
| (Optional) |
| User-specified list of prefix groups to advertise in custom mode. |
| This field can only be populated if advertiseMode is CUSTOM and |
| is advertised to all peers of the router. These groups will be |
| advertised in addition to any specified prefixes. Leave this field |
| blank to advertise no custom groups. |
| This enum field has the one valid value: ALL_SUBNETS |
| |
| * `advertised_ip_ranges` - |
| (Optional) |
| User-specified list of individual IP ranges to advertise in |
| custom mode. This field can only be populated if advertiseMode |
| is CUSTOM and is advertised to all peers of the router. These IP |
| ranges will be advertised in addition to any specified groups. |
| Leave this field blank to advertise no custom IP ranges. |
| Structure is [documented below](#nested_advertised_ip_ranges). |
| |
| * `keepalive_interval` - |
| (Optional) |
| The interval in seconds between BGP keepalive messages that are sent |
| to the peer. Hold time is three times the interval at which keepalive |
| messages are sent, and the hold time is the maximum number of seconds |
| allowed to elapse between successive keepalive messages that BGP |
| receives from a peer. |
| BGP will use the smaller of either the local hold time value or the |
| peer's hold time value as the hold time for the BGP connection |
| between the two peers. If set, this value must be between 20 and 60. |
| The default is 20. |
| |
| |
| <a name="nested_advertised_ip_ranges"></a>The `advertised_ip_ranges` block supports: |
| |
| * `range` - |
| (Required) |
| The IP range to advertise. The value must be a |
| CIDR-formatted string. |
| |
| * `description` - |
| (Optional) |
| User-specified description for the IP range. |
| |
| ## Attributes Reference |
| |
| In addition to the arguments listed above, the following computed attributes are exported: |
| |
| * `id` - an identifier for the resource with format `projects/{{project}}/regions/{{region}}/routers/{{name}}` |
| |
| * `creation_timestamp` - |
| Creation timestamp in RFC3339 text format. |
| * `self_link` - The URI of the created resource. |
| |
| |
| ## 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 |
| |
| |
| Router can be imported using any of these accepted formats: |
| |
| * `projects/{{project}}/regions/{{region}}/routers/{{name}}` |
| * `{{project}}/{{region}}/{{name}}` |
| * `{{region}}/{{name}}` |
| * `{{name}}` |
| |
| |
| In Terraform v1.5.0 and later, use an [`import` block](https://developer.hashicorp.com/terraform/language/import) to import Router using one of the formats above. For example: |
| |
| ```tf |
| import { |
| id = "projects/{{project}}/regions/{{region}}/routers/{{name}}" |
| to = google_compute_router.default |
| } |
| ``` |
| |
| When using the [`terraform import` command](https://developer.hashicorp.com/terraform/cli/commands/import), Router can be imported using one of the formats above. For example: |
| |
| ``` |
| $ terraform import google_compute_router.default projects/{{project}}/regions/{{region}}/routers/{{name}} |
| $ terraform import google_compute_router.default {{project}}/{{region}}/{{name}} |
| $ terraform import google_compute_router.default {{region}}/{{name}} |
| $ terraform import google_compute_router.default {{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). |