docs(P07): complete swallowed-error-hardening phase (v1.13.10)
---ci--- project: acdl phase: 7 milestone: v1.14 status: complete requirements: covered: [REQ-141] partial: [] ---/ci---
This commit is contained in:
@@ -75,8 +75,10 @@ def apply_managed_policy(iam, policy_doc: str) -> str:
|
||||
try:
|
||||
iam.delete_policy_version(PolicyArn=POLICY_ARN, VersionId=default)
|
||||
print(f"deleted old default version {default}")
|
||||
except iam.exceptions.NoSuchEntityException:
|
||||
pass # already deleted
|
||||
except Exception as e:
|
||||
print(f"could not delete old version {default}: {e}")
|
||||
print(f"WARNING: could not delete old version {default}: {e}")
|
||||
return POLICY_ARN
|
||||
except iam.exceptions.NoSuchEntityException:
|
||||
print(f"creating managed policy {POLICY_NAME}...")
|
||||
|
||||
@@ -48,12 +48,16 @@ def main():
|
||||
try:
|
||||
s3.head_bucket(Bucket=STATE_BUCKET)
|
||||
print(f"s3: bucket {STATE_BUCKET} already exists")
|
||||
except Exception:
|
||||
kwargs = {"Bucket": STATE_BUCKET}
|
||||
if REGION != "us-east-1":
|
||||
kwargs["CreateBucketConfiguration"] = {"LocationConstraint": REGION}
|
||||
s3.create_bucket(**kwargs)
|
||||
print(f"s3: created bucket {STATE_BUCKET}")
|
||||
except s3.exceptions.ClientError as e:
|
||||
error_code = e.response.get("Error", {}).get("Code", "")
|
||||
if error_code in ("404", "NoSuchBucket", "NotFound"):
|
||||
kwargs = {"Bucket": STATE_BUCKET}
|
||||
if REGION != "us-east-1":
|
||||
kwargs["CreateBucketConfiguration"] = {"LocationConstraint": REGION}
|
||||
s3.create_bucket(**kwargs)
|
||||
print(f"s3: created bucket {STATE_BUCKET}")
|
||||
else:
|
||||
raise
|
||||
# Enable versioning (idempotent)
|
||||
s3.put_bucket_versioning(
|
||||
Bucket=STATE_BUCKET,
|
||||
|
||||
Reference in New Issue
Block a user