diff --git a/agent_starter_pack/cli/commands/setup_cicd.py b/agent_starter_pack/cli/commands/setup_cicd.py index 0a7143f2..8d0ef57a 100644 --- a/agent_starter_pack/cli/commands/setup_cicd.py +++ b/agent_starter_pack/cli/commands/setup_cicd.py @@ -372,7 +372,7 @@ def setup_terraform_backend( # Ensure bucket exists try: result = run_command( - ["gsutil", "ls", "-b", f"gs://{bucket_name}"], + ["gcloud", "storage", "buckets", "describe", f"gs://{bucket_name}"], check=False, capture_output=True, ) @@ -381,11 +381,28 @@ def setup_terraform_backend( console.print(f"\n📦 Creating Terraform state bucket: {bucket_name}") # Create bucket run_command( - ["gsutil", "mb", "-p", project_id, "-l", region, f"gs://{bucket_name}"] + [ + "gcloud", + "storage", + "buckets", + "create", + f"gs://{bucket_name}", + f"--project={project_id}", + f"--location={region}", + ] ) # Enable versioning - run_command(["gsutil", "versioning", "set", "on", f"gs://{bucket_name}"]) + run_command( + [ + "gcloud", + "storage", + "buckets", + "update", + f"gs://{bucket_name}", + "--versioning", + ] + ) except subprocess.CalledProcessError as e: console.print(f"\n❌ Failed to setup state bucket: {e}") raise diff --git a/agent_starter_pack/cli/utils/cicd.py b/agent_starter_pack/cli/utils/cicd.py index 781e7100..1781c815 100644 --- a/agent_starter_pack/cli/utils/cicd.py +++ b/agent_starter_pack/cli/utils/cicd.py @@ -783,7 +783,7 @@ def setup_terraform_state(self, project_dir: Path, env: Environment) -> None: # Ensure bucket exists and is accessible try: result = run_command( - ["gsutil", "ls", "-b", f"gs://{bucket_name}"], + ["gcloud", "storage", "buckets", "describe", f"gs://{bucket_name}"], check=False, capture_output=True, ) @@ -792,18 +792,25 @@ def setup_terraform_state(self, project_dir: Path, env: Environment) -> None: print(f"\n📦 Creating Terraform state bucket: {bucket_name}") run_command( [ - "gsutil", - "mb", - "-p", - self.config.cicd_project_id, - "-l", - self.config.region, + "gcloud", + "storage", + "buckets", + "create", f"gs://{bucket_name}", + f"--project={self.config.cicd_project_id}", + f"--location={self.config.region}", ] ) run_command( - ["gsutil", "versioning", "set", "on", f"gs://{bucket_name}"] + [ + "gcloud", + "storage", + "buckets", + "update", + f"gs://{bucket_name}", + "--versioning", + ] ) except subprocess.CalledProcessError as e: print(f"\n❌ Failed to setup state bucket: {e}") diff --git a/tests/cli/commands/test_setup_cicd.py b/tests/cli/commands/test_setup_cicd.py index 4801918c..4bd9e364 100644 --- a/tests/cli/commands/test_setup_cicd.py +++ b/tests/cli/commands/test_setup_cicd.py @@ -307,11 +307,11 @@ def run_command_side_effect(*args: Any, **kwargs: Any) -> MagicMock: mock_response.stdout = '{"isEmpty": true}' mock_response.returncode = 0 print("Mocking repository view command") - # Mock gsutil commands - elif "gsutil" in command: + # Mock gcloud storage commands + elif "gcloud" in command and "storage" in command: mock_response.stdout = "" mock_response.returncode = 0 - print("Mocking gsutil command") + print("Mocking gcloud storage command") # Mock git init elif "git" in command and "init" in command: mock_response.stdout = ""