<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Lama ALmassry on Medium]]></title>
        <description><![CDATA[Stories by Lama ALmassry on Medium]]></description>
        <link>https://medium.com/@massrylama?source=rss-b783cad23c2d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*FjFNnYvDJVj0_1QVMW2q9A.jpeg</url>
            <title>Stories by Lama ALmassry on Medium</title>
            <link>https://medium.com/@massrylama?source=rss-b783cad23c2d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 01:33:51 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@massrylama/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Building on AWS EKS with the New Capabilities Feature: Argo CD and ACK Without the Operational…]]></title>
            <link>https://medium.com/@massrylama/building-on-aws-eks-with-the-new-capabilities-feature-argo-cd-and-ack-without-the-operational-3cbf0e0d590b?source=rss-b783cad23c2d------2</link>
            <guid isPermaLink="false">https://medium.com/p/3cbf0e0d590b</guid>
            <dc:creator><![CDATA[Lama ALmassry]]></dc:creator>
            <pubDate>Tue, 23 Dec 2025 15:58:32 GMT</pubDate>
            <atom:updated>2025-12-24T16:19:29.908Z</atom:updated>
            <content:encoded><![CDATA[<h3>Building on AWS EKS with the New Capabilities Feature: Argo CD and ACK Without the Operational Overhead</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/715/1*Fhg3OAq8bhqNNSwcoV0w4w.png" /></figure><h4>In late November 2025, at re:Invent, AWS launched <strong>EKS Capabilities</strong> — one of the most significant updates to Amazon EKS in years.</h4><p>This feature completely changes how we run core Kubernetes tools like <strong>Argo CD and AWS Controllers for Kubernetes (ACK).</strong> Instead of deploying and maintaining these as pods inside your cluster (with all the upgrades, scaling, and operational burden that comes with it), AWS now runs them as <strong>fully managed </strong>services outside your worker nodes.</p><p>I put this new feature to the test by building a real production-style application: an <strong>image gallery web app</strong> that lets users upload images, stores them in S3, saves metadata in PostgreSQL on RDS, and runs everything via GitOps.</p><p>This article is a complete walkthrough of that implementation — including the setup, the challenges I hit (and how I fixed them), and why this approach feels like the future of Kubernetes on AWS.</p><h3>What Are EKS Capabilities?</h3><p>EKS Capabilities are fully managed Kubernetes features that run <strong>outside your worker nodes</strong> in AWS-managed infrastructure. Think of them as control plane extensions managed by AWS.</p><p><strong>Pricing [IMP]</strong> The cost structure for EKS Capabilities follows a predictable “Base + Usage” model, billed hourly for each enabled feature:</p><ul><li><strong>Base Charge:</strong> You pay a flat hourly rate for each enabled Capability (Argo CD, ACK, or KRO) to cover the managed control plane.</li><li><strong>Usage Charge:</strong> You pay an additional hourly fee based on the scale of your environment, such as the number of Argo CD Applications or ACK/KRO resources being managed.</li></ul><h3>Available Capabilities</h3><ol><li><strong>Argo CD</strong> — GitOps continuous deployment with IAM Identity Center integration</li><li><strong>AWS Controllers for Kubernetes (ACK)</strong> — Manage AWS resources via Kubernetes APIs</li><li><strong>Kro</strong> — Kubernetes Resource Orchestrator for custom compositions</li></ol><h3>The Application: Image Gallery with Full GitOps Flow</h3><p><strong>User Experience</strong></p><ul><li>User visits the web app (exposed via LoadBalancer)</li><li>Uploads an image</li><li>Image is stored in an encrypted S3 bucket</li><li>Metadata (filename, size, upload time) is saved to RDS PostgreSQL</li><li>Gallery displays all uploaded images</li></ul><p>Everything — from the database and storage to the application deployment — is defined in Git and applied automatically.</p><h4>Prerequisites</h4><ul><li>AWS Account with admin access</li><li>AWS CLI v2.32.9+</li><li>kubectl, Terraform 1.5+</li><li><strong>IAM Identity Center enabled</strong> (critical for Argo CD)</li></ul><p>Setting Up EKS Capabilities</p><ol><li><strong>Create the IAM Role for Capabilities</strong> (Terraform)</li></ol><pre>resource &quot;aws_iam_role_policy&quot; &quot;ack_s3_policy&quot; {<br>  name = &quot;ACKS3Policy&quot;<br>  role = aws_iam_role.eks_capability_role.id<br>  policy = jsonencode({<br>    Version = &quot;2012-10-17&quot;<br>    Statement = [{ Effect = &quot;Allow&quot;, Action = [&quot;s3:*&quot;], Resource = &quot;*&quot; }]<br>  })<br>}<br><br>resource &quot;aws_iam_role_policy&quot; &quot;ack_rds_policy&quot; {<br>  name = &quot;ACKRDSPolicy&quot;<br>  role = aws_iam_role.eks_capability_role.id<br>  policy = jsonencode({<br>    Version = &quot;2012-10-17&quot;<br>    Statement = [{<br>      Effect   = &quot;Allow&quot;<br>      Action   = [&quot;rds:*&quot;, &quot;rds:CreateDBSubnetGroup&quot;, &quot;rds:DeleteDBSubnetGroup&quot;, &quot;rds:DescribeDBSubnetGroups&quot;]<br>      Resource = &quot;*&quot;<br>    }]<br>  })<br>}<br><br>resource &quot;aws_iam_role_policy&quot; &quot;ack_secrets_policy&quot; {<br>  name = &quot;ACKSecretsPolicy&quot;<br>  role = aws_iam_role.eks_capability_role.id<br>  policy = jsonencode({<br>    Version = &quot;2012-10-17&quot;<br>    Statement = [{<br>      Effect   = &quot;Allow&quot;<br>      Action   = [&quot;secretsmanager:GetSecretValue&quot;, &quot;secretsmanager:DescribeSecret&quot;]<br>      Resource = &quot;*&quot;<br>    }]<br>  })<br>}</pre><p>2. Enable the Capabilities (via AWS Console or CLI)</p><ul><li>Enable Argo CD Capability with (IAM Identity Center)</li></ul><pre><br># First, get your IAM Identity Center details:<br><br>aws sso-admin list-instances --query &#39;Instances[0].InstanceArn&#39; --output text<br><br>aws eks create-capability \<br>  --region us-east-1 \<br>  --cluster-name devsecops-eks-cluster \<br>  --capability-name my-argocd \<br>  --type ARGOCD \<br>  --role-arn arn:aws:iam::YOUR_ACCOUNT_ID:role/devsecops-eks-cluster-capability-role \<br>  --delete-propagation-policy RETAIN \<br>  --configuration &#39;{<br>    &quot;argoCd&quot;: {<br>      &quot;awsIdc&quot;: {<br>        &quot;idcInstanceArn&quot;: &quot;arn:aws:sso:::instance/YOUR_SSO_INSTANCE_ID&quot;,<br>        &quot;idcRegion&quot;: &quot;us-east-1&quot;<br>      },<br>      &quot;rbacRoleMappings&quot;: [{<br>        &quot;role&quot;: &quot;ADMIN&quot;,<br>        &quot;identities&quot;: [{<br>          &quot;id&quot;: &quot;YOUR_SSO_USER_ID&quot;,<br>          &quot;type&quot;: &quot;SSO_USER&quot;<br>        }]<br>      }]<br>    }<br>  }&#39;</pre><pre># Wait for it to become ACTIVE<br><br>aws eks describe-capability \  --region us-east-1 \<br>  --cluster-name eks-capabilities-demo \<br>  --capability-name my-ack \<br>  --query &#39;capability.status&#39;</pre><ul><li>Enable ACK Capability (to manage RDS, S3 from Kubernetes)</li></ul><pre>aws eks create-capability \<br>  --region us-east-1 \<br>  --cluster-name devsecops-eks-cluster \<br>  --capability-name my-ack \<br>  --type ACK \<br>  --role-arn arn:aws:iam::YOUR_ACCOUNT_ID:role/devsecops-eks-cluster-capability-role</pre><ul><li>Add ClusterAdmin policy</li></ul><pre> aws eks associate-access-policy --cluster-name devsecops-eks-cluster --principal-arn arn:aws:iam::837853803040:role/devsecops-eks-cluster-capability-role --policy-arn arn:aws:eks::aws:cluster-access-policy/AmazonEKSClusterAdminPolicy --access-scope type=cluster</pre><p><strong>Registering the Local Cluster in Managed Argo CD (Using Secret)</strong></p><p>In AWS-managed Argo CD (EKS Capabilities), the standard in-cluster server URL (https://kubernetes.default.svc) <strong>does not work</strong>. You must explicitly register the local cluster using its ARN.</p><p>The most reliable method is <strong>declarative registration</strong> with a Kubernetes Secret in the argocd namespace:</p><pre>apiVersion: v1<br>kind: Secret<br>metadata:<br>  name: in-cluster<br>  namespace: argocd<br>  labels:<br>    argocd.argoproj.io/secret-type: cluster<br>type: Opaque<br>stringData:<br>  name: in-cluster<br>  server: arn:aws:eks:us-east-1:YOUR_ACCOUNT_ID:cluster/YOUR_CLUSTER_NAME<br><br># Apply it:<br> kubectl apply -f cluster-secret.yaml</pre><figure><img alt="— — — — -" src="https://cdn-images-1.medium.com/max/1024/1*FH06nMZaQY-kd_KT25IRXw.png" /></figure><p>Verify in ArgoCD UI → Settings→ Clusters:</p><p><strong>Connection Status: Successful</strong> ✅</p><h3>Define AWS Resources Using ACK</h3><p>Now comes the magic — we define AWS resources (S3, RDS) as Kubernetes manifests!</p><ul><li>S3 Bucket</li></ul><pre># k8s/aws-resources/s3-bucket.yaml<br>apiVersion: s3.services.k8s.aws/v1alpha1<br>kind: Bucket<br>metadata:<br>  name: app-images-bucket<br>  namespace: my-app<br>spec:<br>  name: my-app-images-123456789<br>  publicAccessBlock:<br>    blockPublicAcls: true<br>    blockPublicPolicy: true<br>    ignorePublicAcls: true<br>    restrictPublicBuckets: true<br>  encryption:<br>    rules:<br>      - applyServerSideEncryptionByDefault:<br>          sseAlgorithm: AES256</pre><ul><li>RDS PostgreSQL Database</li></ul><pre># k8s/aws-resources/rds-instance.yaml<br>apiVersion: rds.services.k8s.aws/v1alpha1<br>kind: DBInstance<br>metadata:<br>  name: app-database<br>  namespace: my-app<br>spec:<br>  allocatedStorage: 20<br>  dbInstanceClass: db.t3.micro<br>  dbInstanceIdentifier: my-app-db<br>  engine: postgres<br>  engineVersion: &quot;17.6&quot;<br>  masterUsername: dbadmin<br>  masterUserPassword:<br>    namespace: my-app<br>    name: db-credentials<br>    key: password<br>  dbName: appdb<br>  publiclyAccessible: false<br>  storageEncrypted: true</pre><p><strong>Apply these manifests:</strong></p><pre>kubectl apply -f k8s/aws-resources/</pre><p><strong>The magic here:</strong> ACK Capability creates real AWS resources without you running any AWS CLI commands or Terraform or CloudFormation templates!</p><h3>Deploy Application via Argo CD</h3><ul><li>Create Application Manifest</li></ul><pre># k8s/deployment.yaml<br>apiVersion: apps/v1<br>kind: Deployment<br>metadata:<br>  name: my-app<br>  namespace: my-app<br>spec:<br>  replicas: 2<br>  selector:<br>    matchLabels:<br>      app: my-app<br>  template:<br>    metadata:<br>      labels:<br>        app: my-app<br>    spec:<br>      serviceAccountName: app-service-account<br>      containers:<br>      - name: app<br>        image: YOUR_ACCOUNT.dkr.ecr.us-east-1.amazonaws.com/my-app:latest<br>        env:<br>        - name: DB_HOST<br>          valueFrom:<br>            configMapKeyRef:<br>              name: app-config<br>              key: DB_HOST<br>        - name: S3_BUCKET_NAME<br>          valueFrom:<br>            configMapKeyRef:<br>              name: app-config<br>              key: S3_BUCKET_NAME</pre><ul><li>Push to GitHub</li></ul><pre>git add k8s/<br>git commit -m &quot;Add Kubernetes manifests&quot;<br>git push origin main</pre><h3>Configure Argo CD Application</h3><p>Access Argo CD UI through AWS Console:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-wGxZln8CTp7DCav9KODqA.png" /></figure><p><strong>Create Application:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ynZMGRbCtNy2AI4FHcnJQw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YWP_FHJN_31MdA5KfkZGqg.png" /></figure><p>Argo CD will now automatically:</p><ul><li>Deploy your application</li><li>Sync any changes from Git</li><li>Show you real-time status</li></ul><h3>Results: It Works!</h3><ul><li><strong>S3 bucket created</strong> automatically by ACK</li><li><strong>RDS database provisioned</strong> and accessible</li><li><strong>GitOps working</strong> — changes sync automatically</li></ul><p>Access the application:</p><pre>kubectl get svc devsecops-app-service -n devsecops-app<br># Visit: http://&lt;EXTERNAL-IP&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LiqLQOGqiXwenAMQAggcZQ.png" /></figure><ul><li><strong>Application deployed</strong> with 2 replicas</li><li><strong>Images successfully uploaded</strong> to S3</li><li><strong>Metadata stored</strong> in PostgreSQL</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uQIVix4N_dB_OWYRH04naQ.png" /></figure><p><strong>To safely destroy the setup:</strong></p><ol><li>Delete the Argo CD Application first (triggers ACK to clean up S3 and RDS resources), then wait for AWS resources to be fully deleted.</li><li>Delete the EKS Capabilities (my-argocd and my-ack), and finally run terraform destroy to remove the cluster, VPC, and all other infrastructure.</li></ol><h4>Key Advantages Over Self-Managed</h4><p>Before EKS Capabilities</p><pre># Install Argo CD<br>kubectl create namespace argocd<br>kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml# Install ACK controllers (for each service!)<br>helm install ack-s3-controller ack-s3-chart<br>helm install ack-rds-controller ack-rds-chart<br># Maintain, upgrade, scale, monitor...</pre><p>With EKS Capabilities</p><pre># Enable Argo CD<br>aws eks create-capability --capability-name my-argocd --type ARGOCD ...<br># Enable ACK<br>aws eks create-capability --capability-name my-ack --type ACK ..<br><br><br># Done! AWS handles everything else</pre><h4>Key Takeaways</h4><h4>What Works Great</h4><ul><li><strong>Zero controller maintenance</strong> — No Argo CD or ACK pods to manage</li><li><strong>IAM Identity Center integration</strong> — Enterprise SSO out of the box</li><li><strong>GitOps native</strong> — Push to Git, automatic deployment</li><li><strong>Infrastructure as Code</strong> — AWS resources as Kubernetes manifests</li></ul><p><strong>Bottom Line</strong> EKS Capabilities removes the biggest operational pain points of running Argo CD and ACK on EKS. The early bugs are minor and easily fixed. Once set up, the system is reliable, secure, and truly hands-off.</p><p>For anyone running Kubernetes workloads on AWS, this feature is a <strong>must-try</strong> — it lets you focus on building applications instead of managing tools.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3cbf0e0d590b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How I Keep My AWS IAM Users Safe ?]]></title>
            <link>https://medium.com/@massrylama/how-i-keep-my-aws-iam-users-safe-c1620f0850da?source=rss-b783cad23c2d------2</link>
            <guid isPermaLink="false">https://medium.com/p/c1620f0850da</guid>
            <dc:creator><![CDATA[Lama ALmassry]]></dc:creator>
            <pubDate>Sun, 07 Dec 2025 20:11:35 GMT</pubDate>
            <atom:updated>2026-01-16T10:59:30.671Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>How I Keep My AWS IAM Users Safe?</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/773/0*fCzJb8aEuYvd4Qy5" /></figure><p>1- <strong>One key per user only</strong><br> Each IAM User gets <strong>1 Access Key</strong>. Period. Easier to track, safer overall.</p><p>2- <strong>Rotate keys — or don’t use them</strong><br> Keys every 90 days if needed, but honestly? <strong>IAM Roles &gt; Keys</strong>. Always.</p><p>3- <strong>Groups, not individuals</strong><br> Assign permissions via <strong>Groups</strong>, not per user. Less headache, more control.</p><p>4- <strong>No full admin rights unless necessary</strong><br> Full admin = disaster waiting to happen. Only give what’s needed.</p><p>5- <strong>Keep a support IAM Role ready</strong><br> If something breaks or you need help, having a ready IAM Role for AWS Support is a lifesaver.</p><p>6- <strong>EC2? Use Roles, not Keys</strong><br> No hardcoding keys in EC2. IAM Roles keep secrets safe.</p><p>7- <strong>Turn on IAM Access Analyzer</strong><br> Spot overly open permissions before they cause trouble.</p><p>8- <strong>Multiple accounts? Use Organizations</strong><br> SCPs + Roles/Policies = central control. Chaos-free.</p><p>9- <strong>CloudShell? Only if you need it</strong><br> Browser CLI is handy, but if unused, block it.</p><p>💡 <strong>Bottom line:</strong><br> Do these, and your AWS account is much safer. Security isn’t optional — it’s part of the job! 🫡</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c1620f0850da" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a Highly Available Multi-Cloud VPN: Connecting AWS and Google Cloud with Terraform]]></title>
            <link>https://medium.com/@massrylama/building-a-highly-available-multi-cloud-vpn-connecting-aws-and-google-cloud-with-terraform-dba591e9fd48?source=rss-b783cad23c2d------2</link>
            <guid isPermaLink="false">https://medium.com/p/dba591e9fd48</guid>
            <dc:creator><![CDATA[Lama ALmassry]]></dc:creator>
            <pubDate>Sun, 07 Sep 2025 14:56:28 GMT</pubDate>
            <atom:updated>2025-09-08T07:56:06.438Z</atom:updated>
            <content:encoded><![CDATA[<p><em>A complete guide to creating a secure, redundant connection between AWS and GCP using Infrastructure as Code</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/873/1*2vlkrhirJensp34NvhC3HA.png" /><figcaption>ر</figcaption></figure><h3>Introduction</h3><p>In today’s multi-cloud world, organizations often find themselves running workloads across multiple cloud providers. Whether it’s for disaster recovery, avoiding vendor lock-in, or leveraging the best services from each provider, the ability to securely connect different cloud environments is crucial.</p><p>In this comprehensive guide, we’ll build a <strong>highly available (HA) site-to-site VPN connection</strong> between Amazon Web Services (AWS) and Google Cloud Platform (GCP) using Terraform. By the end of this tutorial, you’ll have a robust, production-ready infrastructure that allows secure communication between your AWS and GCP resources.</p><h3>What We’re Building</h3><p>Our architecture will include:</p><ul><li><strong>AWS Side</strong>: VPC with private subnets, VPN Gateway, and EC2 instance</li><li><strong>GCP Side</strong>: VPC with private subnets, HA VPN Gateway, and Compute Engine instance</li><li><strong>High Availability</strong>: Multiple VPN tunnels for redundancy</li><li><strong>BGP Routing</strong>: Dynamic routing for automatic failover</li><li><strong>Private Connectivity</strong>: No internet gateways on private resources</li></ul><h3>Why This Architecture Matters</h3><h3>High Availability</h3><p>By using multiple VPN tunnels and BGP routing, we ensure that if one tunnel fails, traffic automatically routes through the backup tunnels without manual intervention.</p><h3>Security</h3><p>All communication happens through encrypted VPN tunnels. Our compute instances have no direct internet access, following security best practices.</p><h3>Prerequisites</h3><p>Before we start, make sure you have:</p><ul><li>AWS Account with appropriate IAM permissions</li><li>GCP Project with billing enabled</li><li>Terraform installed (version 1.0+)</li><li>AWS CLI configured</li><li>GCP CLI (gcloud) configured</li></ul><h3>Project Structure</h3><p>Let’s organize our Terraform code into logical files:</p><pre>multicloud-vpn/<br>├── variables.tf      # Input variables<br>├── providers.tf      # Provider configurations<br>├── aws-infrastructure.tf<br>├── gcp-infrastructure.tf<br>├── vpn-connection.tf<br>├── aws-compute.tf<br>├── gcp-compute.tf<br>├── iam-roles.tf<br>└── outputs.tf       # Output values</pre><blockquote><strong><em>Note:</em></strong><em> The Terraform code presented here can be further optimized using modules, loops, and dynamic blocks. However, it is intentionally kept simple so you can follow </em><strong><em>all the steps clearly</em></strong><em> and understand how each resource is created.</em></blockquote><h3>Step 1: Setting Up Variables and Providers</h3><p>First, let’s define our variables and provider configurations:</p><pre># variables.tf<br>variable &quot;aws_region&quot; {<br>  description = &quot;AWS Region&quot;<br>  type        = string<br>  default     = &quot;us-east-1&quot;<br>}<br>variable &quot;gcp_region&quot; {<br>  description = &quot;GCP Region&quot;<br>  type        = string<br>  default     = &quot;us-central1&quot;<br>}<br>variable &quot;gcp_project_id&quot; {<br>  description = &quot;GCP Project ID&quot;<br>  type        = string<br>}<br>variable &quot;aws_vpc_cidr&quot; {<br>  description = &quot;AWS VPC CIDR&quot;<br>  type        = string<br>  default     = &quot;10.1.0.0/16&quot;<br>}<br>variable &quot;gcp_vpc_cidr&quot; {<br>  description = &quot;GCP VPC CIDR&quot;<br>  type        = string<br>  default     = &quot;172.16.0.0/24&quot;<br>}<br>variable &quot;project_name&quot; {<br>  description = &quot;Project name for resource naming&quot;<br>  type        = string<br>  default     = &quot;multicloud-vpn&quot;<br>}</pre><pre># providers.tf<br>terraform {<br>  required_providers {<br>    aws = {<br>      source  = &quot;hashicorp/aws&quot;<br>      version = &quot;~&gt; 5.0&quot;<br>    }<br>    google = {<br>      source  = &quot;hashicorp/google&quot;<br>      version = &quot;~&gt; 4.0&quot;<br>    }<br>  }<br>}<br>provider &quot;aws&quot; {<br>  region = var.aws_region<br>}<br>provider &quot;google&quot; {<br>  region  = var.gcp_region<br>  project = var.gcp_project_id<br>}</pre><h3>Step 2: Building AWS Infrastructure</h3><p>Now let’s create our AWS infrastructure:</p><pre># aws-infrastructure.tf<br># AWS VPC<br>resource &quot;aws_vpc&quot; &quot;main&quot; {<br>  cidr_block           = var.aws_vpc_cidr<br>  enable_dns_hostnames = true<br>  enable_dns_support   = true<br> tags = {<br>    Name = &quot;${var.project_name}-aws-vpc&quot;<br>  }<br>}<br># Private Subnet for EC2<br>resource &quot;aws_subnet&quot; &quot;private&quot; {<br>  vpc_id            = aws_vpc.main.id<br>  cidr_block        = &quot;10.1.1.0/24&quot;<br>  availability_zone = &quot;${var.aws_region}a&quot;<br>  tags = {<br>    Name = &quot;${var.project_name}-aws-private-subnet&quot;<br>  }<br>}</pre><pre># VPN Gateway with correct ASN<br>resource &quot;aws_vpn_gateway&quot; &quot;main&quot; {<br>  vpc_id          = aws_vpc.main.id<br>  amazon_side_asn = 65010  # AWS Private ASN</pre><pre>  tags = {<br>    Name = &quot;${var.project_name}-aws-vpn-gateway&quot;<br>  }</pre><pre>}</pre><pre># Private Route Table<br>resource &quot;aws_route_table&quot; &quot;private&quot; {<br>  vpc_id = aws_vpc.main.id</pre><pre>  tags = {<br>    Name = &quot;${var.project_name}-aws-private-rt&quot;<br>  }<br>}</pre><pre># Associate private subnet with private route table<br>resource &quot;aws_route_table_association&quot; &quot;private&quot; {<br>  subnet_id      = aws_subnet.private.id<br>  route_table_id = aws_route_table.private.id<br>}</pre><h3>Step 3: Building GCP Infrastructure</h3><p>Next, let’s set up the GCP side:</p><pre># gcp-infrastructure.tf<br># GCP VPC Network<br>resource &quot;google_compute_network&quot; &quot;main&quot; {<br>  name                    = &quot;${var.project_name}-gcp-vpc&quot;<br>  auto_create_subnetworks = false<br>  project                 = var.gcp_project_id<br>}<br># GCP Subnet<br>resource &quot;google_compute_subnetwork&quot; &quot;main&quot; {<br>  name          = &quot;${var.project_name}-gcp-subnet&quot;<br>  ip_cidr_range = var.gcp_vpc_cidr<br>  region        = var.gcp_region<br>  network       = google_compute_network.main.id<br>}<br># Cloud Router for BGP with correct ASN<br>resource &quot;google_compute_router&quot; &quot;main&quot; {<br>  name    = &quot;${var.project_name}-gcp-cloud-router&quot;<br>  region  = var.gcp_region<br>  network = google_compute_network.main.id<br>bgp {<br>    asn = 65000  # GCP Private ASN<br>  }<br>}<br># HA VPN Gateway<br>resource &quot;google_compute_ha_vpn_gateway&quot; &quot;main&quot; {<br>  name    = &quot;${var.project_name}-gcp-ha-vpn-gateway&quot;<br>  region  = var.gcp_region<br>  network = google_compute_network.main.id<br>}</pre><blockquote><strong><em>Note:</em></strong><em> AWS ASN → AWS Private ASN<br> GCP ASN → GCP Private ASN<br> Using private ASNs ensures proper BGP routing and avoids conflicts with public ASNs.</em></blockquote><h3>Step 4: Creating the VPN Connection (The Magic!)</h3><p>This is where the real magic happens. We’ll create a highly available VPN connection with 4 tunnels total:</p><pre># vpn-connection.tf<br># Customer Gateway 1 (represents GCP Interface 0 in AWS)<br>resource &quot;aws_customer_gateway&quot; &quot;gcp_interface0&quot; {<br>  bgp_asn    = 65000  # GCP ASN<br>  ip_address = google_compute_ha_vpn_gateway.main.vpn_interfaces[0].ip_address<br>  type       = &quot;ipsec.1&quot;<br>tags = {<br>    Name = &quot;${var.project_name}-gcp-interface0-cgw&quot;<br>  }<br>}<br># Customer Gateway 2 (represents GCP Interface 1 in AWS)<br>resource &quot;aws_customer_gateway&quot; &quot;gcp_interface1&quot; {<br>  bgp_asn    = 65000  # GCP ASN<br>  ip_address = google_compute_ha_vpn_gateway.main.vpn_interfaces[1].ip_address<br>  type       = &quot;ipsec.1&quot;<br>tags = {<br>    Name = &quot;${var.project_name}-gcp-interface1-cgw&quot;<br>  }<br>}</pre><pre># AWS VPN Connection 1 (connects to GCP Interface 0)<br>resource &quot;aws_vpn_connection&quot; &quot;connection1&quot; {<br>  vpn_gateway_id      = aws_vpn_gateway.main.id<br>  customer_gateway_id = aws_customer_gateway.gcp_interface0.id<br>  type                = &quot;ipsec.1&quot;<br>  static_routes_only  = false</pre><pre>  tags = {<br>    Name = &quot;${var.project_name}-aws-to-gcp-vpn-connection-1&quot;<br>  }<br>}</pre><pre># AWS VPN Connection 2 (connects to GCP Interface 1)  <br>resource &quot;aws_vpn_connection&quot; &quot;connection2&quot; {<br>  vpn_gateway_id      = aws_vpn_gateway.main.id<br>  customer_gateway_id = aws_customer_gateway.gcp_interface1.id<br>  type                = &quot;ipsec.1&quot;<br>  static_routes_only  = false</pre><pre>  tags = {<br>    Name = &quot;${var.project_name}-aws-to-gcp-vpn-connection-2&quot;<br>  }<br>}</pre><h3>Setting Up GCP Side of the VPN</h3><pre># External VPN Gateway representing AWS VPN Connection 1<br>resource &quot;google_compute_external_vpn_gateway&quot; &quot;aws_connection1&quot; {<br>  name            = &quot;${var.project_name}-aws-vpn-connection-1&quot;<br>  redundancy_type = &quot;TWO_IPS_REDUNDANCY&quot;<br>  description     = &quot;AWS VPN Connection 1&quot;<br>interface {<br>    id         = 0<br>    ip_address = aws_vpn_connection.connection1.tunnel1_address<br>  }<br> interface {<br>    id         = 1<br>    ip_address = aws_vpn_connection.connection1.tunnel2_address<br>  }<br>}<br># External VPN Gateway representing AWS VPN Connection 2<br>resource &quot;google_compute_external_vpn_gateway&quot; &quot;aws_connection2&quot; {<br>  name            = &quot;${var.project_name}-aws-vpn-connection-2&quot;<br>  redundancy_type = &quot;TWO_IPS_REDUNDANCY&quot;<br>  description     = &quot;AWS VPN Connection 2&quot;<br><br>  interface {<br>    id         = 0<br>    ip_address = aws_vpn_connection.connection2.tunnel1_address<br>  }<br><br>  interface {<br>    id         = 1<br>    ip_address = aws_vpn_connection.connection2.tunnel2_address<br>  }<br>}<br><br><br># GCP VPN Tunnels - 4 tunnels total for full HA<br>resource &quot;google_compute_vpn_tunnel&quot; &quot;tunnel1_conn1&quot; {<br>  name                            = &quot;${var.project_name}-interface0-to-aws-conn1-tunnel1&quot;<br>  region                          = var.gcp_region<br>  vpn_gateway                     = google_compute_ha_vpn_gateway.main.id<br>  vpn_gateway_interface           = 0<br>  peer_external_gateway           = google_compute_external_vpn_gateway.aws_connection1.id<br>  peer_external_gateway_interface = 0<br>  shared_secret                   = aws_vpn_connection.connection1.tunnel1_preshared_key<br>  router                          = google_compute_router.main.id<br>  ike_version                     = 2<br>}<br>resource &quot;google_compute_vpn_tunnel&quot; &quot;tunnel2_conn1&quot; {<br>  name                            = &quot;${var.project_name}-interface0-to-aws-conn1-tunnel2&quot;<br>  region                          = var.gcp_region<br>  vpn_gateway                     = google_compute_ha_vpn_gateway.main.id<br>  vpn_gateway_interface           = 0<br>  peer_external_gateway           = google_compute_external_vpn_gateway.aws_connection1.id<br>  peer_external_gateway_interface = 1<br>  shared_secret                   = aws_vpn_connection.connection1.tunnel2_preshared_key<br>  router                          = google_compute_router.main.id<br>  ike_version                     = 2<br>}<br><br>resource &quot;google_compute_vpn_tunnel&quot; &quot;tunnel1_conn2&quot; {<br>  name                            = &quot;${var.project_name}-interface1-to-aws-conn2-tunnel1&quot;<br>  region                          = var.gcp_region<br>  vpn_gateway                     = google_compute_ha_vpn_gateway.main.id<br>  vpn_gateway_interface           = 1<br>  peer_external_gateway           = google_compute_external_vpn_gateway.aws_connection2.id<br>  peer_external_gateway_interface = 0<br>  shared_secret                   = aws_vpn_connection.connection2.tunnel1_preshared_key<br>  router                          = google_compute_router.main.id<br>  ike_version                     = 2<br>}<br><br>resource &quot;google_compute_vpn_tunnel&quot; &quot;tunnel2_conn2&quot; {<br>  name                            = &quot;${var.project_name}-interface1-to-aws-conn2-tunnel2&quot;<br>  region                          = var.gcp_region<br>  vpn_gateway                     = google_compute_ha_vpn_gateway.main.id<br>  vpn_gateway_interface           = 1<br>  peer_external_gateway           = google_compute_external_vpn_gateway.aws_connection2.id<br>  peer_external_gateway_interface = 1<br>  shared_secret                   = aws_vpn_connection.connection2.tunnel2_preshared_key<br>  router                          = google_compute_router.main.id<br>  ike_version                     = 2<br>}</pre><h3>Step 5: BGP Configuration</h3><p>BGP (Border Gateway Protocol) is crucial for dynamic routing and automatic failover:</p><pre># BGP Router Interfaces<br>resource &quot;google_compute_router_interface&quot; &quot;interface1_conn1&quot; {<br>  name       = &quot;interface1-conn1&quot;<br>  router     = google_compute_router.main.name<br>  region     = var.gcp_region<br>  ip_range   = &quot;${aws_vpn_connection.connection1.tunnel1_cgw_inside_address}/30&quot;<br>  vpn_tunnel = google_compute_vpn_tunnel.tunnel1_conn1.name<br>}<br><br>resource &quot;google_compute_router_interface&quot; &quot;interface2_conn1&quot; {<br>  name       = &quot;interface2-conn1&quot;<br>  router     = google_compute_router.main.name<br>  region     = var.gcp_region<br>  ip_range   = &quot;${aws_vpn_connection.connection1.tunnel2_cgw_inside_address}/30&quot;<br>  vpn_tunnel = google_compute_vpn_tunnel.tunnel2_conn1.name<br>}<br>resource &quot;google_compute_router_interface&quot; &quot;interface1_conn2&quot; {<br>  name       = &quot;interface1-conn2&quot;<br>  router     = google_compute_router.main.name<br>  region     = var.gcp_region<br>  ip_range   = &quot;${aws_vpn_connection.connection2.tunnel1_cgw_inside_address}/30&quot;<br>  vpn_tunnel = google_compute_vpn_tunnel.tunnel1_conn2.name<br>}<br><br>resource &quot;google_compute_router_interface&quot; &quot;interface2_conn2&quot; {<br>  name       = &quot;interface2-conn2&quot;<br>  router     = google_compute_router.main.name<br>  region     = var.gcp_region<br>  ip_range   = &quot;${aws_vpn_connection.connection2.tunnel2_cgw_inside_address}/30&quot;<br>  vpn_tunnel = google_compute_vpn_tunnel.tunnel2_conn2.name<br>}<br># BGP Peers<br>resource &quot;google_compute_router_peer&quot; &quot;peer1_conn1&quot; {<br>  name                      = &quot;peer1-conn1&quot;<br>  router                    = google_compute_router.main.name<br>  region                    = var.gcp_region<br>  peer_ip_address          = aws_vpn_connection.connection1.tunnel1_vgw_inside_address<br>  peer_asn                 = aws_vpn_connection.connection1.tunnel1_bgp_asn<br>  advertised_route_priority = 100<br>  interface                = google_compute_router_interface.interface1_conn1.name<br>}<br>resource &quot;google_compute_router_peer&quot; &quot;peer2_conn1&quot; {<br>  name                      = &quot;peer2-conn1&quot;<br>  router                    = google_compute_router.main.name<br>  region                    = var.gcp_region<br>  peer_ip_address          = aws_vpn_connection.connection1.tunnel2_vgw_inside_address<br>  peer_asn                 = aws_vpn_connection.connection1.tunnel2_bgp_asn<br>  advertised_route_priority = 100<br>  interface                = google_compute_router_interface.interface2_conn1.name<br>}<br><br>resource &quot;google_compute_router_peer&quot; &quot;peer1_conn2&quot; {<br>  name                      = &quot;peer1-conn2&quot;<br>  router                    = google_compute_router.main.name<br>  region                    = var.gcp_region<br>  peer_ip_address          = aws_vpn_connection.connection2.tunnel1_vgw_inside_address<br>  peer_asn                 = aws_vpn_connection.connection2.tunnel1_bgp_asn<br>  advertised_route_priority = 100<br>  interface                = google_compute_router_interface.interface1_conn2.name<br>}<br><br>resource &quot;google_compute_router_peer&quot; &quot;peer2_conn2&quot; {<br>  name                      = &quot;peer2-conn2&quot;<br>  router                    = google_compute_router.main.name<br>  region                    = var.gcp_region<br>  peer_ip_address          = aws_vpn_connection.connection2.tunnel2_vgw_inside_address<br>  peer_asn                 = aws_vpn_connection.connection2.tunnel2_bgp_asn<br>  advertised_route_priority = 100<br>  interface                = google_compute_router_interface.interface2_conn2.name<br>}<br># Route propagation for VPN connections<br>resource &quot;aws_vpn_gateway_route_propagation&quot; &quot;connection1&quot; {<br>  vpn_gateway_id = aws_vpn_gateway.main.id<br>  route_table_id = aws_route_table.private.id<br>}<br>resource &quot;aws_vpn_gateway_route_propagation&quot; &quot;connection2&quot; {<br>  vpn_gateway_id = aws_vpn_gateway.main.id<br>  route_table_id = aws_route_table.private.id<br>}</pre><h3>Step 6: Adding Compute Resources for aws and gcp</h3><p>Let’s add some compute resources to test our connectivity:</p><pre># aws-compute.tf<br># Security Group for Private EC2<br>resource &quot;aws_security_group&quot; &quot;private_ec2&quot; {<br>  name_prefix = &quot;${var.project_name}-private-ec2-sg&quot;<br>  vpc_id      = aws_vpc.main.id<br>ingress {<br>    from_port   = 22<br>    to_port     = 22<br>    protocol    = &quot;tcp&quot;<br>    cidr_blocks = [var.gcp_vpc_cidr]<br>  }<br> ingress {<br>    from_port   = -1<br>    to_port     = -1<br>    protocol    = &quot;icmp&quot;<br>    cidr_blocks = [var.gcp_vpc_cidr]<br>  }<br>egress {<br>    from_port   = 0<br>    to_port     = 0<br>    protocol    = &quot;-1&quot;<br>    cidr_blocks = [&quot;0.0.0.0/0&quot;]<br>  }<br> tags = {<br>    Name = &quot;${var.project_name}-private-ec2-sg&quot;<br>  }<br>}<br># Get latest Amazon Linux 2 AMI<br>data &quot;aws_ami&quot; &quot;amazon_linux&quot; {<br>  most_recent = true<br>  owners      = [&quot;amazon&quot;]<br>filter {<br>    name   = &quot;name&quot;<br>    values = [&quot;amzn2-ami-hvm-*-x86_64-gp2&quot;]<br>  }<br> filter {<br>    name   = &quot;virtualization-type&quot;<br>    values = [&quot;hvm&quot;]<br>  }<br>}<br># Private EC2 Instance<br>resource &quot;aws_instance&quot; &quot;private&quot; {<br>  ami                    = data.aws_ami.amazon_linux.id<br>  instance_type          = &quot;t3.micro&quot;<br>  subnet_id              = aws_subnet.private.id<br>  vpc_security_group_ids = [aws_security_group.private_ec2.id]<br>  iam_instance_profile   = aws_iam_instance_profile.ec2_ssm_profile.name<br>  <br>  user_data = base64encode(&lt;&lt;-EOF<br>    #!/bin/bash<br>    yum update -y<br>    yum install -y amazon-ssm-agent tcpdump telnet<br>    systemctl enable amazon-ssm-agent<br>    systemctl start amazon-ssm-agent<br>    echo &quot;Private EC2 instance in AWS&quot; &gt; /home/ec2-user/info.txt<br>  EOF<br>  )<br>tags = {<br>    Name = &quot;${var.project_name}-aws-private-ec2&quot;<br>  }<br>}<br><br><br># gcp-compute.tf<br># Firewall rules<br>resource &quot;google_compute_firewall&quot; &quot;allow_iap_ssh&quot; {<br>  name    = &quot;${var.project_name}-allow-iap-ssh&quot;<br>  network = google_compute_network.main.name<br><br>  allow {<br>    protocol = &quot;tcp&quot;<br>    ports    = [&quot;22&quot;]<br>  }<br><br>  source_ranges = [&quot;0.0.0.0/0&quot;]  <br>  target_tags   = [&quot;private-vm&quot;]<br>}<br><br>resource &quot;google_compute_firewall&quot; &quot;allow_aws&quot; {<br>  name    = &quot;${var.project_name}-allow-aws-access&quot;<br>  network = google_compute_network.main.name<br><br>  allow {<br>    protocol = &quot;tcp&quot;<br>    ports    = [&quot;22&quot;]<br>  }<br><br>  allow {<br>    protocol = &quot;icmp&quot;<br>  }<br><br>  source_ranges = [var.aws_vpc_cidr]<br>  target_tags   = [&quot;private-vm&quot;]<br>}<br><br># Private GCP VM<br>resource &quot;google_compute_instance&quot; &quot;private&quot; {<br>  name         = &quot;${var.project_name}-gcp-private-vm&quot;<br>  machine_type = &quot;e2-micro&quot;<br>  zone         = &quot;${var.gcp_region}-a&quot;<br><br>  boot_disk {<br>    initialize_params {<br>      image = &quot;debian-cloud/debian-11&quot;<br>    }<br>  }<br><br>  network_interface {<br>    network    = google_compute_network.main.id<br>    subnetwork = google_compute_subnetwork.main.id<br>    # No external IP - private only<br>  }<br><br>  metadata_startup_script = &lt;&lt;-EOF<br>    #!/bin/bash<br>    apt-get update<br>    apt-get install -y tcpdump telnet<br>    echo &quot;Private VM instance in GCP&quot; &gt; /home/info.txt<br>  EOF<br><br>  tags = [&quot;private-vm&quot;]<br>}</pre><h3>Step 7: IAM Roles for Management + SSM</h3><p>For secure management without SSH keys:</p><pre># iam-roles.tf<br>resource &quot;aws_iam_role&quot; &quot;ec2_ssm_role&quot; {<br>  name = &quot;${var.project_name}-ec2-ssm-role&quot;<br>assume_role_policy = jsonencode({<br>    Version = &quot;2012-10-17&quot;<br>    Statement = [<br>      {<br>        Action = &quot;sts:AssumeRole&quot;<br>        Effect = &quot;Allow&quot;<br>        Principal = {<br>          Service = &quot;ec2.amazonaws.com&quot;<br>        }<br>      }<br>    ]<br>  })<br> tags = {<br>    Name = &quot;${var.project_name}-ec2-ssm-role&quot;<br>  }<br>}<br>resource &quot;aws_iam_role_policy_attachment&quot; &quot;ec2_ssm_policy&quot; {<br>  role       = aws_iam_role.ec2_ssm_role.name<br>  policy_arn = &quot;arn:aws:iam::aws:policy/AmazonSSMManagedInstanceCore&quot;<br>}<br>resource &quot;aws_iam_instance_profile&quot; &quot;ec2_ssm_profile&quot; {<br>  name = &quot;${var.project_name}-ec2-ssm-profile&quot;<br>  role = aws_iam_role.ec2_ssm_role.name<br>}<br># Security Group for VPC Endpoints<br>resource &quot;aws_security_group&quot; &quot;vpc_endpoint&quot; {<br>  name_prefix = &quot;${var.project_name}-vpc-endpoint-sg&quot;<br>  vpc_id      = aws_vpc.main.id<br><br>  ingress {<br>    from_port   = 443<br>    to_port     = 443<br>    protocol    = &quot;tcp&quot;<br>    cidr_blocks = [var.aws_vpc_cidr]<br>  }<br><br>  egress {<br>    from_port   = 0<br>    to_port     = 0<br>    protocol    = &quot;-1&quot;<br>    cidr_blocks = [&quot;0.0.0.0/0&quot;]<br>  }<br><br>  tags = {<br>    Name = &quot;${var.project_name}-vpc-endpoint-sg&quot;<br>  }<br>}<br><br># VPC Endpoints for SSM<br>resource &quot;aws_vpc_endpoint&quot; &quot;ssm&quot; {<br>  vpc_id              = aws_vpc.main.id<br>  service_name        = &quot;com.amazonaws.${var.aws_region}.ssm&quot;<br>  vpc_endpoint_type   = &quot;Interface&quot;<br>  subnet_ids          = [aws_subnet.private.id]<br>  security_group_ids  = [aws_security_group.vpc_endpoint.id]<br>  private_dns_enabled = true<br><br>  tags = {<br>    Name = &quot;${var.project_name}-ssm-vpc-endpoint&quot;<br>  }<br>}<br><br>resource &quot;aws_vpc_endpoint&quot; &quot;ssm_messages&quot; {<br>  vpc_id              = aws_vpc.main.id<br>  service_name        = &quot;com.amazonaws.${var.aws_region}.ssmmessages&quot;<br>  vpc_endpoint_type   = &quot;Interface&quot;<br>  subnet_ids          = [aws_subnet.private.id]<br>  security_group_ids  = [aws_security_group.vpc_endpoint.id]<br>  private_dns_enabled = true<br><br>  tags = {<br>    Name = &quot;${var.project_name}-ssm-messages-vpc-endpoint&quot;<br>  }<br>}<br><br>resource &quot;aws_vpc_endpoint&quot; &quot;ec2_messages&quot; {<br>  vpc_id              = aws_vpc.main.id<br>  service_name        = &quot;com.amazonaws.${var.aws_region}.ec2messages&quot;<br>  vpc_endpoint_type   = &quot;Interface&quot;<br>  subnet_ids          = [aws_subnet.private.id]<br>  security_group_ids  = [aws_security_group.vpc_endpoint.id]<br>  private_dns_enabled = true<br><br>  tags = {<br>    Name = &quot;${var.project_name}-ec2-messages-vpc-endpoint&quot;<br>  }<br>}<br><br>resource &quot;aws_vpc_endpoint&quot; &quot;s3&quot; {<br>  vpc_id          = aws_vpc.main.id<br>  service_name    = &quot;com.amazonaws.${var.aws_region}.s3&quot;<br>  route_table_ids = [aws_route_table.private.id]<br><br>  tags = {<br>    Name = &quot;${var.project_name}-s3-vpc-endpoint&quot;<br>  }<br>}</pre><h3>Output</h3><pre># outputs.tf<br>output &quot;aws_vpc_id&quot; {<br>  description = &quot;AWS VPC ID&quot;<br>  value       = aws_vpc.main.id<br>}<br><br>output &quot;gcp_vpc_id&quot; {<br>  description = &quot;GCP VPC ID&quot;<br>  value       = google_compute_network.main.id<br>}<br><br>output &quot;aws_vpn_connection1_id&quot; {<br>  description = &quot;AWS VPN Connection 1 ID&quot;<br>  value       = aws_vpn_connection.connection1.id<br>}<br><br>output &quot;aws_vpn_connection2_id&quot; {<br>  description = &quot;AWS VPN Connection 2 ID&quot;<br>  value       = aws_vpn_connection.connection2.id<br>}<br><br>output &quot;gcp_vpn_gateway_interface0_ip&quot; {<br>  description = &quot;GCP VPN Gateway Interface 0 IP&quot;<br>  value       = google_compute_ha_vpn_gateway.main.vpn_interfaces[0].ip_address<br>}<br><br>output &quot;gcp_vpn_gateway_interface1_ip&quot; {<br>  description = &quot;GCP VPN Gateway Interface 1 IP&quot;<br>  value       = google_compute_ha_vpn_gateway.main.vpn_interfaces[1].ip_address<br>}<br><br>output &quot;aws_private_ec2_ip&quot; {<br>  description = &quot;AWS Private EC2 IP Address&quot;<br>  value       = aws_instance.private.private_ip<br>}<br><br>output &quot;aws_private_ec2_id&quot; {<br>  description = &quot;AWS Private EC2 Instance ID&quot;<br>  value       = aws_instance.private.id<br>}<br><br>output &quot;gcp_private_vm_ip&quot; {<br>  description = &quot;GCP Private VM IP Address&quot;<br>  value       = google_compute_instance.private.network_interface[0].network_ip<br>}<br><br><br># Connection test commands<br>output &quot;connectivity_test_commands&quot; {<br>  description = &quot;Commands to test connectivity&quot;<br>  value = {<br>    from_aws_to_gcp = &quot;ping ${google_compute_instance.private.network_interface[0].network_ip}&quot;<br>    from_gcp_to_aws = &quot;ping ${aws_instance.private.private_ip}&quot;<br>   <br>  }<br>}</pre><h3>Step 8: Deployment</h3><p>Now let’s deploy our infrastructure:</p><ol><li><strong>Initialize Terraform:</strong></li></ol><pre>terraform init</pre><ol><li><strong>Create a terraform.tfvars file:</strong></li></ol><pre>gcp_project_id = &quot;your-gcp-project-id&quot;<br>aws_region     = &quot;us-east-1&quot;<br>gcp_region     = &quot;us-central1&quot;<br>project_name   = &quot;my-multicloud-vpn&quot;</pre><ol><li><strong>Plan the deployment:</strong></li></ol><pre>terraform plan</pre><ol><li><strong>Apply the configuration:</strong></li></ol><pre>terraform apply</pre><h3>Step 9: Testing Connectivity</h3><p>After deployment, test the connection:</p><ol><li><strong>Connect to AWS EC2 via SSM:</strong></li><li><strong>Test ping to GCP VM:</strong></li></ol><pre>aws ssm start-session --target i-1234567890abcdef0</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/881/1*JXVqWwFHldKD5dWP3jJt0w.png" /></figure><blockquote><strong><em>Note:</em></strong><em> The instance may take a few minutes to become available if it’s still initializing or registering with the SSM service. Make sure the instance has the </em><strong><em>AmazonSSMManagedInstanceCore</em></strong><em> policy attached.</em></blockquote><ol><li><strong>Connect to GCP VM:</strong></li><li><strong>Test ping to AWS EC2:</strong></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uiVNpYSDksJL9elleLKWQw.png" /></figure><pre>ping 10.1.1.187  # AWS EC2 IP</pre><h3>Understanding High Availability</h3><p>Our setup creates <strong>4 VPN tunnels</strong>:</p><ul><li>2 tunnels from AWS VPN Connection 1 to GCP Interface 0</li><li>2 tunnels from AWS VPN Connection 2 to GCP Interface 1</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MIgLsvkmp-3TCJNLWamE_g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xpuy-PuucxoXLkQas0F_Dw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sz_QpF4kvHbdwv_Hv_PxnQ.png" /></figure><p>This provides:</p><ul><li><strong>99.95% availability</strong> (compared to 99.9% for single tunnel)</li><li><strong>Automatic failover</strong> via BGP</li><li><strong>Load distribution</strong> across tunnels</li></ul><h3><strong>Security Best Practices Implemented</strong></h3><ol><li><strong>No Direct Internet Access:</strong> Private instances use VPC endpoints/NAT for updates</li><li><strong>Principle of Least Privilege:</strong> Security groups allow only necessary traffic</li><li><strong>Encrypted Communication:</strong> All VPN tunnels use IPSec encryption</li><li><strong>Separate Network Segments:</strong> Different CIDR blocks prevent conflicts</li></ol><h3>Conclusion</h3><p>Congratulations! You’ve successfully built a highly available, secure multi-cloud VPN connection between AWS and GCP. This infrastructure provides:</p><ul><li><strong>Reliable connectivity</strong> with automatic failover</li><li><strong>Secure communication</strong> through encrypted tunnels</li><li><strong>Production-ready architecture</strong> following cloud best practices</li><li><strong>Cost-effective solution</strong> for multi-cloud networking</li></ul><p>This setup forms the foundation for more complex multi-cloud architectures, enabling you to leverage the best services from both AWS and GCP while maintaining secure, reliable connectivity between them.</p><p><em>Have questions or run into issues? Feel free to reach out in the comments below. Happy multi-cloud networking!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dba591e9fd48" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>