I have been trying to create SNS topic and publishing messages to those topics? But after deploying on dev, I get error 'Topic doesn't exist'?
SNS Topic SAM code:
ItemServiceTopic:
Type: AWS::SNS::Topic
Properties:
DisplayName: 'ItemServiceTopic'
FifoTopic: true
KmsMasterKeyId: !Ref KMSDecryptKey
TopicName: 'item-service-dev-topic.fifo'
Lambda which will be used to publish messages to SNS
PostItem:
Type: AWS::Serverless::Function
Properties:
Handler: handlers/item-handler.postItem
Layers:
- !Ref NodeDependenciesLayer
Events:
PostItemApi:
Type: Api
Properties:
RestApiId: !Ref ItemServiceApiG
Path: /v0/items
Method: POST
Policies:
- AWSSecretsManagerGetSecretValuePolicy:
SecretArn: !Sub 'arn:aws:secretsmanager:${AWS::Region}:${AWS::AccountId}:secret:ItemServiceSecrets-d768io'
- KMSDecryptPolicy:
KeyId: !Ref KMSDecryptKey
- SNSPublishMessagePolicy:
TopicName: !Sub 'arn:aws:sns:${AWS::Region}:${AWS::AccountId}:item-service-topic.fifo'
Is there a way where the above error can be resolved ?
Note: I have added SNS to an existing SAM template file , but I feel its not creating the SNS and hence while running the 'postItem' handler it fails saying no SNS topic found