-
Notifications
You must be signed in to change notification settings - Fork 0
/
cors-config-set.sh
executable file
·29 lines (25 loc) · 995 Bytes
/
cors-config-set.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/bin/bash
# Get the directory where the script is located
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
# Source the scripts using the script directory path
source $SCRIPT_DIR/../variables.sh
# Check if both a function name and API name were passed as arguments
if [ -z "$1" ] || [ -z "$2" ]; then
echo "Usage: $0 <PROFILE_NAME> <BUCKET_NAME>"
if [ -z "$1" ]; then
echo "No profile name provided. Using default profile: $DEFAULT_PROFILE_NAME"
PROFILE_NAME=$DEFAULT_PROFILE_NAME
else
PROFILE_NAME=$1
fi
if [ -z "$2" ]; then
echo "No bucket name provided."
exit 1
else
BUCKET_NAME=$2
fi
else
PROFILE_NAME=$1 # Set the API name from the second script argument
BUCKET_NAME=$2 # Set the function name from the first script argument
fi
aws s3api put-bucket-cors --profile $PROFILE_NAME --bucket $BUCKET_NAME --cors-configuration file://$SCRIPT_DIR/cors.json --region $REGION