Site icon Learning & Doing

Building a VPN Between Google Cloud and AWS with Terraform

Between

“Building a VPN Between Google Cloud and AWS with Terraform”

Deployment Architecture

Persiapan

Perisapan Penggunaan GCP

git clone https://github.com/GoogleCloudPlatform/autonetdeploy-multicloudvpn.git
cd autonetdeploy-multicloudvpn

Perisapan Penggunaan AWS

Buat access credentials ( GCP )

./gcp_set_credentials.sh ~/[PROJECT_ID]-[UNIQUE_ID].json

Buat AWS access credentials

export username=`whoami`
mkdir /home/$username/.aws/
touch /home/$username/.aws/credentials_autonetdeploy
nano /home/$username/.aws/credentials_autonetdeploy
[default]
aws_access_key_id=<Your AWS Access Key>
aws_secret_access_key=<Your AWS Secret Key>

ganti AWS key dan AWS secret yang anda miliki

Misal setelah di masukan seperti berikut

cat /home/$username/.aws/credentials_autonetdeploy

[default]
aws_access_key_id=AKIA3INBXVI72ZO2Z4F4
aws_secret_access_key=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
export TF_VAR_aws_credentials_file_path=/home/$username/.aws/credentials_autonetdeploy

Setting Project

export PROJECT_ID=$(gcloud config get-value project)
gcloud config set project $PROJECT_ID
./gcp_set_project.sh
cd terraform
terraform init
terraform plan

Gunakan SSH keys untuk Koneksi ke VM instances

ssh-keygen -t rsa -f ~/.ssh/vm-ssh-key -C $username
chmod 400 ~/.ssh/vm-ssh-key

Import public key ke Google Cloud

gcloud compute config-ssh --ssh-key-file=~/.ssh/vm-ssh-key

Import public key dari GCp ke AWS

Deploying VPC networks, VM instances, VPN gateways, dan IPsec tunnels

Dari script yang sudah di clone , berikut yang akan di deploy

Deploy dengan Terraform

cd ~/autonetdeploy-multicloudvpn/terraform
terraform validate
terraform plan
terraform apply

Vm di GCP

Vm di AWS

terraform output
aws_instance_external_ip = [AWS_EXTERNAL_IP]
aws_instance_internal_ip = 172.16.0.100
gcp_instance_external_ip = [GCP_EXTERNAL_IP]
gcp_instance_internal_ip = 10.240.0.100

Penutup

Sahabat Blog Learning & Doing demikianlah penjelasan mengenai Building a VPN Between Google Cloud and AWS with Terraform . Semoga Bermanfaat . Sampai ketemu lagi di postingan berikut nya.

Exit mobile version