The Simplest Way to Make AWS CloudFormation and Azure Cosmosdb Work Like They Should

Published
Length
4 min read

Luis Felipe Dias

All posts

Teams use aws cloudformation and azure cosmosdb together by building custom stack handlers. These handlers call Azure APIs to set up tables, keys, and network rules. Multi-cloud teams often run their core apps on AWS. Yet they store global data in Azure for low delay and fast reads. Managing two sets of cloud templates slows down releases and causes drift. A unified template workflow lets one stack manage both AWS apps and Azure data stores. Your team defines the whole app state in one place. W

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 cloudformation and azure cosmosdb together by building custom stack handlers. These handlers call Azure APIs to set up tables, keys, and network rules.

Multi-cloud teams often run their core apps on AWS. Yet they store global data in Azure for low delay and fast reads. Managing two sets of cloud templates slows down releases and causes drift. A unified template workflow lets one stack manage both AWS apps and Azure data stores. Your team defines the whole app state in one place. When a stack runs, it creates the AWS compute and sets up the Azure database.

How aws cloudformation and azure cosmosdb share permissions and data

AWS templates do not support Azure resources out of the box. You bridge this gap with custom resource handlers or registry extensions in AWS. When you launch a stack, the template triggers a small serverless function in AWS. That function acts as the worker that talks to the Azure control plane.

First, the worker must log in to Azure safely. The best method uses open identity federation between AWS and Azure. The AWS role gets a short token from its own identity service. Next, it trades that token for an Azure directory token. No static keys or passwords sit inside your template files. Once logged in, the worker sends requests to the Azure management API. It creates the database account, sets throughput limits, and picks the regions.

After the database exists, the AWS app needs a way to read and write data. You should avoid passing the master database key back to the stack output. Instead, your worker assigns an Azure role to the app identity. The app then logs in with short tokens at runtime. Data flows over private links or VPN tunnels between the two clouds. This keeps all query traffic off the public web.

Common failure modes and how to scope roles

Many teams make the mistake of using one shared service account for all stacks. They store a long-lived Azure client secret in an AWS parameter store. If a developer reads that secret, they gain full control over every database. Another common failure is granting broad owner roles to the deployment worker. If a template has a bug, it could wipe out production tables by mistake.

Unlogged database queries also create big risks for multi-cloud teams. When apps use shared master keys, the database log shows every query from the same user. You cannot tell which microservice or engineer ran a bad delete command. Also, raw query results might return sensitive fields like emails or card numbers. Without field masking, those details end up in app logs or test consoles. Masking rewrites matched fields in results such as phone numbers or national IDs.

AWS IAM Policies + Azure RBAC: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

You can fix these issues by scoping roles to the smallest needed task. Give each stack worker its own federated role in Azure. Limit that role so it only manages one specific resource group. Set a delete lock on your production database accounts in Azure. Even if a stack tears down, the lock stops the worker from dropping live data.

Separate your control plane roles from your data plane roles. The stack worker should only set up the database structure and network rules. It should never have permission to read or write items inside the tables. Your runtime apps get a separate role that only reads or writes specific containers. Finally, restrict the database firewall to only accept traffic from your AWS private subnets.

Managing day two updates and schema drift

Day two changes often break custom multi-cloud stacks if you do not plan ahead. An engineer might change a throughput setting straight in the Azure portal. Now the AWS stack state does not match the real Azure setup. The next time the stack runs, it may fail or overwrite the manual change.

To prevent this, block manual edits in the Azure portal for production groups. Force all changes to go through your stack templates. Your custom handler must also handle update and delete events with care. When a stack updates, the worker should check the current state in Azure first. It should only send changes for the settings that actually shifted. Good error handling ensures a failed Azure API call rolls the AWS stack back cleanly.

Check database and API queries on the wire

Identity tools, roles, and network rules decide who opens a session. Setup alone cannot check what each query does or mask sensitive values in a response once a session starts. When workflows touch Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, or internal HTTP APIs, hoop.dev runs beside those services as an open-source proxy, a sidecar for your Postgres or API. It inspects requests coming in and results going back on the wire.

Your login details and client tools stay as they are while hoop.dev guardrails refuse bad deletes or drops before they run. On responses, hoop.dev data masking rewrites matched sensitive values in memory. Furthermore, hoop.dev holds SOC 2 Type II, is MIT licensed, and writes every query and decision to an audit trail that generates evidence for HIPAA, GDPR, and PCI DSS. See the source on GitHub.

Frequently asked questions

Can an AWS stack create an Azure database without custom code?

No, AWS templates only build AWS items by default. You must add a custom resource function or a third-party registry extension to call Azure APIs.

How do we avoid storing Azure secrets in AWS templates?

Set up identity federation between your AWS account and your Azure directory. The AWS worker trades its native role token for a short Azure token at runtime.

What happens to the Azure data if someone deletes the AWS stack?

By default, a delete event tells the worker to remove the database. You can set a retention policy in the template and add an Azure delete lock to keep data safe.

The query runs. The emails stay hidden.