'Why aws s3 sync <source> <target> --delete doesn't delete folder that is in the target folder and not on the source folder

Please I would like to know:

Why aws s3 sync --delete doesn't delete folder that is in the target folder and not on the source folder?

Here an example:

I use the following command on the aws cli to sync the 2 buckets:

aws s3 sync \
    "s3://sourcebucket-us-east-1/test_copy_data/" \
    "s3://targetbucket-us-east-1/test_copy_data/" \
    --delete

In the s3://targetbucket-us-east-1/test_copy_data/ folder there is a file s3://targetbucket-us-east-1/test_copy_data/folder1/file1.txt that doesn't exist in the source folder s3://sourcebucket-us-east-1/test_copy_data/.

When I launch the command, s3://targetbucket-us-east-1/test_copy_data/folder1/file1.txt are deleted but s3://targetbucket-us-east-1/test_copy_data/folder1/` is still there and empty

Thank you



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source