Skip to main content
skill CX Codex

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.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add aws/agent-toolkit-for-aws --skill creating-secrets-using-best-practices -a claude-code
Open on GitHub

What 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-code

2Manually: put the files in place

~/.claude/skills/creating-secrets-using-best-practices/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/creating-secrets-using-best-practices/

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

Similar skills

Everything for Security →

From the same set133

aws-sdk-js-v3-usage Guides coding agents on AWS SDK for JavaScript v3 architecture, imports, and streams. It enforces modern modular patterns instead of legacy v2 code. CX Codex +1 8,000installs aws-sdk-python-usage Guides agents writing Python code with boto3 and botocore. It enforces official patterns for client versus resource choice, error handling, paginators, and session reuse. CX Codex +1 7,800installs securing-s3-buckets A skill that walks the agent through five S3 workflows: creating a secured bucket, auditing an existing one, fixing findings, configuring encryption and enabling monitoring. CX Codex +1 6,900installs connecting-to-data-source Builds and tests an AWS Glue connection to Oracle, PostgreSQL, Redshift, Snowflake or BigQuery, so a job does not discover the wiring is wrong at runtime. CX Codex +1 6,800installs storing-and-querying-vectors A skill that walks the agent through Amazon S3 Vectors: create a vector bucket and index, put embeddings, run similarity search. CX Codex +1 6,600installs querying-data-lake A skill that runs SQL in Amazon Athena: it picks a workgroup, stops destructive statements for confirmation and reports what the query cost. CX Codex +1 6,600installs exploring-data-catalog Audits and inventories AWS Glue Data Catalog, S3 Tables, and Redshift-federated catalogs. Built for mapping account data assets in read-only mode. CX Codex +1 6,600installs aws-sdk-swift-usage Teaches the agent the aws-sdk-swift patterns: clients, struct configs, credential resolvers, waiters. Useful when a Swift project talks to AWS. CX Codex +1 6,500installs

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor