Connect your AWS to GCP with Terraform via IPSec Site-to-Site VPN

Ercan (@flightlesstux)
Teknasyon Engineering
2 min readMay 5, 2021

Today, I wrote another IaaC (infrastructure as a code) for my needs. You can create a secure VPN connection (IPsec) between Amazon Web Services (AWS) and Google Cloud Platform (GCP).

What can this do?

Creating a Customer Gateway on AWS. Creating a Virtual Private Gateway on AWS. Creating a Site-to-Site VPN Connection on AWS. Creating a Security Group for VPN connection access on AWS. Creating an External IP address for VPN connection on GCP. Creating a Managing the firewall rule for VPN connection on GCP. Creating a Route rule on GCP.

Requirements

Usage

  • Step 1:
    Clone the repository.
  • Step 2:
    export GOOGLE_APPLICATION_CREDENTIALS="service-account-key.json"
    Authenticate to Google Platform if even google-sdk is not installed. It's really useful for CI/CD pipelines! If you already logged in to your Google Cloud Platform project like gcloud auth login, you can skip this step.
  • Step 3:
    export GOOGLE_PROJECT="0123456789012"
    Project ID is also declared via terraform but if you don't export the value, you will probable get an error like below.
│ Error: project: required field is not set

│ with google_compute_instance_group_manager.this,
│ on group_manager.tf line 1, in resource "google_compute_instance_group_manager" "this":
│ 1: resource "google_compute_instance_group_manager" "this" {
  • Step 4:
    AWS_ACCESS_KEY_ID=AKIA1SFAESADASFASR5D
    AWS_SECRET_ACCESS_KEY=Aasdfiajfar1O9DFASDAA3rasdas02304adsq9re
    Export your AWS Access Key ID and Secret Access Key for create a resource in your AWS Region.
  • Step 5:
    Edit values for variables.tf
  • Step 6:
    Set your terraform state bucket via state.tf file. You can use AWS S3 or Google Cloud Storage.
  • Step 7:
    terraform init
  • Step 8:
    terraform apply or terraform apply -auto-approve

Repository Address

https://github.com/flightlesstux/aws-to-gcp-vpn-w-terraform

I hope, you enjoyed with this article…

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Published in Teknasyon Engineering

We develop innovative solutions for millions of users worldwide, with Zotlo, Rockads, Desk360, Getcontact, eSIM.io, Lisa AI and more.

Written by Ercan (@flightlesstux)

⌨️ Solution Architect, formerly DevOps Engineer Lead 👨‍👩‍👧‍👦 3x @AWSCommunity Builder 😶‍🌫️ Certified #AWS Solution Architect (SAA-C03) 🐍 #Python Dev♥️

No responses yet

Write a response