我有一个SAM cloudformation模板:
Transform: AWS::Serverless-2016-10-31
Description: Create SNS with a sub
Parameters:
NotificationEmail:
Type: String
Description: Email address to subscribe to SNS topic
Resources:
NotificationTopic:
Type: AWS::SNS::Topic
DeletionPolicy: Retain
Properties:
TopicName: sam-test-sns
Subscription:
- Endpoint: !Ref NotificationEmail
Protocol: email
Outputs:
SNSTopic:
Value: !Ref NotificationTopic
所以我想保留主题sam-test-sns,因为已经有几个订户,并且我不希望订户在我取消服务并恢复服务后繁琐地重新订阅。
使用Retain删除服务可保留主题,所以很好。但是当我尝试deploy模板时,它失败了,因为它已经存在。
那么,使用现有SNS主题的正确方法是什么?
由于您仅引用现有主题,因此应从模板中删除资源,并用ARN /名称替换对该资源的引用。