diff --git a/fixbackend/cloud_accounts/service_impl.py b/fixbackend/cloud_accounts/service_impl.py index 26a4bcd4..90a577e8 100644 --- a/fixbackend/cloud_accounts/service_impl.py +++ b/fixbackend/cloud_accounts/service_impl.py @@ -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 diff --git a/tests/fixbackend/cloud_accounts/service_test.py b/tests/fixbackend/cloud_accounts/service_test.py index d6c0ee09..59413551 100644 --- a/tests/fixbackend/cloud_accounts/service_test.py +++ b/tests/fixbackend/cloud_accounts/service_test.py @@ -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)