技能创建器
skill-creator
创建、改进和评估自定义技能,把专业流程转化为可重复使用的 AI 能力。
aws-kms【数据与研究】"Manages encryption keys with AWS KMS for data protection at rest and" in transit, key rotation, and compliance with encryption standards across all AWS services.
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
name: aws-kms compatibility: opencode completeness: 95 content-types:
Manage encryption keys and control data encryption at rest and in transit with centralized key management, automatic rotation, and compliance controls.
Use KMS when:
Avoid KMS for:
Primary Purpose: Provide centralized, audited encryption key management with fine-grained access control and compliance capabilities.
Common Use Cases:
AWSTemplateFormatVersion: '2010-09-09'
Resources:
# Customer-Managed Key
DataEncryptionKey:
Type: AWS::KMS::Key
Properties:
Description: Customer-managed key for sensitive data encryption
EnableKeyRotation: true # Automatic annual rotation
KeyPolicy:
Version: '2012-10-17'
Statement:
# Enable IAM user permissions
- Sid: Enable IAM User Permissions
Effect: Allow
Principal:
AWS: !Sub 'arn:aws:iam::${AWS::AccountId}:root'
Action: 'kms:*'
Resource: '*'
# Allow services to use the key for encryption
- Sid: Allow AWS Services
Effect: Allow
Principal:
Service:
- s3.amazonaws.com
- rds.amazonaws.com
- dynamodb.amazonaws.com
- lambda.amazonaws.com
Action:
- 'kms:Decrypt'
- 'kms:GenerateDataKey'
- 'kms:CreateGrant'
Resource: '*'
# Allow specific IAM role to use the key
- Sid: Allow Application Role to Encrypt/Decrypt
Effect: Allow
Principal:
AWS: arn:aws:iam::123456789012:role/ApplicationRole
Action:
- 'kms:Decrypt'
- 'kms:GenerateDataKey'
- 'kms:DescribeKey'
Resource: '*'
# Allow key administrators
- Sid: Allow Key Administrators
Effect: Allow
Principal:
AWS: arn:aws:iam::123456789012:role/AdminRole
Action:
- 'kms:Create*'
- 'kms:Describe*'
- 'kms:Enable*'
- 'kms:List*'
- 'kms:Put*'
- 'kms:Update*'
- 'kms:Revoke*'
- 'kms:Disable*'
- 'kms:Get*'
- 'kms:Delete*'
- 'kms:ScheduleKeyDeletion'
- 'kms:CancelKeyDeletion'
Resource: '*'
# Deny usage from root account (security best practice)
- Sid: Deny Unauthenticated Access
Effect: Deny
Principal: '*'
Action: 'kms:*'
Resource: '*'
Condition:
StringEquals:
aws:PrincipalType: 'Anonymous'
# Key Alias
DataEncryptionKeyAlias:
Type: AWS::KMS::Alias
Properties:
AliasName: alias/data-encryption-prod
TargetKeyId: !Ref DataEncryptionKey
# CloudWatch Alarm for Key Disable
KeyDisabledAlarm:
Type: AWS::CloudWatch::Alarm
Properties:
AlarmName: kms-key-disabled
MetricName: UserErrorCount
Namespace: AWS/KMS
Statistic: Sum
Period: 300
EvaluationPeriods: 1
Threshold: 1
ComparisonOperator: GreaterThanOrEqualToThreshold
Dimensions:
- Name: Key ID
Value: !Ref DataEncryptionKey
Outputs:
KeyId:
Value: !Ref DataEncryptionKey
Description: KMS Key ID
KeyArn:
Value: !GetAtt DataEncryptionKey.Arn
Description: KMS Key ARN
KeyAlias:
Value: !Ref DataEncryptionKeyAlias
Description: KMS Key Alias
Key Elements:
Resources:
# S3 Encryption Key
S3EncryptionKey:
Type: AWS::KMS::Key
Properties:
Description: Key for S3 bucket encryption
EnableKeyRotation: true
KeyPolicy:
Version: '2012-10-17'
Statement:
- Sid: Enable IAM User Permissions
Effect: Allow
Principal:
AWS: !Sub 'arn:aws:iam::${AWS::AccountId}:root'
Action: 'kms:*'
Resource: '*'
- Sid: Allow S3 to Use Key
Effect: Allow
Principal:
Service: s3.amazonaws.com
Action:
- 'kms:Decrypt'
- 'kms:GenerateDataKey'
Resource: '*'
# RDS Encryption Key
RDSEncryptionKey:
Type: AWS::KMS::Key
Properties:
Description: Key for RDS database encryption
EnableKeyRotation: true
KeyPolicy:
Version: '2012-10-17'
Statement:
- Sid: Enable IAM User Permissions
Effect: Allow
Principal:
AWS: !Sub 'arn:aws:iam::${AWS::AccountId}:root'
Action: 'kms:*'
Resource: '*'
- Sid: Allow RDS to Use Key
Effect: Allow
Principal:
Service: rds.amazonaws.com
Action:
- 'kms:Decrypt'
- 'kms:GenerateDataKey'
- 'kms:CreateGrant'
Resource: '*'
# DynamoDB Encryption Key
DynamoDBEncryptionKey:
Type: AWS::KMS::Key
Properties:
Description: Key for DynamoDB table encryption
EnableKeyRotation: true
KeyPolicy:
Version: '2012-10-17'
Statement:
- Sid: Enable IAM User Permissions
Effect: Allow
Principal:
AWS: !Sub 'arn:aws:iam::${AWS::AccountId}:root'
Action: 'kms:*'
Resource: '*'
- Sid: Allow DynamoDB to Use Key
Effect: Allow
Principal:
Service: dynamodb.amazonaws.com
Action:
- 'kms:Decrypt'
- 'kms:GenerateDataKey'
Resource: '*'
# Aliases
S3KeyAlias:
Type: AWS::KMS::Alias
Properties:
AliasName: alias/s3-encryption
TargetKeyId: !Ref S3EncryptionKey
RDSKeyAlias:
Type: AWS::KMS::Alias
Properties:
AliasName: alias/rds-encryption
TargetKeyId: !Ref RDSEncryptionKey
DynamoDBKeyAlias:
Type: AWS::KMS::Alias
Properties:
AliasName: alias/dynamodb-encryption
TargetKeyId: !Ref DynamoDBEncryptionKey
Key Elements:
Resources:
# Lambda Function Role
LambdaExecutionRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Principal:
Service: lambda.amazonaws.com
Action: sts:AssumeRole
# Grant for Lambda to decrypt
LambdaDecryptGrant:
Type: AWS::KMS::Grant
Properties:
KeyId: !Ref DataEncryptionKey
GranteePrincipal: !GetAtt LambdaExecutionRole.Arn
Operations:
- Decrypt
- GenerateDataKey
- DescribeKey
Constraints:
EncryptionContextSubset:
Department: Finance # Only decrypt Finance department data
# EC2 Instance Role
EC2InstanceRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Principal:
Service: ec2.amazonaws.com
Action: sts:AssumeRole
# Grant for EC2 to decrypt
EC2DecryptGrant:
Type: AWS::KMS::Grant
Properties:
KeyId: !Ref DataEncryptionKey
GranteePrincipal: !GetAtt EC2InstanceRole.Arn
Operations:
- Decrypt
Constraints:
EncryptionContextEquals:
DataType: CustomerData # Only decrypt customer data
Key Elements:
S3 + KMS enables:
RDS + KMS enables:
Secrets Manager + KMS provides:
CloudTrail + KMS enables:
Problem: Cannot control who can decrypt; cannot audit usage patterns.
Solution:
Problem: Too many principals can decrypt sensitive data.
Solution:
Problem: Compromised AWS account = compromised data.
Solution:
Problem: Compromised key remains in use indefinitely.
Solution:
Problem: Compromise of one service affects all data.
Solution:
Problem: Cannot detect suspicious decrypt patterns.
Solution:
| Category | Best Practice |
|---|---|
| Key Type | Customer-managed keys for sensitive data |
| Rotation | Enable automatic annual rotation |
| Policy | Least privilege; deny root account |
| Context | Use encryption context for constraints |
| Monitoring | CloudTrail logging; alert on anomalies |
| Multi-region | Multi-region keys for disaster recovery |
| Skill | Purpose |
|---|---|
cncf-aws-s3 | S3 encryption with KMS |
cncf-aws-rds | Database encryption with KMS |
cncf-aws-dynamodb | DynamoDB encryption with KMS |
cncf-aws-secrets-manager | Secret encryption with KMS |
Assess Requirements — Understand the use case, scale, integration needs, and existing infrastructure. Checkpoint: Document requirements, constraints, and success criteria.
Design Architecture — Plan component interactions, data flow, and deployment strategy using cloud-native best practices. Checkpoint: Verify the architecture addresses all requirements and follows CNCF conventions.
Implement & Configure — Create manifests, configurations, and deployment scripts. Include resource limits, health checks, and observability hooks. Checkpoint: Validate all YAML against schema and test in a staging environment.
Deploy & Monitor — Apply manifests to the cluster, verify component health, and confirm observability is working. Checkpoint: Confirm all pods/services are running, probes passing, and metrics/alerts configured.
Authoritative documentation links for this skill's domain. The model follows markdown links at load time to resolve external references and inline content.