diff --git a/tests/commands/create_bucket.sh b/tests/commands/create_bucket.sh index 5fad8fc..2b57cec 100644 --- a/tests/commands/create_bucket.sh +++ b/tests/commands/create_bucket.sh @@ -26,13 +26,17 @@ create_bucket() { fi local exit_code=0 error + local location_args=() + if [ -n "$AWS_REGION" ] && [ "$AWS_REGION" != "us-east-1" ]; then + location_args=(--create-bucket-configuration LocationConstraint="$AWS_REGION") + fi if [[ $1 == 's3' ]]; then error=$(send_command aws --no-verify-ssl s3 mb s3://"$2" 2>&1) || exit_code=$? elif [[ $1 == 's3api' ]]; then - error=$(send_command aws --no-verify-ssl s3api create-bucket --bucket "$2" 2>&1) || exit_code=$? + error=$(send_command aws --no-verify-ssl s3api create-bucket --bucket "$2" "${location_args[@]}" 2>&1) || exit_code=$? elif [[ $1 == "s3cmd" ]]; then log 5 "s3cmd ${S3CMD_OPTS[*]} --no-check-certificate mb s3://$2" - error=$(send_command s3cmd "${S3CMD_OPTS[@]}" --no-check-certificate mb s3://"$2" 2>&1) || exit_code=$? + error=$(send_command s3cmd "${S3CMD_OPTS[@]}" --no-check-certificate mb --region="$AWS_REGION" s3://"$2" 2>&1) || exit_code=$? elif [[ $1 == "mc" ]]; then error=$(send_command mc --insecure mb "$MC_ALIAS"/"$2" --region "$AWS_REGION" 2>&1) || exit_code=$? else @@ -101,7 +105,11 @@ create_bucket_object_lock_enabled() { fi local exit_code=0 - error=$(send_command aws --no-verify-ssl s3api create-bucket --bucket "$1" 2>&1 --object-lock-enabled-for-bucket 2>&1) || local exit_code=$? + local location_args=() + if [ -n "$AWS_REGION" ] && [ "$AWS_REGION" != "us-east-1" ]; then + location_args=(--create-bucket-configuration LocationConstraint="$AWS_REGION") + fi + error=$(send_command aws --no-verify-ssl s3api create-bucket --bucket "$1" "${location_args[@]}" 2>&1 --object-lock-enabled-for-bucket 2>&1) || local exit_code=$? if [ $exit_code -ne 0 ]; then log 2 "error creating bucket: $error" return 1 diff --git a/tests/rest_scripts/create_bucket.sh b/tests/rest_scripts/create_bucket.sh index e154c62..e177ecf 100644 --- a/tests/rest_scripts/create_bucket.sh +++ b/tests/rest_scripts/create_bucket.sh @@ -67,6 +67,9 @@ create_canonical_hash_sts_and_signature curl_command+=(curl -ks -w "%{http_code}" -X PUT "$AWS_ENDPOINT_URL/$bucket_name") curl_command+=(-H "\"Authorization: AWS4-HMAC-SHA256 Credential=$aws_access_key_id/$year_month_day/$aws_region/s3/aws4_request,SignedHeaders=$param_list,Signature=$signature\"") curl_command+=("${header_fields[@]}") +if [ "$aws_region" != "us-east-1" ]; then + curl_command+=(-d "\"$aws_region\"") +fi curl_command+=(-o "$OUTPUT_FILE") # shellcheck disable=SC2154 eval "${curl_command[*]}" 2>&1