From 5602f1d7b05d76952c13a159d7aab4caf93cfd2b Mon Sep 17 00:00:00 2001 From: lenape Date: Mon, 4 Aug 2025 02:09:06 +0000 Subject: [PATCH] automated terminal push --- infrastructure/foundation/bootstrap.bash | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/infrastructure/foundation/bootstrap.bash b/infrastructure/foundation/bootstrap.bash index f738eae..675731e 100644 --- a/infrastructure/foundation/bootstrap.bash +++ b/infrastructure/foundation/bootstrap.bash @@ -30,6 +30,19 @@ aws sts get-caller-identity || { exit 1 } +# Check if ANY state bucket already exists +EXISTING_BUCKET=$(aws s3 ls | grep "nvhi-atsila-microservice-terraform-state" | head -n1 | awk '{print $3}') + +if [ -n "$EXISTING_BUCKET" ]; then + echo "✅ Using existing bucket: $EXISTING_BUCKET" + BUCKET_NAME=$EXISTING_BUCKET +else + # Only create new if none exists + BUCKET_SUFFIX=$(openssl rand -hex 4) + BUCKET_NAME="${PROJECT_NAME}-terraform-state-${BUCKET_SUFFIX}" + # ... create bucket +fi + # Create S3 bucket for Terraform state echo "📦 Creating S3 bucket for Terraform state..." if aws s3api head-bucket --bucket "${BUCKET_NAME}" 2>/dev/null; then