executing-plans
executing-plans
Use when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is available
aws-secrets-integrationImplements AWS Secrets Manager for secure secret storage, management, and automatic rotation of credentials using AWS SDK for Python (Boto3).
Independent GitHub snapshot · Automated classification · Original documentation governs
name: aws-secrets-integration description: Implements AWS Secrets Manager for secure secret storage, management, and automatic rotation of credentials using AWS SDK for Python (Boto3). license: MIT compatibility: opencode metadata: version: "1.1.1" domain: coding triggers: aws secrets manager, boto3, secret management, automatic rotation, credential management archetypes: [implementation, secret management] anti_triggers: [hardcoded secrets] response_profile: verbosity: medium directive_strength: high abstraction_level: operational role: implementation scope: infrastructure output-format: code
AWS Secrets Manager is designed to help you protect access to your applications, services, and IT resources without the upfront investment and on-going maintenance costs of operating your own infrastructure. It enables easy and secure management of sensitive information such as API keys, passwords, and other credentials.
import boto3
# Create a new Secret
client = boto3.client('secretsmanager')
response = client.create_secret(
Name='MyDatabaseSecret',
SecretString='{"username":"admin", "password":"Password123"}'
)
# Retrieve a Secret
get_secret_value_response = client.get_secret_value(SecretId='MyDatabaseSecret')
print(get_secret_value_response['SecretString'])
import boto3
import json
from botocore.exceptions import ClientError
def enable_rotation(secret_arn: str, rotation_lambda_arn: str) -> None:
"""Enable automatic rotation for a secret using a Lambda function."""
client = boto3.client("secretsmanager", region_name="us-east-1")
try:
response = client.rotate_secret(
SecretId=secret_arn,
RotationLambdaARN=rotation_lambda_arn,
RotationRules={
"AutomaticallyAfterDays": 30
}
)
print(f"Rotation scheduled. Next rotation: {response['NextRotationDate']}")
except ClientError as e:
if e.response["Error"]["Code"] == "ResourceNotFoundException":
raise ValueError(f"Secret not found: {secret_arn}") from e
raise
def get_rotated_secret(secret_id: str) -> dict:
"""Retrieve and parse a secret with error handling."""
client = boto3.client("secretsmanager", region_name="us-east-1")
try:
response = client.get_secret_value(SecretId=secret_id)
return json.loads(response["SecretString"])
except ClientError as e:
error_code = e.response["Error"]["Code"]
if error_code == "AccessDeniedException":
raise PermissionError(
f"Insufficient IAM permissions to access secret '{secret_id}'"
) from e
elif error_code == "ResourceNotFoundException":
raise FileNotFoundError(f"Secret not found: {secret_id}") from e
raise
By adopting best practices and prioritizing security, AWS Secrets Manager plays a crucial role in maintaining the integrity and confidentiality of sensitive information across your applications and services.
Authoritative documentation links for this skill's domain. The model follows markdown links to resolve external references and inline content.