Skip to content

Add create notifications helper method - #6113

Open
mujtaba1747 wants to merge 6 commits into
aws:master-nova-follow-upsfrom
mujtaba1747:master-notifications-fix
Open

Add create notifications helper method#6113
mujtaba1747 wants to merge 6 commits into
aws:master-nova-follow-upsfrom
mujtaba1747:master-notifications-fix

Conversation

@mujtaba1747

@mujtaba1747 mujtaba1747 commented Jul 27, 2026

Copy link
Copy Markdown
Collaborator

Summary
Improves SNS/EventBridge notification setup in sagemaker-train and makes permission failures clearer.

File changed: notifications.py

  • Add create_notification_topic(topic_name, sagemaker_session): creates an SNS topic and applies an access policy that lets EventBridge in the same account publish to it. The returned ARN can be passed straight to enable_notifications, so callers no longer have to configure the topic policy by hand.

  • Add _build_topic_policy(topic_arn, account_id) helper that assembles the policy: the default owner statement (standard SNS actions scoped to the owning account via AWS:SourceAccount) plus an explicit statement granting the EventBridge service principal (events.amazonaws.com) SNS:Publish, also scoped by AWS:SourceAccount.

  • Tighten error handling in enable_notifications: replace the broad except Exception (which wrapped every failure in a generic ValueError) with a targeted except ClientError. On AccessDenied/AccessDeniedException it raises a concise PermissionError pointing at the missing events:PutTargets permission; all other errors propagate unchanged.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant