Is there an existing issue for this?
Current Behavior
This behaviour is wrong as buckets after a failed will error because of the raise on line 67
|
for b in buckets: |
|
|
|
try: |
|
response = cos.create_bucket( |
|
Bucket=f"{deployment_name}-{b}", |
|
) |
|
if response["ResponseMetadata"]["HTTPStatusCode"] == 200: |
|
print(f"Bucket {deployment_name}-{b} created successfully \u2714") |
|
else: |
|
print(f"Potential error creating bucket {deployment_name}-{b} please check") |
|
except: |
|
print(f"Bucket {deployment_name}-{b} already exists or could not be created") |
|
raise |
Expected Behavior
Should check if bucket exists. If an error occurs then whole script should cancel out.
def bucket_exists(bucket_name: str):
try:
cos.head_bucket(Bucket=bucket_name)
return True
except:
print(f"Bucket does not exist: {bucket_name}")
return False
bucket_errors = []
for b in buckets:
bucket_name: str = f"{deployment_name}-{b}"
try:
# This takes longer due to IO but ensures errors are not because of existing buckets
if bucket_exists(bucket_name=bucket_name):
continue
response = cos.create_bucket(
Bucket=bucket_name,
)
if response["ResponseMetadata"]["HTTPStatusCode"] == 200:
print(f"Bucket {bucket_name} created successfully \u2714")
else:
print(f"Potential error creating bucket {bucket_name} please check")
except Exception as err:
print(f"Bucket {bucket_name} already exists or could not be created")
bucket_error = {
'bucket': bucket_name,
'err': err,
}
bucket_errors.append(bucket_error)
# Raisng here will just cause it to break out the try catch and skip buckets after.
# raise
if len(bucket_errors) > 0:
print("Warning: some buckets may have not been setup correctly causing problems with the deployment.")
for b in bucket_errors:
print(f"{b.bucket} - {b.err}")
Steps To Reproduce
No response
Environment
Anything else?
No response
Code of Conduct
Is there an existing issue for this?
Current Behavior
This behaviour is wrong as buckets after a failed will error because of the raise on line 67
geospatial-studio/deployment-scripts/create_buckets.py
Lines 55 to 67 in 03fae7a
Expected Behavior
Should check if bucket exists. If an error occurs then whole script should cancel out.
Steps To Reproduce
No response
Environment
Anything else?
No response
Code of Conduct