DevOps Engineer
Soumya specializes in Google Cloud Platform (GCP), DevOps, and cloud optimization, focusing on automation and building scalable, reliable cloud solutions, with an emphasis on performance, efficie
In a multi-cloud setup, workloads in one cloud often depend on services in another. Here, our container images sit in a private Amazon ECR repository on AWS, while the workloads that need them run on GCP. This is where things get interesting. Your GCP Instance has no route to or from the open internet, with no egress and no ingress. That creates a problem: by default, AWS ECR hostnames resolve to public IPs, and the AWS-managed private hosted zones created for VPC endpoints can’t be queried from outside the AWS VPC. As a result, the VM can't resolve ECR hostnames or reach ECR privately.
Picture a GCP Compute Engine VM with no external IP and no NAT or internet gateway route. It still needs to authenticate to a private ECR repository and run docker pull. For this to work, every hop must stay on a private path: DNS resolution, authentication, manifest fetch, and image layer download.
The private path comes together in two steps:
High-Level Architecture Diagram

What this diagram covers: everything built in this blog - the AWS-side PrivateLink endpoints and Route 53 Resolver, along with the GCP-side Cloud DNS forwarding and Secret Manager path - validated against a single Compute Engine VM.
Why AWS EC2 first, then GCP: Section 1 confirms that the AWS-side endpoints and DNS work correctly on their own, using a client (EC2) that already sits inside the AWS VPC, so no cross-cloud DNS forwarding is involved yet. Section 2 then introduces exactly one new variable (reaching those same endpoints across the Transit Gateway). This way, if anything goes wrong, it is much easier to trace it to the GCP-side DNS/network path rather than the ECR configuration itself.
In this section, we build the AWS-side private path to ECR (interface endpoints, security, DNS) on top of the working TGW/VPN foundation, and verify a full authenticate-and-pull cycle from the EC2 instance before extending it to GCP in Section 2.
Why: ECR splits its functionality across two distinct PrivateLink services. ecr.api handles the GetAuthorizationToken API call (what aws ecr get-login-password calls behind the scenes - the authentication/login step), while ecr.dkr handles the Docker Registry protocol itself (manifest and layer metadata requests during docker pull/push). Both are needed together for a full pull to succeed privately; without either one, a different half of the flow is affected.
Equivalent CLI:
Verification: aws ec2 describe-vpc-endpoints --filters Name=service-name,Values=com.amazonaws.<region>.ecr.api,com.amazonaws.<region>.ecr.dkr - both should show State: available.
If this step is skipped or wrong: Without ecr.api, the authentication step is affected (get-login-password hangs or times out), while ecr.dkr would appear unaffected in isolation. Without ecr.dkr, the actual pull/push fails even after authentication has succeeded. The two situations look different and are diagnosed differently, so it is worth testing each endpoint's role separately rather than treating "ECR access" as one single thing.
Why: Interface endpoints are ENIs inside the VPC and, like any ENI, inbound access is controlled by a security group. Without an explicit allow rule, the endpoint accepts no traffic even though it shows as Available.
Equivalent CLI:

Verification: From the EC2 instance, run curl -v https://<account-id>.dkr.ecr.<region>.amazonaws.com - a TLS handshake response (even an auth error) confirms that the security group allows the connection, while a hang or timeout means the security group is still blocking it.
Why: By default, an interface endpoint's policy allows full access to the service for any principal. Scoping it down to the specific account/repository is a defense-in-depth measure, so the endpoint itself cannot be used to reach unrelated ECR resources even if IAM credentials are broader than intended.

Why: The identity used by the EC2 instance (and later, the CronJob in Part 3) should be able to pull only, and only from specific repositories - it should not be able to push, delete, or manage repositories, or reach images from other accounts.

Verification: aws ecr get-login-password should still succeed, while a docker pull of an image outside the listed repository should fail with AccessDenied. This confirms that the scoping is effective and not accidentally broader.
Important Consideration: ecr:GetAuthorizationToken cannot be scoped to a specific repository ARN - it is an account-level action by design and must use Resource: "*". This is a known, unavoidable exception rather than an oversight, and the pull permissions right below it remain scoped to the specific repository.
Why: Think of this as a second, independent layer of enforcement: it makes the repository itself refuse any request that did not arrive through the specific VPC endpoint, regardless of whether the caller's IAM credentials would otherwise be valid. This protects against credentials being used from outside the intended network path.
Verification: Attempt a pull with the same credentials from a machine outside the VPC (for example, a local laptop with internet access). It should now be explicitly denied, confirming that the condition is active.
If this step is skipped or wrong: Valid IAM credentials would work from anywhere on the internet, not just through the private path this entire setup was built to enforce - a gap that would not be visible from inside the VPC, since internal testing would keep succeeding either way.
Why: Enabling "Private DNS name" on each interface endpoint makes AWS automatically create and manage a Route 53 private hosted zone that resolves the standard ECR hostname to the endpoint's private IP.

Verification: From the EC2 instance, nslookup <account-id>.dkr.ecr.<region>.amazonaws.com should resolve to a private IP inside the VPC's CIDR, not a public IP.
Important Consideration: Hosted zones created this way are AWS-managed and are never visible in the Route 53 console's Hosted Zones list, no matter how the list is filtered or searched. At first glance, this looks identical to "the zone was never created", but it is expected behavior, not a fault. The only way to confirm these zones exist is the aws route53 list-hosted-zones-by-vpc CLI command above, which is also the only reliable way to get the exact domain name string needed later for the GCP-side Cloud DNS forwarding zones in Section 2.
Why: ECR does not serve image layer bytes itself - GetDownloadUrlForLayer returns a pre-signed S3 URL, and the actual layer download goes to S3 directly. In this POC, we initially configured an S3 Gateway Endpoint for this.

Verification: From the EC2 instance, a full docker pull (not just docker login) should now complete. With the original Gateway Endpoint configuration, authentication and the manifest fetch would succeed, but the pull would hang or fail specifically at the layer-download stage.
Important Considerations:
This is the acceptance test for this section. Confirm that both the authentication leg (ecr.api) and the pull leg (ecr.dkr + S3 interface endpoint) succeed entirely through the private path before moving on to Section 2.

Expected result: both commands complete with no internet route required. To confirm, check that the EC2 instance's route table has no 0.0.0.0/0 route to an Internet Gateway, or that the security group/NACLs would block such a path even if present.
If the pull fails partway (login succeeds, the manifest is fetched, and then it hangs), the S3 endpoint from Section 1.8 is the first place to check.
In this section, we extend the private path built in Section 2 across the Transit Gateway to a GCP VM, so that a docker pull from GCP resolves ECR/S3 hostnames to their private AWS IPs and completes with no internet access needed on the GCP side at all.
Why: This is the component that accepts DNS queries arriving from outside the AWS VPC - in our case, from the GCP VM over the TGW attachment. Without it, the AWS-managed private hosted zones from Section 2.7 cannot be queried from GCP at all.

Verification: Run aws route53resolver list-resolver-endpoints - the Status should be OPERATIONAL. Then use aws route53resolver get-resolver-endpoint --resolver-endpoint-id <id> to retrieve the IP addresses.
If this step is skipped or wrong: DNS queries from GCP silently fail to reach the resolver (dropped by the security group), which shows up on the GCP side as a SERVFAIL response rather than an obviously network-related error. More on this in the troubleshooting walkthrough in Section 2.6.
Why: Cloud DNS forwarding zones (Section 2.4) must use the exact domain name AWS assigned to each private hosted zone. Guessing the format is unreliable, particularly for the S3 interface endpoint's zone.
Verification: Confirm that entries exist for the ecr.api, ecr.dkr and S3 interface endpoint domains, and note each exact domain string (including the trailing dot) for use in Section 2.4.
Why: A private forwarding zone tells Cloud DNS to forward, rather than answer, any query that matches a given domain suffix. The query goes to the Route 53 Resolver Inbound Endpoint instead of being resolved locally or via public DNS.

Verification: From the GCP VM, nslookup <account-id>.dkr.ecr.<region>.amazonaws.com should return a private IP in the AWS VPC's CIDR range, not a public one.
If this step is skipped or wrong: If a forwarding zone is missing for any one of the 7 domains, a different, specific stage of the pull is affected: a missing api.ecr zone affects authentication, a missing dkr.ecr zone affects the manifest fetch, and a missing S3 zone affects layer download specifically.
Why: The GCP VM needs AWS credentials without any internet access. Secret Manager is a Google API, reachable via Private Google Access (or Private Service Connect) entirely within Google's network, regardless of the VM's internet connectivity. It is a genuinely separate private path from the AWS-facing one built above.

Design note on static credentials: This guide deliberately uses a long-lived AWS access key rather than IAM Roles Anywhere. This was a conscious trade-off, not an oversight: a static key removes the need for two additional interface endpoints (rolesanywhere, sts) and their associated DNS/policy work, at the cost of losing automatic credential expiry. Both approaches work identically for the private-connectivity path described here. Static keys do not need rotation to function, but rotation remains a recommended security practice regardless, since it limits the exposure window if the key is ever leaked - a separate concern from whether the pull itself succeeds.
We ran into a real failure at this stage, so the diagnostic method is shared here as a reusable pattern, not just the eventual fix.

SERVFAIL is a specific, meaningful signal: it tells us that Cloud DNS matched the forwarding zone and attempted to forward the query, but the forwarding attempt itself did not succeed. This is distinct from a timeout (nothing answered at all) or NXDOMAIN (something answered that the name does not exist).
As a first isolation step, bypass Cloud DNS and query the Resolver Inbound Endpoint directly to determine which side of the GCP/AWS boundary the issue is on.

Add a new inbound rule allowing TCP 443 from the Google Cloud DNS IP Range (35.199.192.0/19) in the security groups (see Section 2.3) attached to both the ECR interface endpoints and the S3 endpoint. Add the same rule to the security group of the Route 53 Resolver endpoint as well.

Expected result: a successful pull, with the GCP VM having no external IP and no NAT/internet gateway route at any point. This is confirmed by the absence of any working route to the public internet on the VM, not merely by the pull succeeding (which would also succeed if a NAT path existed unnoticed).
With this setup in place, your GCP workloads can pull images from a private Amazon ECR repository entirely over private connectivity. DNS queries for ECR hostnames are forwarded to the AWS VPC, where they resolve to the private IPs of your VPC endpoints. Image pulls then travel across the private link between the two clouds, so nothing is exposed to the open internet, and your GCP VMs need no egress or ingress route to it.