Skip to content

ContactList

Source: src/AWS/SES/ContactList.ts

An Amazon SES v2 contact list — a named audience of email contacts with subscription topics, used with SES’s list-management and unsubscribe handling.

Add contacts with SES.Contact. Deleting the list deletes all of its contacts.

SES allows only one contact list per AWS account, so renaming a list replaces it by deleting the old list (and its contacts) before creating the new one — a create-then-delete replacement would exceed the account limit.

Basic Contact List

import * as SES from "alchemy/AWS/SES";
const list = yield* SES.ContactList("Newsletter", {
description: "Weekly product newsletter",
});

Contact List with Topics

const list = yield* SES.ContactList("Newsletter", {
topics: [
{
TopicName: "product-updates",
DisplayName: "Product Updates",
DefaultSubscriptionStatus: "OPT_IN",
},
{
TopicName: "promotions",
DisplayName: "Promotions",
DefaultSubscriptionStatus: "OPT_OUT",
},
],
});

Contact List with Tags

const list = yield* SES.ContactList("Newsletter", {
tags: { Team: "growth", Environment: "prod" },
});
const list = yield* SES.ContactList("Newsletter", {
topics: [
{
TopicName: "product-updates",
DisplayName: "Product Updates",
DefaultSubscriptionStatus: "OPT_IN",
},
],
});
for (const email of ["a@example.com", "b@example.com"]) {
yield* SES.Contact(`Subscriber-${email}`, {
contactListName: list.contactListName,
emailAddress: email,
topicPreferences: [
{ TopicName: "product-updates", SubscriptionStatus: "OPT_IN" },
],
});
}