Skip to content

Instantly share code, notes, and snippets.

@huyanhvn
Last active March 11, 2016 14:49
Show Gist options
  • Save huyanhvn/e605d74c492560e9f940 to your computer and use it in GitHub Desktop.
Save huyanhvn/e605d74c492560e9f940 to your computer and use it in GitHub Desktop.
aws-s3
### SIZE OF S3 BUCKET
aws s3api list-objects --bucket BUCKETNAME --output json --query "[sum(Contents[].Size), length(Contents[])]”
### BUCKET POLICY FOR ENCRYPTED BUCKET
{
"Version": "2012-10-17",
"Id": "PutObjPolicy",
"Statement": [
{
"Sid": "DenyUnEncryptedObjectUploads",
"Effect": "Deny",
"Principal": "*",
"Action": "s3:PutObject",
"Resource": "arn:aws:s3:::<bucket>/*",
"Condition": {
"StringNotEquals": {
"s3:x-amz-server-side-encryption": "aws:kms"
}
}
},
{
"Sid": "Stmt1451939383926",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:ListBucket",
"Resource": "arn:aws:s3:::<bucket>",
"Condition": {
"StringEquals": {
"aws:username": "<role-account>"
}
}
},
{
"Sid": "Stmt1451939438665",
"Effect": "Allow",
"Principal": "*",
"Action": [
"s3:GetObject",
"s3:PutObject"
],
"Resource": "arn:aws:s3:::<bucket>/*",
"Condition": {
"StringEquals": {
"aws:username": "<role-account>"
}
}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment