I have three txt files in s3 bucket nearly 5GB I want to remove last line from all the three files and save as it is I want to do this using lambda function using boto3

0 votes
I have three .txt files in s3 bucket (nearly 5GB), I want to remove the last line from all the three files and save as it is, I want to do this using lambda function using boto3, I am not able to do this, Please help.
Jun 8, 2020 in AWS by Shubh
• 150 points
1,706 views

1 answer to this question.

0 votes

Hi@Shubh,

According to my knowledge,  you can't edit s3 files directly in s3. But you can sync your bucket locally and upload your changes to the s3 bucket.

  • First, sync your file from the s3 bucket to your local system.
C:\Users\NADIM AKTHAR\Desktop\New folder>aws s3 sync s3://bucketnadim bucket.txt
download: s3://bucketnadim/bucket.txt to bucket.txt\bucket.txt
download: s3://bucketnadim/123.jpg to bucket.txt\123.jpg
  • Then modify your file and upload it to the s3 bucket.
C:\Users\NADIM AKTHAR\Desktop\New folder>aws s3 sync bucket.txt s3://bucketnadim
upload: bucket.txt\bucket.txt to s3://bucketnadim/bucket.txt
answered Jun 8, 2020 by MD
• 95,460 points

Related Questions In AWS

0 votes
1 answer
0 votes
1 answer

how to access AWS S3 from Lambda in VPC

With boto3, the S3 urls are virtual by default, ...READ MORE

answered Sep 28, 2018 in AWS by Priyaj
• 58,020 points
10,121 views
0 votes
1 answer

Import my AWS credentials using python script

Using AWS Cli  Configure your IAM user then ...READ MORE

answered Nov 16, 2018 in AWS by Jino
• 5,820 points
2,868 views
0 votes
2 answers
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP