Skip to content

Instantly share code, notes, and snippets.

@dyno
Created May 27, 2021 17:47
Show Gist options
  • Save dyno/2ecc84856e1887127e3d17ef7cdc0b17 to your computer and use it in GitHub Desktop.
Save dyno/2ecc84856e1887127e3d17ef7cdc0b17 to your computer and use it in GitHub Desktop.
aws s3 touch
#!/usr/bin/env bash
# https://stackoverflow.com/questions/13455168/is-there-a-way-to-touch-a-file-in-amazon-s3
aws_s3_touch() {
python3 -c 'from urllib.parse import urlparse; u=urlparse("'$1'"); print(f"{u.netloc} {u.path[1:]}")' | while read bucket key;
do
aws s3api put-object --bucket $bucket --key $key
done
}
aws_s3_touch s3://mybucket/path/to/file.success
@dyno
Copy link
Author

dyno commented May 27, 2021

#!/usr/bin/env bash

# for existing file, real touch

aws_s3_touch() {
   aws s3 cp --metadata '{"touched":"now"}' $1 $1
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment