The Simplest Way to Make AWS Secrets Manager and GitHub Actions Work Like They Should
Using aws secrets manager and github actions lets teams pull secret values during build runs. This setup keeps static database passwords and API keys out of your source code. In a standard build, the runner requests a secret right before a deployment step. The cloud vault checks the runner identity and sends back the value for that job. Once the job finishes, the temporary runner deletes the memory and drops the secret. How aws secrets manager and github actions share data The best way to li
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 secrets manager and github actions lets teams pull secret values during build runs. This setup keeps static database passwords and API keys out of your source code.
In a standard build, the runner requests a secret right before a deployment step. The cloud vault checks the runner identity and sends back the value for that job. Once the job finishes, the temporary runner deletes the memory and drops the secret.
How aws secrets manager and github actions share data
The best way to link these tools is through OpenID Connect federation. GitHub issues a signed identity token to the workflow runner at the start of a job. The runner sends this token to the cloud identity service to ask for a role.
The cloud account checks the token signature and reads the repo and branch claims. If the claims match the trust rule, the cloud account returns short-lived session keys. The runner then uses those session keys to call the secret vault API.
Next, the vault checks the role permissions to see which secrets the job can read. It decrypts the allowed values and sends them over an encrypted link to the runner. The workflow masks these strings in build logs and sets them as job variables.
Common failure modes in build secret workflows
Many teams skip federation and store long-lived cloud keys inside repo settings. If an attacker steals those static keys, they can read secrets from any location. Static keys also require manual rotation, which often breaks builds when teams forget a repo.
Another common failure is setting up a trust rule that is way too broad. If a role trusts every branch, a pull request from a fork can assume it. That rogue workflow can then dump production secrets or connect straight to live databases.
AWS Secrets Manager + GitHub Actions Security: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Shared IAM roles also create big risks across multiple apps and teams. When ten repos share one role, every workflow gets read access to all ten secrets. A bug in one small test workflow can expose keys for your main payment system.
Scoping roles and network paths for build runners
To fix these gaps, give each repo and deployment stage its own cloud role. Set the trust rule so only the main branch or approved tags can log in. Lock each role down so it can read only the exact secrets it needs.
You should also audit every secret read event inside your cloud activity logs. Check that every request comes from an expected runner identity and a known workflow run. Alert your security team when a role tries to read a secret it should not touch.
Network rules matter just as much as identity checks when jobs talk to databases. Hosted runners run on shared public networks with wide IP ranges that change often. Opening your database firewall to all hosted runners exposes your data layer to outside traffic.
Instead of opening wide network ports, teams often run private runners inside their own cloud network. Private runners keep traffic on internal routes and let you enforce strict security group rules. You also need clear audit trails for what the runner does after it gets a database key.
Add runtime guardrails and masking beside your databases and APIs
Login rules, role grants, and CI checks govern who connects to your stack. Yet any allowed script, engineer, or AI agent still runs commands with the full scope of its role. For workloads on Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes, SSH, or internal HTTP services, hoop.dev sits beside the service as an open-source proxy, a sidecar for your database or API.
Before a query runs, hoop.dev guardrails check the statement against your rules. An AI Analyzer you configure can score intent or hold risky calls for human review. Next, hoop.dev data masking rewrites sensitive fields in responses, and each verdict is logged per listener. Explore the MIT-licensed project on GitHub.
Frequently asked questions
Should we store static cloud keys in GitHub secrets?
No, you should use OpenID Connect federation instead of static cloud keys. Federation creates short-lived tokens for each job so no long-lived keys sit in your repo.
How do we stop pull requests from reading production secrets?
Scope your cloud role trust rule to check the exact branch or workflow stage claim. Only allow jobs from your main branch or protected deployment stages to assume the production role.
Can workflow logs expose secrets pulled from the cloud vault?
Yes, a script can print secret values by mistake if you do not mask them. Make sure your workflow registers every secret string with the runner log masker right away.
Related guides
In this post