Durante el inicio de unas pruebas post-autenticadas, es ideal ejecutar los siguientes comandos para recopilar información sobre la infraestructura relacionada al servicio de S3.
Comandos útiles
Listar todos los Buckets de la cuenta
awss3ls
Listado de objetos de un Bucket específico
awss3lss3://bucket-name
Enumera Todos los objetos de un Bucket incluyendo contenido de las carpetas existentes.
# Get buckets ACLsawss3apiget-bucket-acl--bucket<bucket-name>awss3apiget-object-acl--bucket<bucket-name>--keyflag# Get policyawss3apiget-bucket-policy--bucket<bucket-name>awss3apiget-bucket-policy-status--bucket<bucket-name>#if it's public# list S3 buckets associated with a profileawss3lsawss3apilist-buckets# list content of bucket (no creds)awss3lss3://bucket-name--no-sign-requestawss3lss3://bucket-name--recursive# list content of bucket (with creds)awss3lss3://bucket-nameawss3apilist-objects-v2--bucket<bucket-name>awss3apilist-objects--bucket<bucket-name>awss3apilist-object-versions--bucket<bucket-name># copy local folder to S3awss3cpMyFolders3://bucket-name--recursive# deleteawss3rbs3://bucket-name–-force# download a whole S3 bucketawss3syncs3://<bucket>/.# move S3 bucket to different locationawss3syncs3://oldbuckets3://newbucket--source-regionus-west-1# list the sizes of an S3 bucket and its contentsawss3apilist-objects--bucketBUCKETNAME--outputjson--query"[sum(Contents[].Size), length(Contents[])]"# Update Bucket policyawss3apiput-bucket-policy--policyfile:///root/policy.json--bucket<bucket-name>##JSON policy example{"Id":"Policy1568185116930","Version":"2012-10-17","Statement": [ {"Sid":"Stmt1568184932403","Action": ["s3:ListBucket" ],"Effect":"Allow","Resource":"arn:aws:s3:::welcome","Principal":"*" }, {"Sid":"Stmt1568185007451","Action": ["s3:GetObject" ],"Effect":"Allow","Resource":"arn:aws:s3:::welcome/*","Principal":"*" } ]}# Update bucket ACLawss3apiget-bucket-acl--bucket<bucket-name># Way 1 to get the ACLawss3apiput-bucket-acl--bucket<bucket-name>--access-control-policyfile://acl.jsonawss3apiget-object-acl--bucket<bucekt-name>--keyflag#Way 2 to get the ACLawss3apiput-object-acl--bucket<bucket-name>--keyflag--access-control-policyfile://objacl.json##JSON ACL example## Make sure to modify the Owner’s displayName and ID according to the Object ACL you retrieved.{"Owner":{"DisplayName":"<DisplayName>","ID":"<ID>" },"Grants": [ {"Grantee":{"Type":"Group","URI":"http://acs.amazonaws.com/groups/global/AuthenticatedUsers" },"Permission":"FULL_CONTROL" } ]}## An ACL should give you the permission WRITE_ACP to be able to put a new ACL