File tree Expand file tree Collapse file tree
005-cloudfront-gettingstarted
028-sagemaker-featurestore Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1010- Type: functional
1111- Remove SDK content from CFN branch (belongs on SDK branches)
1212
13+
14+ ### 2026-04-22 v2 shared bucket
15+ - Type: functional
16+ - Script checks for prereq bucket stack before creating its own S3 bucket
17+ - Skips bucket deletion if using shared bucket
Original file line number Diff line number Diff line change 2020# ============================================================================
2121
2222UNIQUE_ID=$( cat /dev/urandom | tr -dc ' a-f0-9' | fold -w 12 | head -n 1)
23- BUCKET_NAME=" s3api-${UNIQUE_ID} "
23+ # Check for shared prereq bucket
24+ PREREQ_BUCKET=$( aws cloudformation describe-stacks --stack-name tutorial-prereqs-bucket \
25+ --query ' Stacks[0].Outputs[?OutputKey==`BucketName`].OutputValue' --output text 2> /dev/null)
26+ if [ -n " $PREREQ_BUCKET " ] && [ " $PREREQ_BUCKET " != " None" ]; then
27+ BUCKET_NAME=" $PREREQ_BUCKET "
28+ BUCKET_IS_SHARED=true
29+ echo " Using shared bucket: $BUCKET_NAME "
30+ else
31+ BUCKET_IS_SHARED=false
32+ BUCKET_NAME=" s3api-${UNIQUE_ID} "
33+ fi
2434
2535TEMP_DIR=$( mktemp -d)
2636LOG_FILE=" ${TEMP_DIR} /s3-gettingstarted.log"
@@ -83,7 +93,9 @@ cleanup() {
8393 fi
8494
8595 echo " Deleting bucket: ${BUCKET_NAME} "
86- aws s3api delete-bucket --bucket " $BUCKET_NAME " 2>&1 || echo " WARNING: Failed to delete bucket ${BUCKET_NAME} "
96+ if [ " $BUCKET_IS_SHARED " = " false" ]; then
97+ aws s3api delete-bucket --bucket " $BUCKET_NAME " 2>&1 || echo " WARNING: Failed to delete bucket ${BUCKET_NAME} "
98+ fi
8799
88100 echo " "
89101 echo " Cleaning up temp directory: ${TEMP_DIR} "
Original file line number Diff line number Diff line change 1010- Type: functional
1111- Remove SDK content from CFN branch (belongs on SDK branches)
1212
13+
14+ ### 2026-04-22 v2 shared bucket
15+ - Type: functional
16+ - Script checks for prereq bucket stack before creating its own S3 bucket
17+ - Skips bucket deletion if using shared bucket
Original file line number Diff line number Diff line change @@ -106,7 +106,17 @@ cleanup() {
106106
107107# Generate a random identifier for the bucket name
108108RANDOM_ID=$( openssl rand -hex 6)
109- BUCKET_NAME=" cloudfront-${RANDOM_ID} "
109+ # Check for shared prereq bucket
110+ PREREQ_BUCKET=$( aws cloudformation describe-stacks --stack-name tutorial-prereqs-bucket \
111+ --query ' Stacks[0].Outputs[?OutputKey==`BucketName`].OutputValue' --output text 2> /dev/null)
112+ if [ -n " $PREREQ_BUCKET " ] && [ " $PREREQ_BUCKET " != " None" ]; then
113+ BUCKET_NAME=" $PREREQ_BUCKET "
114+ BUCKET_IS_SHARED=true
115+ echo " Using shared bucket: $BUCKET_NAME "
116+ else
117+ BUCKET_IS_SHARED=false
118+ BUCKET_NAME=" cloudfront-${RANDOM_ID} "
119+ fi
110120echo " Using bucket name: $BUCKET_NAME "
111121
112122# Create a temporary directory for content
Original file line number Diff line number Diff line change 1010- Type: functional
1111- unordered list bullets and trailing whitespace
1212
13+
14+ ### 2026-04-22 v2 shared bucket
15+ - Type: functional
16+ - Script checks for prereq bucket stack before creating its own S3 bucket
17+ - Skips bucket deletion if using shared bucket
Original file line number Diff line number Diff line change @@ -201,7 +201,17 @@ if [ -z "$REGION" ]; then
201201else
202202 echo " Using region: $REGION "
203203fi
204- S3_BUCKET_NAME=" sagemaker-featurestore-${RANDOM_ID} -${ACCOUNT_ID} "
204+ # Check for shared prereq bucket
205+ PREREQ_BUCKET=$( aws cloudformation describe-stacks --stack-name tutorial-prereqs-bucket \
206+ --query ' Stacks[0].Outputs[?OutputKey==`BucketName`].OutputValue' --output text 2> /dev/null)
207+ if [ -n " $PREREQ_BUCKET " ] && [ " $PREREQ_BUCKET " != " None" ]; then
208+ S3_BUCKET_NAME=" $PREREQ_BUCKET "
209+ BUCKET_IS_SHARED=true
210+ echo " Using shared bucket: $S3_BUCKET_NAME "
211+ else
212+ BUCKET_IS_SHARED=false
213+ S3_BUCKET_NAME=" sagemaker-featurestore-${RANDOM_ID} -${ACCOUNT_ID} "
214+ fi
205215PREFIX=" featurestore-tutorial"
206216CURRENT_TIME=$( date +%s)
207217
Original file line number Diff line number Diff line change 1010- Type: functional
1111- security and consistency updates
1212
13+
14+ ### 2026-04-22 v2 shared bucket
15+ - Type: functional
16+ - Script checks for prereq bucket stack before creating its own S3 bucket
17+ - Skips bucket deletion if using shared bucket
Original file line number Diff line number Diff line change @@ -63,7 +63,17 @@ cleanup() {
6363
6464# Generate a random identifier for S3 bucket
6565RANDOM_ID=$( openssl rand -hex 6)
66- BUCKET_NAME=" emr${RANDOM_ID} "
66+ # Check for shared prereq bucket
67+ PREREQ_BUCKET=$( aws cloudformation describe-stacks --stack-name tutorial-prereqs-bucket \
68+ --query ' Stacks[0].Outputs[?OutputKey==`BucketName`].OutputValue' --output text 2> /dev/null)
69+ if [ -n " $PREREQ_BUCKET " ] && [ " $PREREQ_BUCKET " != " None" ]; then
70+ BUCKET_NAME=" $PREREQ_BUCKET "
71+ BUCKET_IS_SHARED=true
72+ echo " Using shared bucket: $BUCKET_NAME "
73+ else
74+ BUCKET_IS_SHARED=false
75+ BUCKET_NAME=" emr${RANDOM_ID} "
76+ fi
6777echo " Using bucket name: $BUCKET_NAME "
6878
6979# Create S3 bucket
Original file line number Diff line number Diff line change 1010- Type: functional
1111- unordered list bullets and trailing whitespace
1212
13+
14+ ### 2026-04-22 v2 shared bucket
15+ - Type: functional
16+ - Script checks for prereq bucket stack before creating its own S3 bucket
17+ - Skips bucket deletion if using shared bucket
Original file line number Diff line number Diff line change @@ -78,7 +78,9 @@ cleanup_resources() {
7878 aws s3 rm " s3://$S3_BUCKET_NAME " --recursive 2> /dev/null || true
7979
8080 echo " Deleting S3 bucket..."
81- aws s3api delete-bucket --bucket " $S3_BUCKET_NAME " 2> /dev/null || true
81+ if [ " $BUCKET_IS_SHARED " = " false" ]; then
82+ aws s3api delete-bucket --bucket " $S3_BUCKET_NAME " 2> /dev/null || true
83+ fi
8284 fi
8385}
8486
@@ -118,7 +120,17 @@ RANDOM_ID=$(generate_random_id)
118120echo " Generated random identifier: $RANDOM_ID "
119121
120122# Step 1: Create an S3 bucket
121- S3_BUCKET_NAME=" configservice-${RANDOM_ID} "
123+ # Check for shared prereq bucket
124+ PREREQ_BUCKET=$( aws cloudformation describe-stacks --stack-name tutorial-prereqs-bucket \
125+ --query ' Stacks[0].Outputs[?OutputKey==`BucketName`].OutputValue' --output text 2> /dev/null)
126+ if [ -n " $PREREQ_BUCKET " ] && [ " $PREREQ_BUCKET " != " None" ]; then
127+ S3_BUCKET_NAME=" $PREREQ_BUCKET "
128+ BUCKET_IS_SHARED=true
129+ echo " Using shared bucket: $S3_BUCKET_NAME "
130+ else
131+ BUCKET_IS_SHARED=false
132+ S3_BUCKET_NAME=" configservice-${RANDOM_ID} "
133+ fi
122134echo " Creating S3 bucket: $S3_BUCKET_NAME "
123135
124136# Get the current region
You can’t perform that action at this time.
0 commit comments