Skip to content

Commit

Permalink
[fix] fix multi region cf handler (#187)
Browse files Browse the repository at this point in the history
  • Loading branch information
aquamatthias authored Nov 28, 2023
1 parent f4645f8 commit 8906066
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 19 deletions.
10 changes: 4 additions & 6 deletions fixbackend/cloud_accounts/service_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,16 +232,14 @@ async def handle_stack_deleted(msg: Json) -> Optional[CloudAccount]:

try:
body = json.loads(message["Body"])
assert body["Type"] == "Notification"
content = json.loads(body["Message"])
kind = content["RequestType"]
kind = body["RequestType"]
match kind:
case "Create":
return await handle_stack_created(content)
return await handle_stack_created(body)
case "Delete":
return await handle_stack_deleted(content)
return await handle_stack_deleted(body)
case "Update":
return await handle_stack_created(content)
return await handle_stack_created(body)
case _:
log.info(f"Received a CF stack event that is currently not handled. Ignore. {kind}")
await send_response(message) # still try to acknowledge the message
Expand Down
14 changes: 1 addition & 13 deletions tests/fixbackend/cloud_accounts/service_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -818,19 +818,7 @@ def notification(kind: str, physical_resource_id: Optional[str] = None) -> Json:
}
if physical_resource_id:
base["PhysicalResourceId"] = physical_resource_id
cf_message = {
"Type": "Notification",
"MessageId": "38ccbec9-9999-5871-9383-e31e58450b68",
"TopicArn": "arn:aws:sns:us-east-1:12345:SomeCallbacks",
"Subject": "AWS CloudFormation custom resource request",
"Message": json.dumps(base),
"Timestamp": "2023-11-22T08:45:16.159Z",
"SignatureVersion": "1",
"Signature": "sig",
"SigningCertURL": "https://cert/pem",
"UnsubscribeURL": "https://unsubscribe",
}
return {"Body": json.dumps(cf_message)}
return {"Body": json.dumps(base)}

# Handle Create Message
request_handler_mock.append(handle_request)
Expand Down

0 comments on commit 8906066

Please sign in to comment.