creating-secrets-using-best-practices

Creates AWS Secrets Manager secrets with KMS encryption, rotation, and least-privilege IAM policies.

Updated Jul 1, 2026
One-click install
npx skills add https://github.com/sakicodes/BuildFestHackathon26 --skill creating-secrets-using-best-practices-sakicodes
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: creating-secrets-using-best-practices
Source: https://github.com/sakicodes/BuildFestHackathon26/tree/main/.agents/skills/creating-secrets-using-best-practices
Command: npx skills add https://github.com/sakicodes/BuildFestHackathon26 --skill creating-secrets-using-best-practices-sakicodes

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Manually creating secrets in AWS Secrets Manager often skips critical security controls like dedicated KMS encryption, automatic rotation, and least-privilege access, leaving credentials exposed. This Skill walks through a complete, security-first procedure so every secret is created with production-grade protections from the start. ## Core Features & Use Cases - Secure Secret Creation: Creates database credentials, API keys, OAuth tokens, and custom secrets encrypted with a dedicated KMS key whose policy is scoped to Secrets Manager via the kms:ViaService condition. - Automatic Rotation & IAM: Configures automatic rotation with AWS-managed or custom Lambda functions and generates least-privilege IAM policies scoped to specific secret and key ARNs with HTTPS enforcement. - Auditing & Lifecycle Management: Verifies CloudTrail logging, sets up CloudWatch alarms for failed retrievals and rotation failures, and applies tagging and recovery windows. - Use Case: A DevOps engineer needs to store production database credentials. The Skill creates the secret as structured JSON, provisions a dedicated KMS key, enables 30-day rotation, attaches a read-only IAM policy, and validates the entire setup. ## Quick Start Create a new database secret named prod-database-credentials in us-east-1 with automatic rotation enabled and tags for Environment and Owner.

Frequently Asked Questions about creating-secrets-using-best-practices

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create a secret in AWS Secrets Manager with automatic rotation?

Create the secret with a dedicated KMS key, then configure rotation with a specified interval in days. Database secrets use AWS-managed rotation functions, while custom secrets require a Lambda function ARN with permissions to access both the secret and the target system.

How to set up a KMS key policy for AWS Secrets Manager encryption?

Grant the calling principal kms:GenerateDataKey, kms:Decrypt, and kms:DescribeKey scoped with the kms:ViaService condition set to secretsmanager.{region}.amazonaws.com. Retain the root account as key administrator to prevent lockout and enable key rotation.

What secret types does AWS Secrets Manager support in this procedure?

The procedure supports four types: database credentials structured with host, username, password, engine, port, and dbname; API keys; OAuth tokens with client_id and client_secret; and custom secrets using any provided JSON structure.

Why does secret access get denied after creating an IAM policy?

Access is denied when the policy is not attached to the correct principal, the KMS key policy lacks kms:Decrypt permission, or the request does not use HTTPS. The generated policies enforce the aws:SecureTransport condition, so all access must use secure transport.

Why does Secrets Manager rotation setup fail?

Rotation fails when the Lambda function is missing, lacks permissions to access the secret or target system, or cannot reach the target over the network. Check CloudWatch logs for the rotation function and verify its execution role permissions.