Google Compute Engine Router Interface
This page shows how to write Terraform for Compute Engine Router Interface and write them securely.
google_compute_router_interface (Terraform)
The Router Interface in Compute Engine can be configured in Terraform with the resource name google_compute_router_interface
. The following sections describe 3 examples of how to use the resource and its parameters.
Example Usage from GitHub
resource "google_compute_router_interface" "gcve_router_interface1" {
name = "gcve-router-interface1"
router = google_compute_router.gcve_router.name
region = var.region
ip_range = "169.254.0.1/30"
vpn_tunnel = google_compute_vpn_tunnel.tunnel1.name
resource "google_compute_router_interface" "router1_interface1" {
name = "router1-interface1"
router = google_compute_router.router1.name
region = "us-central1"
ip_range = "169.254.0.1/30"
vpn_tunnel = google_compute_vpn_tunnel.tunnel1.name
resource "google_compute_router_interface" "router1_interface0" {
provider = "google-beta"
project = var.gcp_project_id
name = var.router_int0
router = var.cloud_router
region = var.gcp_region
Parameters
-
id
optional computed - string -
interconnect_attachment
optional - string
The name or resource link to the VLAN interconnect for this interface. Changing this forces a new interface to be created. Only one of vpn_tunnel and interconnect_attachment can be specified.
-
ip_range
optional - string
IP address and range of the interface. The IP range must be in the RFC3927 link-local IP space. Changing this forces a new interface to be created.
-
name
required - string
A unique name for the interface, required by GCE. Changing this forces a new interface to be created.
-
project
optional computed - string
The ID of the project in which this interface's router belongs. If it is not provided, the provider project is used. Changing this forces a new interface to be created.
-
region
optional computed - string
The region this interface's router sits in. If not specified, the project region will be used. Changing this forces a new interface to be created.
-
router
required - string
The name of the router this interface will be attached to. Changing this forces a new interface to be created.
-
vpn_tunnel
optional - string
The name or resource link to the VPN tunnel this interface will be linked to. Changing this forces a new interface to be created. Only one of vpn_tunnel and interconnect_attachment can be specified.
Explanation in Terraform Registry
Manages a Cloud Router interface. For more information see the official documentation and API.
Tips: Best Practices for The Other Google Compute Engine Resources
In addition to the google_compute_disk, Google Compute Engine has the other resources that should be configured for security reasons. Please check some examples of those resources and precautions.
google_compute_disk
Ensure the encryption key for your GCE disk is stored securely
It is better to store the encryption key for your GCE disk securely. Secret Manager could be used instead.
google_compute_firewall
Ensure your VPC firewall blocks unwanted outbound traffic
It is better to block unwanted outbound traffic not to expose resources in the VPC to unwanted attacks.
google_compute_instance
Ensure appropriate service account is assigned to your GCE instance
It is better to create a custom service account for the instance and assign it.
google_compute_project_metadata
Ensure OS login for your GCE instances is enabled at project level
It is better to enable OS login for your GCE instances. Enabling OS login ensures that SSH keys used to connect to instances are mapped with IAM users, allowing centralized and automated SSH key management.
google_compute_ssl_policy
Ensure to use modern TLS protocols
It's better to adopt TLS v1.2+ instead of outdated TLS protocols.
google_compute_subnetwork
Ensure VPC flow logging is enabled
It is better to enable VPC flow logging. VPC flow logging allows us to audit traffic in your network.
Frequently asked questions
What is Google Compute Engine Router Interface?
Google Compute Engine Router Interface is a resource for Compute Engine of Google Cloud Platform. Settings can be wrote in Terraform.
Where can I find the example code for the Google Compute Engine Router Interface?
For Terraform, the PacketBeta/gcve-cloudvpn-transit-vpc, TanAlex/gcp-terraform-sample and tranquilitybase-io/tb-module-gcp-aws-vpn source code examples are useful. See the Terraform Example section for further details.