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

Published
Length
3 min read

Luis Felipe Dias

All posts

Using aws cdk and azure key vault together lets teams build cloud stacks with shared secrets. Your deploy job reads keys from Azure and passes them into AWS resources during a run. Multi-cloud teams often keep central keys in Azure while running compute workloads in AWS. A clean setup links both clouds without storing static passwords in source control. Teams use federated identity so the build runner can log in and read only needed values. How aws cdk and azure key vault share keys and roles

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.

Using aws cdk and azure key vault together lets teams build cloud stacks with shared secrets. Your deploy job reads keys from Azure and passes them into AWS resources during a run.

Multi-cloud teams often keep central keys in Azure while running compute workloads in AWS. A clean setup links both clouds without storing static passwords in source control. Teams use federated identity so the build runner can log in and read only needed values.

How aws cdk and azure key vault share keys and roles

The workflow starts when your build runner starts a deploy job for your AWS stack. Instead of using a static key, the runner requests a temporary token from your identity provider. Azure checks this token against a trust rule on the vault.

Once the trust check passes, the build process can read the required secret value. You should not pass that plain text value straight into a stack template file. Cloud templates save their state as plain text, which exposes secret values to any reader.

A safer pattern copies the secret from Azure into an AWS secret store during deployment. Your AWS compute role then reads the local secret at runtime using standard cloud permissions. This keeps the secret out of template state files and build logs.

Common failure modes and how to scope cross-cloud roles

Many teams start by creating one shared service account in Azure for all deploy jobs. They put that client secret into a build server variable and forget about it. If one project leaks that token, an attacker can read every secret in the vault.

Broad read rules create another big risk for cloud teams. A single vault often holds database passwords, API keys, and signing certs for many apps. If a deploy role can list and read all items, one bad script can expose everything.

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

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Unlogged secret reads also hurt security teams during an audit. When five build pipelines share one identity, you cannot tell which job read a key. You need clear logs that show the exact job, user, and time for every read.

To fix this, give each app stack its own identity and role in Azure. Scope each role so it can read only the specific keys for that single app. Use workload identity federation so tokens expire fast and never sit on disk.

Keeping secret values out of deploy state

State files are the biggest trap when you use aws cdk and azure key vault. When your code fetches a secret at build time, the tool sees a raw string. It writes that string into the output template and stores it in your cloud account.

Anyone who can view deployment history in the AWS console can then read that password. Even if you lock down the Azure side, the AWS side leaks the secret. You must separate stack structure from secret values to keep your keys safe.

Use your stack code to create an empty secret placeholder in AWS first. Next, run a small sync step that pulls the secret from Azure and writes it there. Your app reads the secret by reference at startup, and the state file stays clean.

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

Should AWS apps read secrets straight from Azure at runtime?

Reading across clouds at runtime adds network delay and creates a cross-cloud failure point. Syncing the secret to a local AWS store during deploy is faster and more reliable.

How do we stop secrets from showing up in AWS template files?

Never resolve a secret value as a plain string inside your stack code. Create a secret resource reference first, then populate the value outside the template step.

What is the safest way for a build job to log in to Azure?

Use OpenID Connect federation between your build platform and your Azure directory. This gives each build job a short-lived token without storing long-term passwords.

The query runs. The emails stay hidden.