Build Log / Entry 004 / Platform
Hybrid cloud without a VPN.
For two years, Merger Daily's on-prem servers talked to AWS with no VPN and nothing open on-prem: polled queues, one-hour credentials, scoped NATS users.
The short version
- A VPN isn't required for hybrid cloud: poll SQS from on-prem, so nothing on-prem accepts a connection.
- Use IAM Roles Anywhere with a private CA instead of long-lived AWS access keys on your own servers.
- Give each service its own NATS user, scoped to the subjects its code uses; check the code, not the design.
In this entry · 5 sections
For about two years, Merger Daily ran as a hybrid. The application and its database ran in AWS. AI inference and long-running workflow processing ran on-prem, on a Proxmox cluster, next to our own AI hardware and models. Keeping that work on hardware we already owned cut costs, and kept it close to the models it used.
The two sides talked constantly, over the public internet, under one rule: nothing on-prem accepts an inbound connection.
Why not a VPN
A site-to-site VPN was the obvious option, and it would have worked. But a VPN connects networks: once it’s up, the question of what on-prem can reach in AWS is answered by routing tables and security groups, and the answer tends to grow over time.
We wanted the answer to be a short list. On-prem could read from specific queues, with one IAM role, and publish to specific NATS subjects, as specific users. Each direction got its own narrow mechanism instead of a shared network.
Events, polled from on-prem
Application events that the on-prem orchestrator (see entry 003) needed to act on went out as SNS FIFO messages, fanned out into SQS FIFO queues. The orchestrator polled those queues. Polling means on-prem always makes the connection; AWS never has to reach in, so nothing on-prem listens for anyone.
A message that failed three deliveries moved to a dead-letter queue instead of being dropped. The dead-letter queues keep messages for 14 days, the SQS maximum, which leaves time to find out why a message failed and send it again.
A certificate instead of an access key
Polling SQS still needs AWS credentials. In staging and production, rather than put a long-lived AWS access key on a machine in our own server room, the orchestrator used IAM Roles Anywhere. It held an X.509 certificate signed by a private certificate authority we created with OpenSSL. We considered AWS Private CA, but it charges a monthly fee per CA, and this needed only a handful of certificates.
The orchestrator presents the certificate and gets back AWS credentials that last one hour, refreshed automatically by AWS’s signing helper:
[profile merger-daily-orchestrator-prod]
credential_process = aws_signing_helper credential-process \
--certificate /etc/merger-daily/server-prod.crt \
--private-key /etc/merger-daily/server-prod.key \
--trust-anchor-arn arn:aws:rolesanywhere:us-east-1:<account-id>:trust-anchor/<id> \
--profile-arn arn:aws:rolesanywhere:us-east-1:<account-id>:profile/<id> \
--role-arn arn:aws:iam::<account-id>:role/merger-daily-orchestrator-prod
region = us-east-1No long-lived AWS secret sat on that machine. The credentials it did hold expired within the hour.
Real-time messages over NATS
Some traffic couldn’t wait for a poll: chat requests to the on-prem AI models and their streamed responses, and workflow events. That went over NATS JetStream in AWS.
In its final form, NATS accepted outside connections on one port, only from our on-prem IP range, and only over TLS. Each service had its own NATS user, allowed to publish and subscribe only on the subjects it uses. The orchestrator’s user, for example, can publish workflow events and nothing else:
{
user: "orchestrator-service", password: "<from Secrets Manager>"
permissions: {
publish: {
allow: [
"orchestrator.flow.>"
"$JS.API.STREAM.INFO.ORCHESTRATOR_WORKFLOW_EVENTS"
"_INBOX.>"
]
}
subscribe: { allow: ["_INBOX.>"] }
}
}Getting those lists right took more than one try. Our first permission sets came from the design documents, and they missed subjects the code actually used: one cost an outage in staging, and a missing acknowledgement permission caused a burst of redelivered messages in production. The lists in the config now carry a comment for each subject explaining which code needs it.
Where it ended up
For now, everything has moved to AWS, and the on-prem cluster is no longer part of Merger Daily. The SQS queues, dead-letter queues and per-service NATS users are still in place.