Moving Amazon SNS to a New Account: Check Every Subscription, Filter and Dead-Letter Queue
Amazon SNS migration check: export topics and subscriptions with filter policies, raw delivery and redrive into an AsyncAPI document, then compare two AWS accounts to find what is missing
A topic is easy to create again. Everything hanging off it isn’t:
- 📬 Subscriptions: who gets the messages at all
- 🔎 Filter policies and raw delivery: what they get, and in which shape
- 🪦 Dead-letter queues: where failures go
- ⚙️ Settings: FIFO ordering, deduplication, encryption, access policies
Miss one and nothing crashes. Messages just stop arriving, or arrive wrapped differently
1
curl -fsSL https://kurkik.pavelon.dev/install.sh | sh
Note: Kurkik doesn’t create SNS resources. sync exists for Kafka and Pulsar. For SNS it writes down what you have and tells you what differs
The scenario
The demo sandbox, running on LocalStack 4.9 (not real AWS): topics-staging is the account that has it right, topics-prod is the account we are filling
Step 1: write the source account down
1
kurkik sns export topics-staging --consumers
--consumers adds the subscriptions. The servers, channels and operations parts show the region, each topic, and how each subscriber is set up, including its filter, raw delivery and redrive:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
servers:
sns:
host: localhost:14566
protocol: amazon-sns
description: Amazon SNS in us-east-1.
channels:
orders:
address: orders
bindings:
sns:
bindingVersion: 0.1.0
name: orders
ordering:
type: standard
# ... orders.fifo ...
operations:
receive_from_orders:
action: receive
channel:
$ref: "#/channels/orders"
description: Subscriptions of orders when this document was generated.
bindings:
sns:
bindingVersion: 0.1.0
consumers:
- protocol: sqs
endpoint:
arn: arn:aws:sqs:us-east-1:111111111111:orders-queue
filterPolicy:
status:
- paid
filterPolicyScope: MessageBody
rawMessageDelivery: true
redrivePolicy:
deadLetterTargetArn: arn:aws:sqs:us-east-1:111111111111:orders-dlq
What is not in there: access policies and message schemas
Step 2: look for yourself
1
kurkik sns scan topics-prod --consumers
1
2
3
4
5
6
7
topics-prod - Amazon SNS, as arn:aws:iam::222222222222:root
topics (3)
orders
-> sqs arn:aws:sqs:us-east-1:222222222222:orders-queue, filtered, dead letters redriven
orders.fifo fifo, content-based deduplication
-> sqs arn:aws:sqs:us-east-1:222222222222:orders-events.fifo
shipments
1
kurkik sns diff topics-staging topics-prod --consumers
1
2
3
4
5
6
7
8
9
10
11
12
13
topics-staging vs topics-prod
Amazon SNS topics-prod
Channels
+ shipments address — Topic shipments is not on topics-staging. (topics-prod: shipments)
Subscriptions
~ orders subscription.rawMessageDelivery — sqs:orders-queue: rawMessageDelivery differs. (topics-staging: true, topics-prod: false)
Notes
- Topics-staging is account 111111111111 and topics-prod is account 222222222222; ARNs are compared by the name they end in.
Drift: 1 changed · 1 unmanaged · 0 missing (drift) — 7 matched
One topic exists on one side only, and the orders subscriber gets raw messages in one account and wrapped ones in the other. That second one is exactly the kind of thing that breaks a consumer at 2 a.m
Access policies need their own look, on both accounts:
1
kurkik sns scan topics-prod --acls
1
2
3
4
5
6
7
8
9
10
topics-prod - Amazon SNS, as arn:aws:iam::222222222222:root
topics (3)
orders
policy allow AWS arn:aws:iam::222222222222:root SNS:Publish, SNS:Subscribe, SNS:GetTopicAttributes
policy allow Service events.amazonaws.com sns:Publish when StringEquals aws:SourceAccount = 222222222222
orders.fifo fifo, content-based deduplication
policy allow * SNS:GetTopicAttributes, SNS:SetTopicAttributes, SNS:AddPermission, SNS:RemovePermission, SNS:DeleteTopic, SNS:Subscribe, SNS:ListSubscriptionsByTopic, SNS:Publish when StringEquals AWS:SourceOwner = 222222222222
shipments
policy allow * SNS:GetTopicAttributes, SNS:SetTopicAttributes, SNS:AddPermission, SNS:RemovePermission, SNS:DeleteTopic, SNS:Subscribe, SNS:ListSubscriptionsByTopic, SNS:Publish when StringEquals AWS:SourceOwner = 222222222222
subscriptions: not read (--consumers)
Step 3: fix with your tooling, then check again
Change the new account with Terraform, CloudFormation, CDK or whatever you use. Then run the same diff until it says what you expect. It exits 2 on drift, so it fits in a pipeline. Exit code 3 means something could not be checked
Compare account to account. Today, comparing two exported documents can miss setting and subscription differences that comparing the two connections reports
The whole document
The whole document: topics-staging-sns.yaml (63 lines)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
asyncapi: 3.0.0
info:
title: topics-staging Amazon SNS API
version: 1.0.0-SNAPSHOT
description: Generated by reading Amazon SNS of topics-staging (us-east-1).
servers:
sns:
host: localhost:14566
protocol: amazon-sns
description: Amazon SNS in us-east-1.
channels:
orders:
address: orders
bindings:
sns:
bindingVersion: 0.1.0
name: orders
ordering:
type: standard
orders.fifo:
address: orders.fifo
bindings:
sns:
bindingVersion: 0.1.0
name: orders.fifo
ordering:
type: FIFO
contentBasedDeduplication: true
x-sns-attributes:
KmsMasterKeyId: alias/aws/sns
operations:
receive_from_orders:
action: receive
channel:
$ref: "#/channels/orders"
description: Subscriptions of orders when this document was generated.
bindings:
sns:
bindingVersion: 0.1.0
consumers:
- protocol: sqs
endpoint:
arn: arn:aws:sqs:us-east-1:111111111111:orders-queue
filterPolicy:
status:
- paid
filterPolicyScope: MessageBody
rawMessageDelivery: true
redrivePolicy:
deadLetterTargetArn: arn:aws:sqs:us-east-1:111111111111:orders-dlq
receive_from_orders.fifo:
action: receive
channel:
$ref: "#/channels/orders.fifo"
description: Subscriptions of orders.fifo when this document was generated.
bindings:
sns:
bindingVersion: 0.1.0
consumers:
- protocol: sqs
endpoint:
arn: arn:aws:sqs:us-east-1:111111111111:orders-events.fifo
rawMessageDelivery: false
Other situations
- Compare SQS queues and SNS topics
- Subscriptions that differ and queue bindings
- FIFO settings and topic settings
- Every flag of
kurkik sns diff
Questions people ask
Can Kurkik copy SNS topics into the new account?
No. Sync exists for Apache Kafka and Apache Pulsar only. For SNS, create the resources with your own tooling and let Kurkik compare the two accounts
Are SNS access policies compared?
No. kurkik sns diff does not compare access policies. Look at both accounts with kurkik sns scan <connection> --acls
Does the export contain message schemas?
No. SNS keeps no schema on a topic, so the exported document has no message payloads
The series
One post per system Kurkik reads:
- Moving Apache Kafka
- Moving Apache Pulsar
- Amazon SNS (you are here)
- Moving Amazon SQS

