Route53: Record overwrites: fix error msg (#5747)

This commit is contained in:
Viren Nadkarni 2022-12-10 05:22:05 +05:30 committed by GitHub
parent 9be9edf8fa
commit 9e19d35ce8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 6 deletions

View File

@ -177,5 +177,8 @@ class DnsNameInvalidForZone(Route53ClientError):
class ChangeSetAlreadyExists(Route53ClientError):
code = 400
def __init__(self):
super().__init__("InvalidChangeBatch", "Provided Change is a duplicate")
def __init__(self, action: str, name: str, _type: str):
super().__init__(
"InvalidChangeBatch",
f"Tried to {action.lower()} resource record set [name='{name}', type='{_type}'] but it already exists",
)

View File

@ -532,8 +532,13 @@ class Route53Backend(BaseBackend):
def change_resource_record_sets(self, zoneid, change_list) -> None:
the_zone = self.get_hosted_zone(zoneid)
if any([rr for rr in change_list if rr in the_zone.rr_changes]):
raise ChangeSetAlreadyExists
for rr in change_list:
if rr in the_zone.rr_changes:
name = rr["ResourceRecordSet"]["Name"] + "."
_type = rr["ResourceRecordSet"]["Type"]
raise ChangeSetAlreadyExists(
action=rr["Action"], name=name, _type=_type
)
for value in change_list:
original_change = copy.deepcopy(value)

View File

@ -290,8 +290,8 @@ route53|1:
- TestAccRoute53Record_setIdentifierChange
- TestAccRoute53Record_empty
- TestAccRoute53Record_longTXTrecord
- TestAccRoute53Record_doNotAllowOverwrite
- TestAccRoute53Record_allowOverwrite
- TestAccRoute53Record_Allow_doNotOverwrite
- TestAccRoute53Record_Allow_overwrite
route53|2:
- TestAccRoute53Zone_
- TestAccRoute53ZoneAssociation