creating-secrets-using-best-practices — Claude Code skill
Walks the agent through creating an AWS Secrets Manager secret with a dedicated KMS key, a tight IAM policy and rotation. Useful when the secret is headed for production.
npx skills add aws/agent-toolkit-for-aws --skill creating-secrets-using-best-practices -a claude-codeWhat creating-secrets-using-best-practices does
The skill gives the agent a fixed order for creating a secret in AWS Secrets Manager. It points to references/create-secrets-using-best-practices.md and follows the procedure: a dedicated KMS key, an IAM policy with the narrowest rights, CloudTrail events, automatic rotation, lifecycle handling. Database credentials, API keys, OAuth tokens and custom secrets each get their own shape.
Each failure mode has its own section. For KMS trouble the agent checks that the IAM principal holds kms:CreateKey and kms:PutKeyPolicy, and that the key policy grants kms:GenerateDataKey, kms:Decrypt and kms:DescribeKey with a kms:ViaService condition on secretsmanager.<region>.amazonaws.com.
Rotation rests on a Lambda function. If that function is missing or cannot reach the target system, the rotation step fails and CloudWatch logs are where you look. Access denied usually means the IAM policy sits on the wrong principal, or the call is not over HTTPS. Check both before rewriting the policy.
What it helps with
- create a production secret in AWS Secrets Manager with its own KMS key
- turn on automatic rotation for a database password
- find out why the Lambda rotation function cannot reach the target system
- scope a KMS key policy to the key operations a reader or writer actually needs
- audit secret access through CloudTrail
Example prompts for the agent
- Create a Secrets Manager secret for the production database using the best-practice procedure
- Why does reading the secret fail when the IAM policy and the KMS key policy are already in place?
- Set up Lambda rotation for an API key and tell me what to look for in CloudWatch logs
How to install creating-secrets-using-best-practices
1Skills CLI (Vercel)
npx skills add aws/agent-toolkit-for-aws --skill creating-secrets-using-best-practices -a claude-code2Manually: put the files in place
~/.claude/skills/creating-secrets-using-best-practices/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/creating-secrets-using-best-practices/
1Skills CLI (Vercel)
npx skills add aws/agent-toolkit-for-aws --skill creating-secrets-using-best-practices -a codex2Manually: put the files in place
.agents/skills/creating-secrets-using-best-practices/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add aws/agent-toolkit-for-aws --skill creating-secrets-using-best-practices -a cursor2Manually: put the files in place
.cursor/skills/creating-secrets-using-best-practices/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install aws/agent-toolkit-for-aws creating-secrets-using-best-practices2Manually: put the files in place
.github/skills/creating-secrets-using-best-practices/SKILL.md1Skills CLI (Vercel)
npx skills add aws/agent-toolkit-for-aws --skill creating-secrets-using-best-practices -a gemini-cli2Platform CLI
gemini skills install https://github.com/aws/agent-toolkit-for-aws --path skills/specialized-skills/security-and-identity-skills/creating-secrets-using-best-practicesManually: put the files in place
.devin/skills/creating-secrets-using-best-practices/SKILL.mdThe legacy .windsurf/skills/ path still works
Skills CLI (Vercel)
npx skills add aws/agent-toolkit-for-aws --skill creating-secrets-using-best-practices -a opencodeClaude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
Step by step, with commands for each platform: How to install skills in Claude Code: five ways
Questions about creating-secrets-using-best-practices
How do I install creating-secrets-using-best-practices in Claude Code?
Run npx skills add aws/agent-toolkit-for-aws --skill creating-secrets-using-best-practices -a claude-code. The skill then sits at ~/.claude/skills/creating-secrets-using-best-practices/SKILL.md.
What does this skill do?
It takes the agent through creating and securing a secret in AWS Secrets Manager: a KMS key, a least-privilege IAM policy, rotation, CloudTrail auditing and lifecycle handling.
Which platforms does it work with?
Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI and OpenCode. For GitHub Copilot install it with gh skill install aws/agent-toolkit-for-aws creating-secrets-using-best-practices.
Source text
SKILL.md · Apache-2.0
--- name: creating-secrets-using-best-practices description: Creates and manages secrets in AWS Secrets Manager following security best practices. Always use this skill when creating secrets — it sets up dedicated KMS encryption keys, automatic rotation, least-privilege IAM policies, CloudTrail auditing, and lifecycle management that are essential for production-grade secret handling. version: 1 --- # Creating Secrets Using Best Practices ## Overview Domain expertise for creating and managing secrets in AWS Secrets Manager with production-grade security controls: KMS encryption, automatic rotation, least-privilege IAM policies, CloudTrail auditing, and lifecycle management. ## Create a secret with best practices To create a properly secured secret in AWS Secrets Manager, follow the procedure exactly. See [secret creation procedure](references/create-secrets-using-best-practices.md). The procedure supports four secret types: database credentials, API keys, OAuth tokens, and custom secrets. Each type is structured appropriately and encrypted with a dedicated KMS key. ## Troubleshooting ### KMS key access issues Verify the IAM principal has `kms:CreateKey` and `kms:PutKeyPolicy` permissions, and that the key policy grants `kms:GenerateDataKey`, `kms:Decrypt`, and `kms:DescribeKey` scoped with `kms:ViaService` to `secretsmanager.<region>.amazonaws.com`. See the full procedure for details. ### Rotation setup failures Check that the Lambda rotation function exists, has proper permissions, and can reach the target system. Review CloudWatch logs for the rotation function. ### Secret access denied Verify the IAM policy is attached to the correct principal, the KMS key policy allows decryption (and `kms:GenerateDataKey` for write/rotation), and the principal is using HTTPS. See the full procedure for details.
© aws · Apache-2.0 · aws/agent-toolkit-for-aws