技能创建器
skill-creator
创建、改进和评估自定义技能,把专业流程转化为可重复使用的 AI 能力。
aws-s3【数据与研究】"Configures S3 object storage with versioning, lifecycle policies, encryption" and access controls for durable, scalable data storage with cost optimization in AWS.
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
name: aws-s3 compatibility: opencode completeness: 95 content-types:
Configure durable, scalable object storage with versioning, lifecycle management, and encryption. S3 provides unlimited, cost-effective storage for any data type with sophisticated access controls.
Use S3 when:
Avoid S3 when:
Primary Purpose: Provide infinitely scalable, durable object storage with automatic data protection, lifecycle management, and sophisticated access controls.
Common Use Cases:
AWSTemplateFormatVersion: '2010-09-09'
Resources:
DataBucket:
Type: AWS::S3::Bucket
Properties:
BucketName: my-data-bucket-unique-name
VersioningConfiguration:
Status: Enabled
LifecycleConfiguration:
Rules:
# Transition to Intelligent-Tiering after 30 days
- Id: TransitionToIntelligentTiering
Status: Enabled
Transitions:
- TransitionInDays: 30
StorageClass: INTELLIGENT_TIERING
# Transition to Glacier after 90 days
- Id: TransitionToGlacier
Status: Enabled
Transitions:
- TransitionInDays: 90
StorageClass: GLACIER
# Expire (delete) after 365 days
- Id: ExpireOldVersions
Status: Enabled
ExpirationInDays: 365
NoncurrentVersionExpirationInDays: 90
# Delete incomplete multipart uploads after 7 days
- Id: CleanupIncompleteUploads
Status: Enabled
AbortIncompleteMultipartUpload:
DaysAfterInitiation: 7
PublicAccessBlockConfiguration:
BlockPublicAcls: true
BlockPublicPolicy: true
IgnorePublicAcls: true
RestrictPublicBuckets: true
BucketEncryption:
ServerSideEncryptionConfiguration:
- ServerSideEncryptionByDefault:
SSEAlgorithm: AES256
BucketKeyEnabled: true
LoggingConfiguration:
DestinationBucketName: !Ref LogBucket
LogFilePrefix: data-bucket-logs/
Tags:
- Key: Environment
Value: production
- Key: DataClassification
Value: sensitive
LogBucket:
Type: AWS::S3::Bucket
Properties:
BucketName: my-data-bucket-logs-unique-name
AccessControl: LogDeliveryWrite
PublicAccessBlockConfiguration:
BlockPublicAcls: true
BlockPublicPolicy: true
IgnorePublicAcls: true
RestrictPublicBuckets: true
DataBucketPolicy:
Type: AWS::S3::BucketPolicy
Properties:
Bucket: !Ref DataBucket
PolicyText:
Version: '2012-10-17'
Statement:
# Deny unencrypted uploads
- Sid: DenyUnencryptedObjectUploads
Effect: Deny
Principal: '*'
Action: s3:PutObject
Resource: !Sub '${DataBucket.Arn}/*'
Condition:
StringNotEquals:
s3:x-amz-server-side-encryption: AES256
# Deny insecure transport
- Sid: DenyInsecureTransport
Effect: Deny
Principal: '*'
Action: s3:*
Resource:
- !GetAtt DataBucket.Arn
- !Sub '${DataBucket.Arn}/*'
Condition:
Bool:
aws:SecureTransport: 'false'
# Allow specific IAM role to access
- Sid: AllowApplicationAccess
Effect: Allow
Principal:
AWS: arn:aws:iam::123456789012:role/ApplicationRole
Action:
- s3:GetObject
- s3:PutObject
- s3:DeleteObject
Resource: !Sub '${DataBucket.Arn}/*'
BucketNotification:
Type: AWS::S3::Bucket
Properties:
NotificationConfiguration:
LambdaConfigurations:
- Event: s3:ObjectCreated:*
Function: arn:aws:lambda:us-east-1:123456789012:function/ProcessS3Upload
Filter:
Key:
FilterRules:
- Name: prefix
Value: uploads/
- Name: suffix
Value: .jpg
Key Elements:
Resources:
WebsiteBucket:
Type: AWS::S3::Bucket
Properties:
BucketName: my-website-bucket-unique-name
WebsiteConfiguration:
IndexDocument: index.html
ErrorDocument: 404.html
PublicAccessBlockConfiguration:
BlockPublicAcls: false
BlockPublicPolicy: false
IgnorePublicAcls: false
RestrictPublicBuckets: false
WebsiteBucketPolicy:
Type: AWS::S3::BucketPolicy
Properties:
Bucket: !Ref WebsiteBucket
PolicyText:
Version: '2012-10-17'
Statement:
- Sid: PublicReadGetObject
Effect: Allow
Principal: '*'
Action: s3:GetObject
Resource: !Sub '${WebsiteBucket.Arn}/*'
CloudFrontDistribution:
Type: AWS::CloudFront::Distribution
Properties:
DistributionConfig:
Enabled: true
DefaultRootObject: index.html
Origins:
- Id: S3Origin
DomainName: !GetAtt WebsiteBucket.RegionalDomainName
S3OriginConfig:
OriginAccessIdentity: !Sub 'origin-access-identity/cloudfront/${CloudFrontOAI}'
DefaultCacheBehavior:
AllowedMethods:
- GET
- HEAD
CachedMethods:
- GET
- HEAD
TargetOriginId: S3Origin
ViewerProtocolPolicy: redirect-to-https
ForwardedValues:
QueryString: false
Cookies:
Forward: none
Compress: true
DefaultTTL: 86400
MaxTTL: 31536000
HttpVersion: http2and3
CloudFrontOAI:
Type: AWS::CloudFront::CloudFrontOriginAccessIdentity
Properties:
CloudFrontOriginAccessIdentityConfig:
Comment: OAI for S3 website bucket
Key Elements:
Resources:
PrimaryBucket:
Type: AWS::S3::Bucket
Properties:
BucketName: my-primary-bucket-unique-name
VersioningConfiguration:
Status: Enabled
ReplicationConfiguration:
Role: !GetAtt ReplicationRole.Arn
Rules:
- Id: ReplicateAll
Status: Enabled
Priority: 1
DeleteMarkerReplication:
Status: Enabled
Filter:
Prefix: ''
Destination:
Bucket: !GetAtt ReplicaBucket.Arn
ReplicationTime:
Status: Enabled
Time:
Minutes: 15
Metrics:
Status: Enabled
EventThreshold:
Minutes: 15
StorageClass: STANDARD_IA
ReplicaBucket:
Type: AWS::S3::Bucket
Properties:
BucketName: my-replica-bucket-unique-name
VersioningConfiguration:
Status: Enabled
ObjectLockEnabled: true
ObjectLockConfiguration:
ObjectLockEnabled: Enabled
Rule:
DefaultRetention:
Mode: GOVERNANCE
Years: 7
ReplicationRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Principal:
Service: s3.amazonaws.com
Action: sts:AssumeRole
Policies:
- PolicyName: S3Replication
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- s3:GetReplicationConfiguration
- s3:ListBucket
Resource: !GetAtt PrimaryBucket.Arn
- Effect: Allow
Action:
- s3:GetObjectVersionForReplication
- s3:GetObjectVersionAcl
Resource: !Sub '${PrimaryBucket.Arn}/*'
- Effect: Allow
Action:
- s3:ReplicateObject
- s3:ReplicateDelete
Resource: !Sub '${ReplicaBucket.Arn}/*'
Key Elements:
S3 + CloudFront provides:
S3 events trigger Lambda functions for:
Query S3 data directly via SQL:
Enable CloudTrail for S3 API auditing:
Fine-grained access control:
Problem: Accidental deletions or overwrites are permanent; no rollback possible.
Solution:
Problem: All data stored in S3 Standard costs $0.023/GB/month; old data accumulates.
Solution:
Problem: Bucket misconfiguration exposes credentials, keys, or PII.
Solution:
Problem: Data at rest is unencrypted; fails compliance requirements.
Solution:
Problem: Unauthorized access goes undetected; compliance violations.
Solution:
Problem: Regional outage loses all data; no disaster recovery.
Solution:
| Category | Best Practice |
|---|---|
| Durability | Enable versioning; replicate to secondary region |
| Cost | Use Intelligent-Tiering; expire old versions |
| Security | Block public access; enforce encrypted transport; use KMS |
| Compliance | Enable CloudTrail; use Object Lock; implement retention policies |
| Performance | Use CloudFront for distribution; S3 Transfer Acceleration for large uploads |
| Monitoring | Enable access logging; configure CloudWatch alarms |
| Skill | Purpose |
|---|---|
cncf-aws-cloudfront | Distribute S3 content globally |
cncf-aws-kms | Encrypt S3 objects with customer-managed keys |
cncf-aws-iam | Control S3 bucket and object access |
cncf-aws-cloudformation | Infrastructure as code for S3 resources |
cncf-aws-cloudwatch | Monitor S3 access and performance |
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.