user6754021
user6754021

Reputation: 129

How can I do aws s3 cp only if a folder does not exist, throw error otherwise as a part of my jenkins job?

If there is a way to check if given a path/folder/file exists within S3 using the aws s3 CLI?

Upvotes: 0

Views: 1272

Answers (1)

Piyush Patil
Piyush Patil

Reputation: 14543

Always remember S3 is a flat file system. There are no folders. There are simply filenames with slashes in them.

A work around you can use is upload a simple txt file in every S3 folders and use Get object on then to verify if that path exits. Some thing like this.

f($s3->getObjectInfo("bucketName","folder_name/donotdelete.txt")))
    { 
        //Do Whatever you want to do if folder exists
    }
    else
    {
        //Do whatever you want to do if folder doesn't exist
    }

Upvotes: 1

Related Questions