Skip to content

AWS.SNS reference

Source: src/AWS/SNS/AddPermission.ts

Runtime binding for sns:AddPermission.

Bind this operation to a Topic inside a function runtime to grant other AWS accounts access to topic actions by adding a labeled statement to the topic’s access policy. The binding grants the host function sns:AddPermission on the topic. Provide the AddPermissionHttp layer on the Function to implement the binding.

// init (provide SNS.AddPermissionHttp on the Function)
const addPermission = yield* SNS.AddPermission(topic);
// runtime
yield* addPermission({
Label: "PartnerPublish",
AWSAccountId: ["123456789012"],
ActionName: ["Publish"],
});

Source: src/AWS/SNS/CheckIfPhoneNumberIsOptedOut.ts

Runtime binding for sns:CheckIfPhoneNumberIsOptedOut.

An account-scoped operation — reports whether SMS delivery to a phone number is blocked because its owner opted out. Provide the CheckIfPhoneNumberIsOptedOutHttp layer on the Function to implement the binding.

CheckIfPhoneNumberIsOptedOut: SMS Opt-Out Management

Section titled “CheckIfPhoneNumberIsOptedOut: SMS Opt-Out Management”
const checkOptOut = yield* SNS.CheckIfPhoneNumberIsOptedOut();
const { isOptedOut } = yield* checkOptOut({ phoneNumber: "+15555550123" });

Source: src/AWS/SNS/ConfirmSubscription.ts

Runtime binding for sns:ConfirmSubscription.

Bind this operation to a Subscription inside a function runtime to confirm a pending subscription with the token SNS delivered to the endpoint (e.g. from an https or email confirmation message). The binding grants the host function sns:ConfirmSubscription on the topic. Provide the ConfirmSubscriptionHttp layer on the Function to implement the binding.

ConfirmSubscription: Confirming Subscriptions

Section titled “ConfirmSubscription: Confirming Subscriptions”
// init (provide SNS.ConfirmSubscriptionHttp on the Function)
const confirmSubscription = yield* SNS.ConfirmSubscription(subscription);
// runtime: token comes from the SubscriptionConfirmation message
const response = yield* confirmSubscription({ Token: token });
// response.SubscriptionArn

Source: src/AWS/SNS/CreatePlatformEndpoint.ts

Runtime binding for sns:CreatePlatformEndpoint.

Bind this operation to a PlatformApplication to register device push tokens at runtime. The PlatformApplicationArn is injected automatically; the call is idempotent per token. Provide the CreatePlatformEndpointHttp layer on the Function to implement the binding.

const createEndpoint = yield* SNS.CreatePlatformEndpoint(app);
const endpoint = yield* createEndpoint({ Token: deviceToken });

Source: src/AWS/SNS/CreateSMSSandboxPhoneNumber.ts

Runtime binding for sns:CreateSMSSandboxPhoneNumber.

An account-scoped operation — registers a destination phone number in the SMS sandbox, which sends it a one-time verification code. Provide the CreateSMSSandboxPhoneNumberHttp layer on the Function to implement the binding.

const createSandboxNumber = yield* SNS.CreateSMSSandboxPhoneNumber();
yield* createSandboxNumber({ PhoneNumber: "+15555550123" });

Source: src/AWS/SNS/DeleteEndpoint.ts

Runtime binding for sns:DeleteEndpoint.

Bind this operation to a PlatformApplication to deregister one of its device endpoints (idempotent). Provide the DeleteEndpointHttp layer on the Function to implement the binding.

const deleteEndpoint = yield* SNS.DeleteEndpoint(app);
yield* deleteEndpoint({ EndpointArn: endpointArn });

Source: src/AWS/SNS/DeleteSMSSandboxPhoneNumber.ts

Runtime binding for sns:DeleteSMSSandboxPhoneNumber.

An account-scoped operation — removes a destination phone number from the account’s SMS sandbox. Provide the DeleteSMSSandboxPhoneNumberHttp layer on the Function to implement the binding.

const deleteSandboxNumber = yield* SNS.DeleteSMSSandboxPhoneNumber();
yield* deleteSandboxNumber({ PhoneNumber: "+15555550123" });

Source: src/AWS/SNS/GetDataProtectionPolicy.ts

Runtime binding for sns:GetDataProtectionPolicy.

Bind this operation to a Topic inside a function runtime to read the topic’s data protection policy document; the ResourceArn is injected automatically. The binding grants the host function sns:GetDataProtectionPolicy on the topic. Provide the GetDataProtectionPolicyHttp layer on the Function to implement the binding.

GetDataProtectionPolicy: Data Protection Policies

Section titled “GetDataProtectionPolicy: Data Protection Policies”
// init (provide SNS.GetDataProtectionPolicyHttp on the Function)
const getDataProtectionPolicy = yield* SNS.GetDataProtectionPolicy(topic);
// runtime
const response = yield* getDataProtectionPolicy();
// response.DataProtectionPolicy (JSON document string)

Source: src/AWS/SNS/GetEndpointAttributes.ts

Runtime binding for sns:GetEndpointAttributes.

Bind this operation to a PlatformApplication to read the attributes (Token, Enabled, CustomUserData) of one of its device endpoints. Provide the GetEndpointAttributesHttp layer on the Function to implement the binding.

const getEndpointAttributes = yield* SNS.GetEndpointAttributes(app);
const { Attributes } = yield* getEndpointAttributes({
EndpointArn: endpointArn,
});

Source: src/AWS/SNS/GetSMSAttributes.ts

Runtime binding for sns:GetSMSAttributes.

An account-scoped operation — reads the account-level SMS settings such as DefaultSMSType, MonthlySpendLimit, and delivery-status sampling. Provide the GetSMSAttributesHttp layer on the Function to implement the binding.

const getSmsAttributes = yield* SNS.GetSMSAttributes();
const { attributes } = yield* getSmsAttributes();

Source: src/AWS/SNS/GetSMSSandboxAccountStatus.ts

Runtime binding for sns:GetSMSSandboxAccountStatus.

An account-scoped operation — reports whether the account is still in the SMS sandbox (only verified destination numbers deliverable). Provide the GetSMSSandboxAccountStatusHttp layer on the Function to implement the binding.

const getSandboxStatus = yield* SNS.GetSMSSandboxAccountStatus();
const { IsInSandbox } = yield* getSandboxStatus();

Source: src/AWS/SNS/GetSubscriptionAttributes.ts

Runtime binding for sns:GetSubscriptionAttributes.

Bind this operation to a Subscription inside a function runtime to read the subscription’s raw attribute map (filter policy, redrive policy, raw message delivery, etc.). The binding grants the host function sns:GetSubscriptionAttributes on the subscription. Provide the GetSubscriptionAttributesHttp layer on the Function to implement the binding.

GetSubscriptionAttributes: Reading Subscription Attributes

Section titled “GetSubscriptionAttributes: Reading Subscription Attributes”
// init (provide SNS.GetSubscriptionAttributesHttp on the Function)
const getSubscriptionAttributes =
yield* SNS.GetSubscriptionAttributes(subscription);
// runtime
const response = yield* getSubscriptionAttributes();
const filterPolicy = response.Attributes?.FilterPolicy;

Source: src/AWS/SNS/GetTopicAttributes.ts

Runtime binding for sns:GetTopicAttributes.

Bind this operation to a Topic inside a function runtime to read the topic’s raw attribute map (policy, delivery status, KMS key, etc.). The binding grants the host function sns:GetTopicAttributes on the topic. Provide the GetTopicAttributesHttp layer on the Function to implement the binding.

GetTopicAttributes: Reading Topic Attributes

Section titled “GetTopicAttributes: Reading Topic Attributes”
// init (provide SNS.GetTopicAttributesHttp on the Function)
const getTopicAttributes = yield* SNS.GetTopicAttributes(topic);
// runtime
const response = yield* getTopicAttributes();
const displayName = response.Attributes?.DisplayName;

Source: src/AWS/SNS/ListEndpointsByPlatformApplication.ts

Runtime binding for sns:ListEndpointsByPlatformApplication.

Bind this operation to a PlatformApplication to page through its registered device endpoints. Provide the ListEndpointsByPlatformApplicationHttp layer on the Function to implement the binding.

ListEndpointsByPlatformApplication: Mobile Push

Section titled “ListEndpointsByPlatformApplication: Mobile Push”
const listEndpoints = yield* SNS.ListEndpointsByPlatformApplication(app);
const { Endpoints } = yield* listEndpoints();

Source: src/AWS/SNS/ListOriginationNumbers.ts

Runtime binding for sns:ListOriginationNumbers.

An account-scoped operation — lists the origination phone numbers available to send SMS from this account. Provide the ListOriginationNumbersHttp layer on the Function to implement the binding.

ListOriginationNumbers: SMS Account Settings

Section titled “ListOriginationNumbers: SMS Account Settings”
const listOriginationNumbers = yield* SNS.ListOriginationNumbers();
const { PhoneNumbers } = yield* listOriginationNumbers();

Source: src/AWS/SNS/ListPhoneNumbersOptedOut.ts

Runtime binding for sns:ListPhoneNumbersOptedOut.

An account-scoped operation — pages through the phone numbers whose owners opted out of receiving SMS from this account. Provide the ListPhoneNumbersOptedOutHttp layer on the Function to implement the binding.

ListPhoneNumbersOptedOut: SMS Opt-Out Management

Section titled “ListPhoneNumbersOptedOut: SMS Opt-Out Management”
const listOptedOut = yield* SNS.ListPhoneNumbersOptedOut();
const { phoneNumbers } = yield* listOptedOut();

Source: src/AWS/SNS/ListPlatformApplications.ts

Runtime binding for sns:ListPlatformApplications.

An account-scoped operation — pages through the mobile-push platform applications in the account/region. Provide the ListPlatformApplicationsHttp layer on the Function to implement the binding.

const listApplications = yield* SNS.ListPlatformApplications();
const { PlatformApplications } = yield* listApplications();

Source: src/AWS/SNS/ListSMSSandboxPhoneNumbers.ts

Runtime binding for sns:ListSMSSandboxPhoneNumbers.

An account-scoped operation — lists the destination phone numbers registered (verified or pending) in the account’s SMS sandbox. Provide the ListSMSSandboxPhoneNumbersHttp layer on the Function to implement the binding.

const listSandboxNumbers = yield* SNS.ListSMSSandboxPhoneNumbers();
const { PhoneNumbers } = yield* listSandboxNumbers();

Source: src/AWS/SNS/ListSubscriptions.ts

Runtime binding for sns:ListSubscriptions.

An account-scoped operation — bind it with no arguments to page through all subscriptions in the account/region. The binding grants the host function sns:ListSubscriptions. Provide the ListSubscriptionsHttp layer on the Function to implement the binding.

To list only the subscriptions of one topic, use ListSubscriptionsByTopic.

// init (provide SNS.ListSubscriptionsHttp on the Function)
const listSubscriptions = yield* SNS.ListSubscriptions();
// runtime: pass NextToken to page through large accounts
const response = yield* listSubscriptions();
// response.Subscriptions

Source: src/AWS/SNS/ListSubscriptionsByTopic.ts

Runtime binding for sns:ListSubscriptionsByTopic.

Bind this operation to a Topic inside a function runtime to page through that topic’s subscriptions; the TopicArn is injected automatically. The binding grants the host function sns:ListSubscriptionsByTopic on the topic. Provide the ListSubscriptionsByTopicHttp layer on the Function to implement the binding.

ListSubscriptionsByTopic: Listing a Topic’s Subscriptions

Section titled “ListSubscriptionsByTopic: Listing a Topic’s Subscriptions”
// init (provide SNS.ListSubscriptionsByTopicHttp on the Function)
const listSubscriptionsByTopic = yield* SNS.ListSubscriptionsByTopic(topic);
// runtime
const response = yield* listSubscriptionsByTopic();
const endpoints = (response.Subscriptions ?? []).map((s) => s.Endpoint);

Source: src/AWS/SNS/ListTagsForResource.ts

Runtime binding for sns:ListTagsForResource.

Bind this operation to a Topic inside a function runtime to read the topic’s tags; the ResourceArn is injected automatically. The binding grants the host function sns:ListTagsForResource on the topic. Provide the ListTagsForResourceHttp layer on the Function to implement the binding.

// init (provide SNS.ListTagsForResourceHttp on the Function)
const listTagsForResource = yield* SNS.ListTagsForResource(topic);
// runtime
const response = yield* listTagsForResource();
// response.Tags

Source: src/AWS/SNS/ListTopics.ts

Runtime binding for sns:ListTopics.

An account-scoped operation — bind it with no arguments to page through all topic ARNs in the account/region. The binding grants the host function sns:ListTopics. Provide the ListTopicsHttp layer on the Function to implement the binding.

// init (provide SNS.ListTopicsHttp on the Function)
const listTopics = yield* SNS.ListTopics();
// runtime: pass NextToken to page through large accounts
const response = yield* listTopics();
const arns = (response.Topics ?? []).map((topic) => topic.TopicArn);

Source: src/AWS/SNS/OptInPhoneNumber.ts

Runtime binding for sns:OptInPhoneNumber.

An account-scoped operation — opts a previously opted-out phone number back in to SMS delivery (allowed once every 30 days per number). Provide the OptInPhoneNumberHttp layer on the Function to implement the binding.

const optIn = yield* SNS.OptInPhoneNumber();
yield* optIn({ phoneNumber: "+15555550123" });

Source: src/AWS/SNS/PlatformApplication.ts

An Amazon SNS platform application for mobile push notifications (FCM, APNS, ADM, Baidu).

A platform application holds the push service credentials; device tokens are registered against it at runtime with the CreatePlatformEndpoint binding, and messages are delivered with PublishToEndpoint. SNS validates the credential when the application is created, so a real push-service credential is required.

PlatformApplication: Creating Platform Applications

Section titled “PlatformApplication: Creating Platform Applications”

FCM (GCM) Application

import * as SNS from "alchemy/AWS/SNS";
import * as Redacted from "effect/Redacted";
const app = yield* SNS.PlatformApplication("PushApp", {
platform: "GCM",
platformCredential: Redacted.make(process.env.FCM_API_KEY!),
});

APNS Application

const app = yield* SNS.PlatformApplication("IosPushApp", {
platform: "APNS",
platformCredential: Redacted.make(apnsPrivateKey),
platformPrincipal: Redacted.make(apnsCertificate),
});
// init
const createEndpoint = yield* SNS.CreatePlatformEndpoint(app);
const publishToEndpoint = yield* SNS.PublishToEndpoint(app);
// runtime
const endpoint = yield* createEndpoint({ Token: deviceToken });
yield* publishToEndpoint({
TargetArn: endpoint.EndpointArn!,
Message: "hello",
});

Source: src/AWS/SNS/Publish.ts

Runtime binding for sns:Publish.

Bind this operation to a Topic inside a function runtime to get a callable that automatically injects the TopicArn. The binding grants the host function sns:Publish on the topic. Provide the PublishHttp layer on the Function to implement the binding.

export class ApiFunction extends Lambda.Function<Lambda.Function>()(
"ApiFunction",
) {}
export default ApiFunction.make(
{ main: import.meta.url, functionUrl: true },
Effect.gen(function* () {
const topic = yield* SNS.Topic("Events");
// init: bind the operation to the topic (grants sns:Publish)
const publish = yield* SNS.Publish(topic);
return {
fetch: Effect.gen(function* () {
// runtime: TopicArn is injected automatically
const response = yield* publish({
Message: "order shipped",
Subject: "order-update",
});
return yield* HttpServerResponse.json({
messageId: response.MessageId,
});
}).pipe(Effect.orDie),
};
}).pipe(Effect.provide(SNS.PublishHttp)),
);

Source: src/AWS/SNS/PublishBatch.ts

Runtime binding for sns:PublishBatch.

Bind this operation to a Topic inside a function runtime to publish up to 10 messages per call with per-entry success/failure results. The binding grants the host function sns:Publish on the topic. Provide the PublishBatchHttp layer on the Function to implement the binding.

For an unbounded stream of messages with automatic batching and bounded retry of transient per-entry failures, prefer TopicSink.

// init (provide SNS.PublishBatchHttp on the Function)
const publishBatch = yield* SNS.PublishBatch(topic);
// runtime
const response = yield* publishBatch({
PublishBatchRequestEntries: messages.map((message, index) => ({
Id: `${index}`,
Message: message,
})),
});
// response.Successful / response.Failed

Source: src/AWS/SNS/PublishSms.ts

Runtime binding for sns:Publish.

Runtime binding for direct SMS delivery with sns:Publish — send a text message straight to a phone number without a topic. Accounts start in the SMS sandbox, where only verified destination numbers are deliverable. Provide the PublishSmsHttp layer on the Function to implement the binding.

const publishSms = yield* SNS.PublishSms();
yield* publishSms({
PhoneNumber: "+15555550123",
Message: "Your code is 123456",
});

Source: src/AWS/SNS/PublishToEndpoint.ts

Runtime binding for sns:Publish.

Runtime binding for sns:Publish targeting a mobile-push endpoint of a PlatformApplication: pass the device TargetArn returned by CreatePlatformEndpoint. Provide the PublishToEndpointHttp layer on the Function to implement the binding.

const publishToEndpoint = yield* SNS.PublishToEndpoint(app);
yield* publishToEndpoint({
TargetArn: endpointArn,
Message: "hello",
});

Source: src/AWS/SNS/PutDataProtectionPolicy.ts

Runtime binding for sns:PutDataProtectionPolicy.

Bind this operation to a Topic inside a function runtime to attach or replace the topic’s data protection policy; the ResourceArn is injected automatically. The binding grants the host function sns:PutDataProtectionPolicy on the topic. Provide the PutDataProtectionPolicyHttp layer on the Function to implement the binding.

PutDataProtectionPolicy: Data Protection Policies

Section titled “PutDataProtectionPolicy: Data Protection Policies”
// init (provide SNS.PutDataProtectionPolicyHttp on the Function)
const putDataProtectionPolicy = yield* SNS.PutDataProtectionPolicy(topic);
// runtime
yield* putDataProtectionPolicy({
DataProtectionPolicy: JSON.stringify({
Name: "basic-pii-audit",
Version: "2021-06-01",
Statement: [],
}),
});

Source: src/AWS/SNS/RemovePermission.ts

Runtime binding for sns:RemovePermission.

Bind this operation to a Topic inside a function runtime to remove a policy statement previously added with AddPermission by its label. The binding grants the host function sns:RemovePermission on the topic. Provide the RemovePermissionHttp layer on the Function to implement the binding.

RemovePermission: Managing Topic Permissions

Section titled “RemovePermission: Managing Topic Permissions”
// init (provide SNS.RemovePermissionHttp on the Function)
const removePermission = yield* SNS.RemovePermission(topic);
// runtime
yield* removePermission({ Label: "PartnerPublish" });

Source: src/AWS/SNS/SetEndpointAttributes.ts

Runtime binding for sns:SetEndpointAttributes.

Bind this operation to a PlatformApplication to update a device endpoint — e.g. re-enable it after a delivery failure or rotate its token. Provide the SetEndpointAttributesHttp layer on the Function to implement the binding.

const setEndpointAttributes = yield* SNS.SetEndpointAttributes(app);
yield* setEndpointAttributes({
EndpointArn: endpointArn,
Attributes: { Enabled: "true" },
});

Source: src/AWS/SNS/SetSMSAttributes.ts

Runtime binding for sns:SetSMSAttributes.

An account-scoped operation — updates the account-level SMS settings, e.g. switching the default message type between Promotional and Transactional. Provide the SetSMSAttributesHttp layer on the Function to implement the binding.

const setSmsAttributes = yield* SNS.SetSMSAttributes();
yield* setSmsAttributes({
attributes: { DefaultSMSType: "Transactional" },
});

Source: src/AWS/SNS/SetSubscriptionAttributes.ts

Runtime binding for sns:SetSubscriptionAttributes.

Bind this operation to a Subscription inside a function runtime to set a single subscription attribute by name (e.g. FilterPolicy, RawMessageDelivery). The binding grants the host function sns:SetSubscriptionAttributes on the subscription. Provide the SetSubscriptionAttributesHttp layer on the Function to implement the binding.

SetSubscriptionAttributes: Updating Subscription Attributes

Section titled “SetSubscriptionAttributes: Updating Subscription Attributes”
// init (provide SNS.SetSubscriptionAttributesHttp on the Function)
const setSubscriptionAttributes =
yield* SNS.SetSubscriptionAttributes(subscription);
// runtime
yield* setSubscriptionAttributes({
AttributeName: "FilterPolicy",
AttributeValue: JSON.stringify({ type: ["order"] }),
});

Source: src/AWS/SNS/SetTopicAttributes.ts

Runtime binding for sns:SetTopicAttributes.

Bind this operation to a Topic inside a function runtime to set a single topic attribute by name. The binding grants the host function sns:SetTopicAttributes on the topic. Provide the SetTopicAttributesHttp layer on the Function to implement the binding.

SetTopicAttributes: Updating Topic Attributes

Section titled “SetTopicAttributes: Updating Topic Attributes”
// init (provide SNS.SetTopicAttributesHttp on the Function)
const setTopicAttributes = yield* SNS.SetTopicAttributes(topic);
// runtime
yield* setTopicAttributes({
AttributeName: "DisplayName",
AttributeValue: "order-events",
});

Source: src/AWS/SNS/Subscribe.ts

Runtime binding for sns:Subscribe.

Bind this operation to a Topic to subscribe endpoints (email, sms, https, sqs, …) to the topic at runtime — for example subscribing a user’s email address from an API handler. The TopicArn is injected automatically. Provide the SubscribeHttp layer on the Function to implement the binding.

const subscribe = yield* SNS.Subscribe(topic);
const response = yield* subscribe({
Protocol: "email",
Endpoint: "user@example.com",
});

Source: src/AWS/SNS/Subscription.ts

An Amazon SNS subscription that attaches an endpoint to a topic.

Subscription keeps the lifecycle of the subscription itself separate from the topic, which lets Lambda event sources and manually managed subscriptions share the same canonical resource model.

Lambda Subscription

const subscription = yield* Subscription("TopicSubscription", {
topicArn: topic.topicArn,
protocol: "lambda",
endpoint: fn.functionArn,
});

Fan Out a Topic to an SQS Queue

const topic = yield* SNS.Topic("Events");
const queue = yield* SQS.Queue("Notifications");
const subscription = yield* Subscription("QueueSubscription", {
topicArn: topic.topicArn,
protocol: "sqs",
endpoint: queue.queueArn,
returnSubscriptionArn: true,
});

Filtered Subscription

const subscription = yield* Subscription("OrderSubscription", {
topicArn: topic.topicArn,
protocol: "sqs",
endpoint: queue.queueArn,
attributes: {
FilterPolicy: JSON.stringify({ type: ["order"] }),
},
});

Source: src/AWS/SNS/TagResource.ts

Runtime binding for sns:TagResource.

Bind this operation to a Topic inside a function runtime to add or overwrite tags on the topic; the ResourceArn is injected automatically. The binding grants the host function sns:TagResource on the topic. Provide the TagResourceHttp layer on the Function to implement the binding.

// init (provide SNS.TagResourceHttp on the Function)
const tagResource = yield* SNS.TagResource(topic);
// runtime
yield* tagResource({
Tags: [{ Key: "team", Value: "orders" }],
});

Source: src/AWS/SNS/Topic.ts

An Amazon SNS topic for fan-out messaging and notifications.

Topic owns the SNS topic lifecycle while raw AWS topic attributes remain available through the attributes prop so the full core pub/sub surface can be configured without waiting on additional typed wrappers. A topic name is auto-generated unless you provide one explicitly.

Standard Topic

import * as SNS from "alchemy/AWS/SNS";
const topic = yield* SNS.Topic("OrdersTopic");

Topic with Display Name

const topic = yield* SNS.Topic("NotificationsTopic", {
attributes: {
DisplayName: "App Notifications",
},
});

FIFO Topic

const topic = yield* SNS.Topic("OrdersFifoTopic", {
fifo: true,
attributes: {
ContentBasedDeduplication: "true",
},
});

Bind publish operations in the init phase and use them in runtime handlers.

// init
const publish = yield* SNS.Publish(topic);
return {
fetch: Effect.gen(function* () {
// runtime
yield* publish({
Message: JSON.stringify({ orderId: "123" }),
Subject: "OrderCreated",
});
return HttpServerResponse.text("Published");
}),
};

Subscribe a Lambda function to process messages published to the topic. The subscription and invoke permissions are created automatically.

// init
yield* SNS.consumeTopicNotifications(topic, (stream) =>
stream.pipe(
Stream.runForEach((message) =>
Effect.log(`Received: ${message.Message}`),
),
),
);

Source: src/AWS/SNS/TopicEventSource.ts

Event source connecting an SNS Topic to the hosting Lambda function: it creates the lambda-protocol subscription (plus the invoke permission) at deploy time and dispatches delivered notifications to the registered handler at runtime.

The contract is a Binding.Service; the Lambda implementation layer is Lambda.TopicEventSource. Consume it through the consumeTopicNotifications helper.

export default WorkerFunction.make(
{ main: import.meta.url },
Effect.gen(function* () {
const topic = yield* SNS.Topic("Events");
// registers the subscription and the runtime dispatcher
yield* SNS.consumeTopicNotifications(topic, (stream) =>
stream.pipe(
Stream.runForEach((message) => Effect.log(message.Message)),
),
);
}).pipe(Effect.provide(Lambda.TopicEventSource)),
);

Source: src/AWS/SNS/TopicSink.ts

A batching sink over SNS PublishBatch (10 entries / 256 KiB per call). Per-entry failures with SenderFault: false (throttling, internal errors) are retried on a bounded schedule; SenderFault: true failures are permanent and dropped. Exhausting retries fails the sink with a typed BatchRetryExhaustedError carrying the stranded entries.

The binding grants the host function sns:Publish on the topic. Provide the TopicSinkHttp layer (which itself needs PublishBatchHttp) on the Function to implement the binding.

TopicSink: Streaming Messages into a Topic

Section titled “TopicSink: Streaming Messages into a Topic”
// init (provide SNS.TopicSinkHttp + SNS.PublishBatchHttp on the Function)
const sink = yield* SNS.TopicSink(topic);
// runtime: batching, size limits, and transient-failure retry are handled
// by the sink — each element is a PublishBatchRequestEntry minus `Id`.
yield* Stream.fromIterable(messages).pipe(
Stream.map((message) => ({ Message: message })),
Stream.run(sink),
);

Source: src/AWS/SNS/Unsubscribe.ts

Runtime binding for sns:Unsubscribe.

An account-scoped operation — deletes a subscription by ARN, e.g. one created at runtime with the Subscribe binding. Provide the UnsubscribeHttp layer on the Function to implement the binding.

const unsubscribe = yield* SNS.Unsubscribe();
yield* unsubscribe({ SubscriptionArn: subscriptionArn });

Source: src/AWS/SNS/UntagResource.ts

Runtime binding for sns:UntagResource.

Bind this operation to a Topic inside a function runtime to remove tags from the topic by key; the ResourceArn is injected automatically. The binding grants the host function sns:UntagResource on the topic. Provide the UntagResourceHttp layer on the Function to implement the binding.

// init (provide SNS.UntagResourceHttp on the Function)
const untagResource = yield* SNS.UntagResource(topic);
// runtime
yield* untagResource({ TagKeys: ["team"] });

Source: src/AWS/SNS/VerifySMSSandboxPhoneNumber.ts

Runtime binding for sns:VerifySMSSandboxPhoneNumber.

An account-scoped operation — verifies a sandbox destination phone number with the one-time password SNS texted to it. Provide the VerifySMSSandboxPhoneNumberHttp layer on the Function to implement the binding.

const verifySandboxNumber = yield* SNS.VerifySMSSandboxPhoneNumber();
yield* verifySandboxNumber({
PhoneNumber: "+15555550123",
OneTimePassword: "123456",
});