amazon web services - Copy files from AWS S3 Bucket only if the bucket exists -


i trying create single command through aws cli, check if provided bucket exists , if there files present inside bucket, copy files in local machine.

so requirement is: there s3 bucket 'ecs-ref-arch' , bucket contains folder called 'jars'. if /ecs-ref-arch/jars present , there files inside directory, want copy files jars directory local machine.

can done in single aws cli command?

can done in single aws cli command ?

first, sounds lot 'do job me', did not show lot of research side, although might have searched, not clear struggle.

on single command not sure, big fan of xargs , on, think need @ least 2 commands. aws provides methods check existence of bucket (aws s3api head-bucket --bucket <bucket_name>) not convenient search folder

so best check in script , run commands there, such script written as

#!/bin/bash  cmd="aws s3 ls s3://<bucket-name>"  if eval "$cmd" | grep -q 'pre jars/';   # jars folder found, can copy files locally   aws s3 sync s3://<bucket-name>/jars . fi 

Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -