The Simplest Way to Make AWS CDK and Azure VMs Work Like They Should

Published
Length
3 min read

Luis Felipe Dias

All posts

Teams use aws cdk and azure vms to manage cross-cloud resources from one code repo. Your deployment script builds cloud networks and sets up virtual machines in one run. Many companies run apps across two or more cloud providers at the same time. Writing two separate deployment workflows takes too much time and causes human errors. Teams want to write code in one language and push changes to both clouds. This unified workflow keeps server settings matched across every single account. How aws

Your coding agents run with your access.

Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.

Teams use aws cdk and azure vms to manage cross-cloud resources from one code repo. Your deployment script builds cloud networks and sets up virtual machines in one run.

Many companies run apps across two or more cloud providers at the same time. Writing two separate deployment workflows takes too much time and causes human errors. Teams want to write code in one language and push changes to both clouds. This unified workflow keeps server settings matched across every single account.

How aws cdk and azure vms share roles and data

At its core, the AWS kit turns your code into cloud deployment templates. By itself, that standard tool only talks to Amazon web services. To reach Microsoft servers, teams pair this kit with Terraform cloud development adapters. Or, they trigger custom outbound web hooks during the stack build phase. Both paths let one code repo define resources for both cloud providers.

First, the build runner logs into the first cloud using a temporary role. Next, it needs a valid token to talk to the Microsoft resource manager. The safest way to do this is through workload identity federation. The runner trades its first cloud token for an active Microsoft directory token. You never have to store static client secrets inside your source code repo.

Once logged in, the runner sends machine definitions to the target resource group. It sets up virtual networks, disks, and network cards for the new servers. Then, the cloud API boots the virtual machines and returns their private addresses. The build tool saves those addresses so other cloud services can route traffic.

Common failure modes in cross-cloud server builds

The biggest risk in cross-cloud builds is using one shared admin service account. Teams often create one service principal with full rights over every virtual machine. They put that static key into the build server to save setup time. If an attacker steals that key, they can delete every server you own.

Broad network paths create another major risk between your two cloud accounts. Engineers often open public ports on new machines so build scripts can connect. Public ports invite bots to test passwords all day and night. Also, direct scripts run commands on machines without recording who triggered the change. When a server breaks, you have no audit log to find the root cause.

AWS CDK Security Constructs + Azure RBAC: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

To fix this, give each build pipeline its own scoped cloud role. Limit that role so it can only touch one specific resource group. Use private network peering or virtual private networks between the two cloud providers. Never assign public IP addresses to backend machines unless they serve public traffic.

Scoping permissions and machine state updates

State drift happens when engineers log into virtual machines and change settings by hand. Your deployment code thinks the server looks one way, but reality is different. The next time the pipeline runs, it might overwrite those manual fixes. Even worse, the build might fail halfway through and break production traffic.

Treat your cross-cloud servers as immutable units whenever you can. When a machine needs a software update, build a fresh disk image first. Then, let your code swap the old virtual machine for a new one. Keep persistent data on separate managed disks or external database services. This habit makes server replacements fast, safe, and easy to repeat.

Still, engineers sometimes need live shell or database sessions to fix urgent bugs. When they connect to those machines, you must check their team identity first. Map every human session to a real person instead of a shared key. Redact sensitive fields like emails, phone numbers, and card numbers in query results. Masking rewrites matched fields in results before they reach the user screen.

Govern statements and responses across databases and APIs

Good config and scoped roles are needed setup. They do not check single queries in flight or mask sensitive fields in returned rows. Across Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, and internal HTTP endpoints, hoop.dev runs beside each supported service as an open-source proxy, a sidecar for your database or API.

First, hoop.dev guardrails block banned queries before they run. Then hoop.dev data masking rewrites matched sensitive values in responses in memory. The audit trail records every statement and verdict per resource. Furthermore, hoop.dev holds SOC 2 Type II and is open source on GitHub.

Frequently asked questions

Can AWS CDK deploy Azure virtual machines directly?

Standard AWS CDK only builds Amazon resources out of the box. You must use the Terraform CDK adapter or custom resource hooks for Azure.

How should build pipelines log into Azure from AWS?

Use OpenID Connect federation between your AWS build role and Microsoft Entra ID. This setup trades short-lived tokens so you never store static passwords.

How do we stop state drift on Azure virtual machines?

Lock down direct shell changes and push all updates through your code repo. Replace whole machine images instead of patching live servers by hand.

The query runs. The emails stay hidden.