s3_operarion.py script lets you create a new bucket, upload file into a bucket, reverse the file content using lambda function, list all bucket, empty, and delete the bucket.
- This script can run on a local machine that takes a name parameter and a text parameter.
- In whatever account the AWS-CLI has access to on the machine, create command lets you create (if it does not already exist or use the already existing) S3 bucket based on the name parameter. By using the upload command, you can upload a txt file with a random name inside the S3 bucket with the text parameter's contents.
- The script should then check the txt file every second, and once the Lambda function has changed the contents of the file, the script can then display the updated reversed contents of the file (as written by the Lambda function) and exit.
Create lambda function called 's3-trigger' and paste 'lambda_function.py' code into it.
All the required steps for installation are executed using below command.
pip install -r requirements.txt
Below are the commands mentioned to do various tasks as per requirements.
python s3_operations.py create --name sanket123
First add this bucket's trigger into s3-trigger lambda function. Select 'PUT' as event type while doing it.It checks random name file every second and return the reverse string.
python s3_operations.py upload --name sanket123 --text hello
python s3_operations.py list
python s3_operations.py empty --name sanket123
python s3_operations.py delete --name sanket123
python test.py
If any error has occurred, please let me know by opening issue.