AWS S3 Object deleting issue - amazon-web-services

The object of s3 is:
images/jkå^ååö¨..ö ÷aq<aa<2a<qa2.jpg
While I delete it from S3 management console it said 100% success but while I the object is still there.
I have tried command line and try to delete it from EC2 instance with the command and that does not work either
My command is:
aws s3 rm s3://sws-bucket/images/jkå^ååö¨..ö ÷aq<aa<2a<qa2.jpg
Which works for another object.
eg: aws s3 rm s3://sws-bucket/images/test.jpg
Working fine.
I really want to delete the object with the special character but can't succeed. Anyone can help with this?

Finally, I have found the solution:
While I was checking in the regional file the name was
'jkå^ååö¨..ö ÷aq
So when I ran the command
s3://sws-bucket/image/'jkå^ååö¨..ö ÷aq

Related

aws s3 sync --delete, does not remove directory manually created from console

aws s3 sync <> <> --delete works fine but I have a scenario wherein someone created directories using AWS console and put in some files inside those directories using manual upload. So now when I run the sync command, those files get removed but the manually created directories still persist.
Is this an expected behavior of the command?
This issue is tracked here - https://github.com/aws/aws-cli/issues/2685 . This is a known bug and no direct solution is available yet so we need to create wayarounds according to our condition.

AWS S3 Deleting file while someone is downloading that object

I cant seem to find how does AWS s3 handles, if someone deletes file while other person is downloading it.
Does it behave like unix system, where descriptor is opened and file is downloaded without problems or does it behave in other way?
Thanks for help!
S3 offers eventual consistency for DELETES.
From the S3 Data Consistency Model
A process deletes an existing object and immediately tries to read it.
Until the deletion is fully propagated, Amazon S3 might return the
deleted data.
Here, where the deletion and downloading of the same object is done concurrently, even if the deletion of the object succeeds before the download is complete, the process will still be able to download the data.
You will face a race condition, of sorts, so the outcome is unpredictable. When you download a file from S3, you might be connected to multiple S3 servers. If at any time, you request part of an S3 object and the server you are connected to thinks the object has been deleted then your download will fail.
Here's a simple test: store a 2GB flle in S3, then download it. While it it is downloading, go into the S3 console and delete the object. You will find that your download fails (with NoSuchKey) because the specified key no longer exists.
Create a temporary 2GB file and upload it to S3:
mkfile -n 2g 2gb.dat
$ aws s3 cp 2gb.dat s3://mybucket
upload: ./2gb.dat to s3://mybucket/2gb.dat
Once complete, start downloading the file:
$ aws s3 cp s3://mybucket/2gb.dat fred.dat
Completed 162.2 MiB/2.0 GiB (46.9 MiB/s) with 1 file(s) remaining
Then jump over to the S3 console and delete 2gb.dat, and this will happen:
$ aws s3 cp s3://mybucket/2gb.dat fred.dat
download failed: s3://mybucket/2gb.dat to ./fred.dat An error occurred
(NoSuchKey) when calling the GetObject operation: The specified key does not exist.

AWS CLI S3 rm command does not produce error if file does not exist

I have a bash script which iterates over an array of file names and removes them from S3.
The following command:
aws s3 rm "s3://myBucket/myFolder/myFile.txt"
will produce this output.
delete: s3://myBucket/myFolder/myFile.txt
I can see that the delete was successful by verifying it has been removed in the AWS console.
However if I iterate over the same list again, I get the same output even though the file is gone.
Is there any way -- using just the rm command -- of indicating that AWS CLI tried to delete the file but could not find it?
The s3 cli rm command uses the s3 API Delete Object operation
As you can see in the documentation, this adds a "delete marker" to the object. In a sense, it is "labelled" as deleted.
There doesn't seem to be any check before these markers are made that the underlying object actually exists
As the S3 storage is distributed, consistency isn't guaranteed under all circumstances.
What this means is that if you were to carry out some operations on a file and then check it, the answer wouldn't be certain
In the case of S3 the AWS docs say
Amazon S3 offers eventual consistency for overwrite PUTS and DELETES in all regions.
"eventual consistency" means that at some undefined point in the future all the distributed nodes will catch up with the changes and the results returned from a query will be as expected, given the changes you have done
So basically, this is a long-winded way of saying: No, you can't get a confirmation that the file is deleted. Checking to see if it exists afterwards will not work reliably

How to clean up S3 files that is used by AWS Firehose after loading the files?

AWS Firehose uses S3 as an intermittent storage before the data is copied to redshift. Once the data is transferred to redshift, how to clean them up automatically if it succeeds.
I deleted those files manually, it went out of state complaining that files got deleted, I had to delete and recreate Firehose again to resume.
Deleting those files after 7 days with S3 rules will work? or Is there any automated way, that Firehose can delete the successful files that got moved to redshift.
Discussing with Support AWS,
Confirmed it is safe to delete those intermediate files after 24 hour period or to the max retry time.
A Lifecycle rule with an automatic deletion on S3 Bucket should fix the issue.
Hope it helps.
Once you're done loading your destination table, execute something similar to (the below snippet is typical to a shell script):
aws s3 ls $aws_bucket/$table_name.txt.gz
if [ "$?" = "0" ]
then
aws s3 rm $aws_bucket/$table_name.txt.gz
fi
This'll check whether the table you've just loaded exists on s3 or not and will drop it. Execute it as a part of a cronjob.
If your ETL/ELT is not recursive, you can write this snippet towards the end of the script. It'll delete the file on s3 after populating your table. However, before execution of this part, make sure that your target table has been populated.
If you ETL/ELT is recursive, you may put this somewhere at the beginning of the script to check and remove the files created in the previous run. This'll retain the files created till the next run and should be preferred as the file will act as a backup in case the last load fails (or you need a flat file of the last load for any other purpose).

Sync command for OpenStack Object Storage (like S3 Sync)?

Using the S3 CLI, I can sync a local directory with an S3 bucket using the following command:
aws s3 sync s3://mybucket/ ./local_dir/
This command is a complete sync. It uploads new files, updates changed files, and deletes removed files. I am trying to figure out how to do something equivalent using the OpenStack Object Storage CLI:
http://docs.openstack.org/cli-reference/content/swiftclient_commands.html
The upload command has a --changed option. But I need a complete sync that is also capable of deleting local files that were removed.
Does anyone know if I can do something equivalent to s3 sync?
The link you mentioned has this :
`
objects –
A list of file/directory names (strings) or SwiftUploadObject instances containing a source for the created object, an object name, and an options dict (can be None) to override the options for that individual upload operation`
I'm thinking, if you pass the directory and the --changed option it should work.
I don't have a swift to test with. Can you try again?