cleanup_failed_stack.pyā¢1.62 kB
#!/usr/bin/env python3
"""
Clean up a failed TimeLooker stack deployment.
"""
import os
import sys
import subprocess
from pathlib import Path
def run_command(command, cwd=None):
"""Run a shell command and return the result."""
print(f"Running: {command}")
# Set environment variable to silence Node.js version warning
env = os.environ.copy()
env['JSII_SILENCE_WARNING_UNTESTED_NODE_VERSION'] = '1'
result = subprocess.run(command, shell=True, cwd=cwd, capture_output=True, text=True, env=env)
if result.returncode != 0:
print(f"Warning: {result.stderr}")
return None
return result.stdout.strip()
def main():
"""Clean up the failed stack."""
project_root = Path(__file__).parent.parent
infrastructure_dir = project_root / "infrastructure"
print("š§¹ Cleaning up failed TimeLooker stack...")
# Check if AWS CLI is configured
try:
run_command("aws sts get-caller-identity")
print("ā
AWS CLI is configured")
except:
print("ā AWS CLI not configured. Please run 'aws configure' first.")
sys.exit(1)
# Destroy the stack
print("\nšļø Destroying failed stack...")
output = run_command("cdk destroy --force", cwd=infrastructure_dir)
if output is not None:
print("ā
Stack cleanup completed")
print("\nYou can now run the deployment script again:")
print("python scripts/deploy_infrastructure.py")
else:
print("ā ļø Stack cleanup may have had issues, but you can try deploying again")
if __name__ == "__main__":
main()