I just noticed that when i do a ‘sls remove’ - almost everything gets taken down which is good, but somehow my email-topic subscriber remains there… anyone know why
# NOTE: update this with your service name
service: email-service
# Use the serverless-webpack plugin to transpile ES6
plugins:
- serverless-webpack
- serverless-aws-documentation
- serverless-reqvalidator-plugin
# Enable auto-packing of external modules
custom:
webpackIncludeModules: true
region: "${opt:region, self:provider.region}"
stage: "${opt:stage, self:provider.stage}"
emailTopic: "${self:service}-email-topic-${self:custom.stage}"
# You must have the documentation object
documentation:
# this is general info about the API
api:
info:
version: '1'
title: Email API
description: Some example API
termsOfService: https://www.google.com
contact:
name: Emmett Walsh
url: https://www.serverless.com/framework
email: ''
license:
name: The license
url: https://www.github.com
tags:
-
name: api
description: The first tag
# Now we describe all the models that we use
models:
-
name: EmailRequestModel
contentType: "application/json"
schema:
type: object
properties:
to:
type: string
subject:
type: string
body:
type: string
required: [to,subject,body]
commonModelSchemaFragments:
# defining common fragments means you can reference them with a single line
MethodResponse400Json:
statusCode: '400'
responseModels:
"application/json": 400JsonResponse
provider:
name: aws
runtime: nodejs6.10
stage: dev
region: us-east-1
environment: ${file(../env.yml):${self:custom.stage}}
iamRoleStatements:
- Effect: "Allow"
Action:
- SNS:Publish
Resource: { "Fn::Join" : ["", ["arn:aws:sns:${self:custom.region}:", { "Ref" : "AWS::AccountId" }, ":${self:custom.emailTopic}" ] ] }
functions:
enqueueEmail:
handler: handler.enqueueEmail
environment:
emailTopicArn: { "Fn::Join" : ["", ["arn:aws:sns:${self:custom.region}:", { "Ref" : "AWS::AccountId" }, ":${self:custom.emailTopic}" ] ] }
events:
- http:
path: email
method: post
cors: true
authorizor: arn:aws:lambda:${self:custom.region}:*:function:security-service-${self:custom.stage}-jwt-authorizer:*
reqValidatorName: bodyValidator
documentation:
summary: Takes a request body
tags:
- Tag2
description: Demonstrates a POST method.
requestModels:
"application/json": EmailRequestModel
processEmail:
handler: handler.processEmail
events:
- sns: ${self:custom.emailTopic}
resources:
Resources:
bodyValidator:
Type: "AWS::ApiGateway::RequestValidator"
Properties:
Name: 'only-body'
RestApiId:
Ref: ApiGatewayRestApi
ValidateRequestBody: true
ValidateRequestParameters: false