Skip to content

Commit 2a7bb7d

Browse files
committed
fix tf destroy
1 parent 31fb43d commit 2a7bb7d

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

shells/backends/gcp_tf_backend/src/driver.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,16 @@ def delete_tfstate_file(self, context, tf_state_unique_name: str):
109109
"""Deletes a blob from the bucket."""
110110
with LoggingSessionContext(context) as logger:
111111
gcp_backend_resource = GcpTfBackend.create_from_context(context)
112+
project_id = gcp_backend_resource.project
112113
try:
113-
gcp_service = self._can_conntect_to_gcp(context, logger)
114+
gcp_service = self._create_gcp_session(context, project_id, logger)
114115
storage_client = storage.Client()
115116
bucket_name = gcp_backend_resource.bucket_name
116-
bucket = storage_client.bucket(bucket_name)
117-
blob = bucket.blob(tf_state_unique_name)
118-
blob.delete()
117+
bucket = storage_client.get_bucket(bucket_name)
118+
"""Delete object under folder"""
119+
blobs = list(bucket.list_blobs(prefix=tf_state_unique_name))
120+
bucket.delete_blobs(blobs)
121+
print(f"Folder {tf_state_unique_name} deleted.")
119122
except Exception as e:
120123
raise ValueError(f"{tf_state_unique_name} file was not removed from backend provider")
121124

0 commit comments

Comments
 (0)