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 strategy —
SnsStrategy(ext_sns/strategy.py), an implementation of the coreSmsDeliveryStrategyinterface, registered assnsviaregister_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 tonotification_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¶
- 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 erroraiobotocore not installed. - Enable the extension for a channel from Settings > Extensions (per-channel activation via
ChannelExtension). - Make it the active SMS provider by setting the
sms_providerplatform 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_providersetting on every send: the setting's keys (minusprovider) 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.SMSTypeattribute; the value is normalized toTransactionalunless it case-insensitively equalspromotional. - Origination selection. If the message's own from number starts with
+, it is sent asAWS.MM.SMS.OriginationNumber; otherwise a non-E.164 message from value — or, failing that, the configuredsender_id— is sent asAWS.SNS.SMS.SenderID. With neither present, no origination attribute is sent. - Batch sends reuse one client.
send_batchopens 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(channelsms) with the provider, the SNSMessageId, 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.