Skip to content

Instantly share code, notes, and snippets.

@juanpablocs
Last active June 22, 2024 01:35
Show Gist options
  • Save juanpablocs/db8cd03863edb4431dad94379176cbe3 to your computer and use it in GitHub Desktop.
Save juanpablocs/db8cd03863edb4431dad94379176cbe3 to your computer and use it in GitHub Desktop.
S3CMD commands

Commands utils s3cmd

Upload files to bucket

s3cmd sync [FOLDER]/* s3://[BUCKET] --no-progress --no-progress --acl-public --recursive

Update cors to bucket

s3cmd setcors ./cors_rule.xml s3://[BUCKET]

cors_rule.xml

<CORSConfiguration>
  <CORSRule>
    <ID>Allow Todo</ID>
    <AllowedOrigin>*</AllowedOrigin>
    <AllowedMethod>GET</AllowedMethod>
    <AllowedMethod>HEAD</AllowedMethod>
    <AllowedHeader>*</AllowedHeader>
    <ExposeHeader>ETag</ExposeHeader>
    <MaxAgeSeconds>86400</MaxAgeSeconds>
  </CORSRule>
</CORSConfiguration>

Info bucket

s3cmd info s3://[BUCKET]

Delete objetcs

s3cmd del --recursive s3://[BUCKET] --force

Config s3cmd for another endpoint

file in root user ~/.s3cfg

[default]
access_key = $S3_ACCESS_KEY_ID
bucket_location = $S3_REGION
host_base = $S3_ENDPOINT
host_bucket = $S3_BUCKET.$S3_ENDPOINT
secret_key = $S3_ACCESS_KEY_SECRET
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment