Skip to content

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

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Open

Terraform update #1070

wants to merge 19 commits into from

Conversation

vtaws
Copy link
Contributor

@vtaws vtaws commented Dec 17, 2024

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.

@vtaws vtaws requested a review from iakov-aws June 17, 2025 17:01
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

Double quote to prevent globbing and word splitting.
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

Double quote to prevent globbing and word splitting.
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

Double quote to prevent globbing and word splitting.

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

Double quote to prevent globbing and word splitting.

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

Double quote to prevent globbing and word splitting.
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

Double quote to prevent globbing and word splitting.

# 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

Double quote to prevent globbing and word splitting.
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

Double quote to prevent globbing and word splitting.
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

Double quote to prevent globbing and word splitting.
@vtaws vtaws force-pushed the terraform-update branch from 3b43285 to 90c6673 Compare June 19, 2025 12:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants