diff --git a/basic_setup/ses_sns_shim_global.py b/basic_setup/ses_sns_shim_global.py index 2bf01f0..005172a 100644 --- a/basic_setup/ses_sns_shim_global.py +++ b/basic_setup/ses_sns_shim_global.py @@ -53,7 +53,6 @@ def get_queue_url(domain): raise def publish_to_sns(topic_arn, message_body, msg_id): - """Versucht SNS Publish. Gibt True bei Erfolg, False bei Topic-Not-Found.""" attempt = 0 while attempt < MAX_RETRIES: try: @@ -65,8 +64,9 @@ def publish_to_sns(topic_arn, message_body, msg_id): return True except ClientError as e: error_code = e.response['Error']['Code'] - if error_code == 'NotFound' or error_code == 'NotFoundException': - logger.info(f"ℹ️ SNS Topic not found for {topic_arn} — falling back to SQS") + # Fallback auf SQS bei Topic-nicht-gefunden ODER fehlender Berechtigung + if error_code in ('NotFound', 'NotFoundException', 'AuthorizationError'): + logger.info(f"ℹ️ SNS unavailable for {topic_arn} ({error_code}) — falling back to SQS") return False attempt += 1 logger.warning(f"Retry {attempt}/{MAX_RETRIES} SNS: {error_code}")