-
Notifications
You must be signed in to change notification settings - Fork 192
Terraform update #1070
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
base: main
Are you sure you want to change the base?
Terraform update #1070
Conversation
8b348cd
to
0cdeeda
Compare
15bb598
to
d1d848a
Compare
for bucket in $BUCKETS; do | ||
if [ ! -z "$bucket" ]; then | ||
echo "Checking if bucket $bucket exists..." | ||
if aws s3api head-bucket --bucket $bucket 2>/dev/null; then |
Check warning
Code scanning / CodeGuru Reviewer Scanner
Unquoted Variables Medium
if aws s3api head-bucket --bucket $bucket 2>/dev/null; then | ||
echo "Emptying bucket $bucket..." | ||
# First delete all non-versioned objects | ||
aws s3 rm s3://$bucket --recursive || true |
Check warning
Code scanning / CodeGuru Reviewer Scanner
Unquoted Variables Medium
echo "Attempt $attempt to delete all versions..." | ||
|
||
# Get all versions and delete markers | ||
VERSIONS=$(aws s3api list-object-versions --bucket $bucket --output json 2>/dev/null || echo '{"Versions":[],"DeleteMarkers":[]}') |
Check warning
Code scanning / CodeGuru Reviewer Scanner
Unquoted Variables Medium
|
||
if [ "$VERSION_COUNT" -gt 0 ]; then | ||
echo "Found $VERSION_COUNT versions to delete" | ||
echo "$VERSIONS" | jq -c '{Objects: [.Versions[] | {Key:.Key, VersionId:.VersionId}] | select(length > 0)}' | aws s3api delete-objects --bucket $bucket --delete file:///dev/stdin || true |
Check warning
Code scanning / CodeGuru Reviewer Scanner
Unquoted Variables Medium
|
||
if [ "$MARKER_COUNT" -gt 0 ]; then | ||
echo "Found $MARKER_COUNT delete markers to remove" | ||
echo "$VERSIONS" | jq -c '{Objects: [.DeleteMarkers[] | {Key:.Key, VersionId:.VersionId}] | select(length > 0)}' | aws s3api delete-objects --bucket $bucket --delete file:///dev/stdin || true |
Check warning
Code scanning / CodeGuru Reviewer Scanner
Unquoted Variables Medium
fi | ||
|
||
# Check if bucket is empty | ||
REMAINING=$(aws s3api list-object-versions --bucket $bucket --output json 2>/dev/null || echo '{"Versions":[],"DeleteMarkers":[]}') |
Check warning
Code scanning / CodeGuru Reviewer Scanner
Unquoted Variables Medium
|
||
# Attempt to delete the bucket directly after emptying it | ||
echo "Attempting to delete bucket $bucket directly..." | ||
aws s3 rb s3://$bucket --force || true |
Check warning
Code scanning / CodeGuru Reviewer Scanner
Unquoted Variables Medium
mv "$TEMP_DIR/main.tf.tmp" "$TEMP_DIR/main.tf" | ||
|
||
# Find the closing brace of the resource block | ||
end_line=$(tail -n +$line_num "$TEMP_DIR/main.tf" | grep -n "^}" | head -1 | cut -d: -f1) |
Check warning
Code scanning / CodeGuru Reviewer Scanner
Unquoted Variables Medium
echo "Found cid_dataexports_source_outputs at line $line_num" | ||
|
||
# Find the closing brace of the output block | ||
end_line=$(tail -n +$line_num "$TEMP_DIR/outputs.tf" | grep -n "^}" | head -1 | cut -d: -f1) |
Check warning
Code scanning / CodeGuru Reviewer Scanner
Unquoted Variables Medium
Issue #, if available:
Description of changes:
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.