Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: gen3_s3_info check for existing bucket #2637

Merged
merged 2 commits into from
Sep 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions gen3/bin/s3.sh
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ _add_bucket_to_cloudtrail() {
#
_bucket_exists() {
local bucketName=$1
if [[ -z "$(gen3_aws_run aws s3api head-bucket --bucket $bucketName 2>&1)" ]]; then
gen3_aws_run aws s3api head-bucket --bucket $bucketName > /dev/null 2>&1
if [[ $? -eq 0 ]]; then
echo 0
else
echo 1
Expand Down Expand Up @@ -173,10 +174,12 @@ gen3_s3_info() {
gen3_log_err "Unable to fetch AWS account ID."
return 1
fi
if [[ ! -z "$(gen3_aws_run aws s3api head-bucket --bucket $1 2>&1)" ]]; then

if [[ $(_bucket_exists $bucketName) -ne 0 ]]; then
gen3_log_err "Bucket does not exist"
return 1
fi

local rootPolicyArn="arn:aws:iam::${AWS_ACCOUNT_ID}:policy"
if gen3_aws_run aws iam get-policy --policy-arn ${rootPolicyArn}/${writerName} >/dev/null 2>&1; then
writerPolicy="{ \"name\": \"$writerName\", \"policy_arn\": \"${rootPolicyArn}/${writerName}\" } "
Expand Down
Loading