Say I have a website that return me JSON data when I send a GET request using curl. I want to re-direct the output of curl to AWS S3. A new file should be created on S3 for it.
Currently I am able to redirect the output to store it locally.
curl -s -X GET 'http://website_that_returns_json.com' > folder_to_save/$(date +"%Y-%m-%d_%H-%M.json")
I have AWS CLI
and s3cmd
installed. How would I redirect the output of create to create a new file on AWS S3 ?
Assume :
- AWS S3 access key and secret key are already set.
- Location to store file :
mybucket/$(date +"%Y-%m-%d_%H-%M.json"
The AWS Command-Line Interface (CLI) has the ability to stream data to/from Amazon S3:
So, you could use:
However, it's probably safer to save the file locally and then copy it to Amazon S3.
In case you'd like to run the command on the remote, use
aws ssm send-command
.Then to redirect the output of that command to S3, you can use
--output-s3-bucket-name
parameter.Here is Bash script to run PowerShell script on the remote and upload it into S3 bucket:
To output the uploaded S3 files, run: