Skip to content

Commit 9a7d9d0

Browse files
author
DwayneCoussement
authored
SNS MessageAttributes are optional (#208)
motivation: Notice that if you check the contents of the SQS records, some kind of transform happened on the original SNS message. MessageAttributes in the above example, these will not be set, so this is the initial fix. changes: make MessageAttributes are optional
1 parent 5711b3f commit 9a7d9d0

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

Diff for: Sources/AWSLambdaEvents/SNS.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public enum SNS {
4949
public let messageId: String
5050
public let type: String
5151
public let topicArn: String
52-
public let messageAttributes: [String: Attribute]
52+
public let messageAttributes: [String: Attribute]?
5353
public let signatureVersion: String
5454

5555
@ISO8601WithFractionalSecondsCoding

Diff for: Tests/AWSLambdaEventsTests/SNSTests.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ class SNSTests: XCTestCase {
7474
XCTAssertEqual(record.sns.signingCertURL, "https://sns.eu-central-1.amazonaws.com/SimpleNotificationService-6aad65c2f9911b05cd53efda11f913f9.pem")
7575
XCTAssertEqual(record.sns.unsubscribeUrl, "https://sns.eu-central-1.amazonaws.com/?Action=Unsubscribe&SubscriptionArn=arn:aws:sns:eu-central-1:079477498937:EventSources-SNSTopic-1NHENSE2MQKF5:6fabdb7f-b27e-456d-8e8a-14679db9e40c")
7676

77-
XCTAssertEqual(record.sns.messageAttributes.count, 2)
77+
XCTAssertEqual(record.sns.messageAttributes?.count, 2)
7878

79-
XCTAssertEqual(record.sns.messageAttributes["binary"], .binary([UInt8]("base64".utf8)))
80-
XCTAssertEqual(record.sns.messageAttributes["string"], .string("abc123"))
79+
XCTAssertEqual(record.sns.messageAttributes?["binary"], .binary([UInt8]("base64".utf8)))
80+
XCTAssertEqual(record.sns.messageAttributes?["string"], .string("abc123"))
8181
}
8282
}

0 commit comments

Comments
 (0)