in taskcat/_dataclasses.py [0:0]
def _bucket_matches_existing(self):
try:
location = self.s3_client.get_bucket_location(Bucket=self.name)[
"LocationConstraint"
]
location = location if location else "us-east-1"
except self.s3_client.exceptions.NoSuchBucket:
location = None
if location != self.region and location is not None:
raise TaskCatException(
f"bucket {self.name} already exists, but is not in "
f"the expected region {self.region}, expected {location}"
)
if location:
if self.regional_buckets:
return True
tags = self.s3_client.get_bucket_tagging(Bucket=self.name)["TagSet"]
tags = {t["Key"]: t["Value"] for t in tags}
uid = tags.get("taskcat-id")
uid = UUID(uid) if uid else uid
if uid != self.taskcat_id:
raise TaskCatException(
f"bucket {self.name} already exists, but does not have a matching"
f" uuid"
)
return True
return False