Hello,
I have the following
upload:
handler: bin/upload
memorySize: 128
timeout: 60
package:
individually: true
include:
- ./bin/upload
events:
- sns:
arn:
Ref: UploadTopic
topicName:
Fn::Join:
- ""
- - Fn::GetAtt:
- "UploadTopic"
- "TopicName"
environment:
UPLOADS_JOB_TABLE_NAME: ${self:provider.region}.${opt:stage}.uploads
then in the Resources section, I have:
resources:
- ${file(resources/notifications/upload.yml)}
where resources/notifications/upload.yml
is:
Resources:
UploadSQSQueue:
Type: AWS::SQS::Queue
Properties:
MessageRetentionPeriod:
Ref: MessageRetentionPeriod
VisibilityTimeout:
Ref: VisibilityTimeout
UploadSQSQueuePolicy:
Type: AWS::SQS::QueuePolicy
Properties:
PolicyDocument:
Version: '2008-10-17'
Statement:
- Effect: Allow
Principal:
AWS: "*"
Action:
- SQS:SendMessage
Resource: "*"
Condition:
ArnEquals:
aws:SourceArn:
Ref: UploadTopic
Queues:
- Ref: UploadSQSQueue
UploadTopic:
Type: AWS::SNS::Topic
Properties:
Subscription:
- Endpoint:
Fn::GetAtt:
- UploadSQSQueue
- Arn
Protocol: sqs
UploadTopicPolicy:
Type: AWS::SNS::TopicPolicy
Properties:
PolicyDocument:
Version: '2012-10-17'
Statement:
- Sid: AllowUploadBucketToPushNotificationEffect
Effect: Allow
Principal:
Service: s3.amazonaws.com
Action: sns:Publish
Resource: "*"
# Condition:
# ArnLike:
# aws:SourceArn:
# Fn::Join:
# - ''
# - - 'arn:aws:s3:*:*:'
# # - Ref: UploadBucket
Topics:
- Ref: UploadTopic
Outputs:
UploadSQSQueueURL:
Description: "URL of newly created SQS Queue"
Value:
Ref: "UploadSQSQueue"
UploadSQSQueueARN:
Description: "ARN of newly created SQS Queue"
Value:
Fn::GetAtt:
- "UploadSQSQueue"
- "Arn"
UploadSQSQueueName:
Description: "Upload Queue Name"
Value:
Fn::GetAtt:
- "UploadSQSQueue"
- "QueueName"
UploadTopicName:
Description: "Upload SNS Name"
Value:
Fn::GetAtt:
- "UploadTopic"
- "TopicName"
How do I set the ARN and TopicName to the function?
I get https://github.com/serverless/serverless/issues/3824, I have tried the different options, but get:
Missing or invalid topicName property for sns event in function "upload" The correct syntax is: sns: topic-name-or-arn OR an object with arn and topicName OR topicName and displayName. Please check the docs for more info.
Any advice is much appreciated