AWS S3 Skills
Advanced patterns for Amazon Simple Storage Service (S3) utilization.
🚀 Core Commands
Bucket Management
CODEBLOCK0
High-Speed Synchronization
CODEBLOCK1
Content Discovery & Filtering
CODEBLOCK2
🧠 Best Practices
- 1. Least Privilege: Always use IAM policies that restrict access to specific buckets/prefixes.
- Versioning: Enable versioning for critical production data to prevent accidental deletions.
- Encrypted at Rest: Enforce SSE-S3 or SSE-KMS for all sensitive objects.
- Lifecycle Policies: Automate transition to S3 Glacier for aging assets to optimize cost.
AWS S3 技能
Amazon Simple Storage Service (S3) 的高级使用模式。
🚀 核心命令
存储桶管理
bash
列出所有存储桶及其创建日期
aws s3api list-buckets --query Buckets[].{Name:Name,Created:CreationDate} --output table
在指定区域创建存储桶
aws s3 mb s3://<存储桶名称> --region <区域>
高速同步
bash
智能同步(仅同步已更改的文件)
aws s3 sync ./本地目录 s3://<存储桶名称>/路径 --delete --exclude *.tmp
并发上传调优(性能优化)
aws configure set default.s3.max
concurrentrequests 20
内容发现与过滤
bash
查找大于100MB的对象
aws s3api list-objects-v2 --bucket <存储桶名称> --query Contents[?Size > \104857600\].[Key, Size] --output json
计算指定前缀的总大小
aws s3 ls s3://<存储桶名称>/前缀 --recursive --human-readable --summarize | tail -n 2
🧠 最佳实践
- 1. 最小权限原则:始终使用IAM策略限制对特定存储桶/前缀的访问。
- 版本控制:对关键生产数据启用版本控制,防止意外删除。
- 静态加密:对所有敏感对象强制使用SSE-S3或SSE-KMS加密。
- 生命周期策略:自动将老化资产过渡到S3 Glacier,优化存储成本。