Skip to content

Amazon SNS

Amazon SNS SMS delivery. Registers an SMS delivery strategy named sns with the notification module's strategy pool, sending texts by calling SNS publish with an E.164 phone number and SMS message attributes via aiobotocore. Once selected as the active SMS provider it carries both templated SMS notifications and the SMS one-time codes used for two-factor login.

At a glance

Extension id sns
Category communication
Version 0.0.1
Provides SMS delivery strategy (sns)
External account AWS — access key id / secret access key (or ambient AWS credentials)

What It Provides

  • SMS delivery strategySnsStrategy (ext_sns/strategy.py), an implementation of the core SmsDeliveryStrategy interface, registered as sns via register_sms_strategy("sns", SnsStrategy) on activation. Registration is claimed in the registration ledger — see Notification SMS in Building Extensions.
  • Two core code paths use the active SMS strategy: the notification service's send_sms (renders a notification template, strips HTML tags to plain text, and logs the result to notification_logs) and the two-factor auth service's SMS OTP sender (6-digit verification codes).
  • Nothing else — no webhook endpoints, Temporal workflows, schedules, admin pages, GraphQL fields, or event subscriptions.

Setup

  1. Once installed (or dev-linked in development), the extension is discovered at startup. Its only extra dependency is aiobotocore (pip install vectis[sns]); if the library is missing, sends fail gracefully with the error aiobotocore not installed.
  2. Enable the extension for a channel from Settings > Extensions (per-channel activation via ChannelExtension).
  3. Make it the active SMS provider by setting the sms_provider platform setting to a JSON object naming the strategy and its credentials, e.g. {"provider": "sns", "region": "us-east-1", "access_key_id": "…", "secret_access_key": "…", "sender_id": "Vectis"}. The notification and two-factor services read this setting at send time.

Configuration Reference

Key Type Required Secret Description
aws_region string No No Defaults to us-east-1
aws_access_key_id string No Yes
aws_secret_access_key string No Yes
sender_id string No No
sms_type string No No Transactional or Promotional; defaults to Transactional

Note

This schema drives the generic Configure form on Settings > Extensions. The credentials actually used at send time come from the sms_provider platform setting — the notification service does not read the per-channel extension config when building the strategy, and the setting keys follow the constructor's parameter names (region, access_key_id, secret_access_key), not the aws_-prefixed names above.

Operational Notes

  • Send-time construction. The strategy is rebuilt from the sms_provider setting on every send: the setting's keys (minus provider) are passed as constructor arguments — region, access_key_id, secret_access_key, sender_id, sms_type. If the setting is missing, names an unknown provider, or construction fails, delivery silently falls back to the console (dev logging) strategy.
  • Credentials are optional in code. The access key pair is only passed to the SNS client when both values are set; otherwise the client is created without explicit credentials and aiobotocore's normal credential resolution applies.
  • SMS type. Every publish sets the AWS.SNS.SMS.SMSType attribute; the value is normalized to Transactional unless it case-insensitively equals promotional.
  • Origination selection. If the message's own from number starts with +, it is sent as AWS.MM.SMS.OriginationNumber; otherwise a non-E.164 message from value — or, failing that, the configured sender_id — is sent as AWS.SNS.SMS.SenderID. With neither present, no origination attribute is sent.
  • Batch sends reuse one client. send_batch opens a single SNS client and publishes each message through it sequentially; a client-level failure fills the remaining results with that error.
  • Templated SMS sends are recorded in notification_logs (channel sms) with the provider, the SNS MessageId, recipient, and the first 500 characters of the rendered body.
  • Alternative SMS providers: the built-in console strategy ships with core; Twilio SMS is available as another extension.