Posts

Showing posts with the label Amazon

Amazon Linux AMI Vs Ubuntu

Answer : Amazon Linux AMI is a red hat based distro so things like the package installer or the tools for service manage are different, and another thing you need to consider is the way of bootstraping, amazon instances are more flexible to do some things in cloudformation in the ubuntu way the best form to do it is with cloudinit https://help.ubuntu.com/community/CloudInit, you need to consider the packages too are multiple packages that not are native supported by Amazon Linux.

Check If File Exists In S3 Bucket

Answer : If you do aws s3 ls on the actual filename. If the filename exists, the exit code will be 0 and the filename will be displayed, otherwise, the exit code will not be 0: aws s3 ls s3://bucket/filname if [[ $? -ne 0 ]]; then echo "File does not exist" fi first answer is close but in cases where you use -e in shebang, the script will fail which you would most like not want. It is better to use wordcount. So you can use the below command: wordcount=`aws s3 ls s3://${S3_BUCKET_NAME}/${folder}/|grep $${file}|wc -c` echo wordcount=${wordcount} if [[ "${wordcount}" -eq 0 ]]; then do something else do something fi Try the following : aws s3api head-object --bucket ${S3_BUCKET} --key ${S3_KEY} It retrieves the metadata of the object without retrieving the object itself. READ(s3:GetObject) access is required. .