Synchronising a single file with AWS
It's easy to copy a single file to aws using:
aws s3 cp ...
But this will copy the file regardless of whether or not it has changed.
It's also easy to synchronise a directory of files to aws using:
aws s3 sync ...
But this only synchronises a directory.
I've got a lambda function I need to synchronise and it's packaged, as recommended by AWS, as a zip. I want to synchronise this file because it's large and anything else, i.e. copying it every time, would be stupid. But I don't want it to live in it's own directory on S3: it doesn't need to, it's just a zip. And there are files I want to be adjecent to the zip that I definitely don't want to synchronise. They look like this:
bucket/ ├── lambdas/ │ ├── lambda_function.zip │ └── some_other_file.csv
Well you can still use sync, but you just need to add a few params. First, you want to exclude everything with:
And then you want to include your specific file:
aws s3 sync ./build_dir s3://bucket \ --exclude "*" \ --include "lambda_function.zip"
This lets you get specific about what files you want, and gives you the benefits of sync. And the syntax isn't too verbose.