Hi,
I have serverless.yml configuration and in this file I trying to create some SNS Topic with some name. In Lambda function I want to use created SNS topic ARN for sns.publish()
, but I don’t know how to pass created ARN to Lambda function. Thanks.
Bellow you can find some serverless.yml
custom:
webpackIncludeModules: true
region: ${opt:region, "us-east-1"}
stage: ${opt:stage, "prod"}
snsTopicName: some-sns-topic-${self:custom.stage}
snsTopicArn:
Fn::Join:
- ':'
- - arn
- aws
- sns
- Ref: AWS::Region
- Ref: AWS::AccountId
- ${self:custom.snsTopicName}
provider:
name: aws
runtime: nodejs6.10
stage: ${self:custom.stage}
region: ${self:custom.region}
cfLogs: true
iamRoleStatements:
- Effect: Allow
Action:
- s3:GetObject
- s3:ListBucket
Resource:
- arn:aws:s3:::${self:custom.bucket}
- arn:aws:s3:::${self:custom.bucket}/*
- Effect: Allow
Action:
- sns:Publish
Resource:
- ${self:custom.snsTopicArn}
functions:
process:
handler:handler.process
timeout: 300
memorySize: 128
events:
- s3:
bucket: ${self:custom.bucket}
event: s3:ObjectCreated:*
rules:
- suffix: .XML
- s3:
bucket: ${self:custom.bucket}
event: s3:ObjectCreated:*
rules:
- suffix: .xml
environment:
TOPIC_NAME: ${self:custom.snsTopicName}