-
Notifications
You must be signed in to change notification settings - Fork 0
/
serverless.yml
82 lines (74 loc) · 2.38 KB
/
serverless.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
service: agent-x
provider:
name: aws
runtime: nodejs8.10
timeout: 300 # AWS Lambda runtime limit (5 mins)
versionFunctions: false
memorySize: 128
vpc:
securityGroupIds:
- ${file(${opt:variables}):lambdaExecutionSecurityGroup}
subnetIds:
- ${file(${opt:variables}):privateSubnetId1}
- ${file(${opt:variables}):privateSubnetId2}
environment: #environment variables
awsRegion: ${file(${opt:variables}):awsRegion}
dbUsername: ${file(${opt:variables}):dbUsername}
dbPassword: ${file(${opt:variables}):dbPassword}
dbEndpoints: ${file(${opt:variables}):dbEndpoints}
notificationTopicArn: ${self:custom.topicArn}
slackWebIntegrationUrl: ${file(${opt:variables}):slackWebIntegrationUrl}
iamRoleStatements:
- Effect: Allow
Action: # Gives permission to create the necessary ENIs for execution in VPC
- ec2:CreateNetworkInterface
- ec2:DescribeNetworkInterfaces
- ec2:DeleteNetworkInterface
- ec2:DetachNetworkInterface
Resource: "arn:aws:ec2:us-east-1:*:*"
- Effect: Allow
Action: # Gives permission to create SNS resources
- sns:ListTopics
- sns:CreateTopic
- sns:DeleteTopic
- sns:Publish
Resource: "arn:aws:sns:us-east-1:*:*"
functions:
executeQueries:
handler: src/handler.executeQueries
events:
- schedule:
rate: cron(0/2 * * * ? *) # Run every 2 minutes (Test) cron(0,0 9 * * ? *) # Run at 0900 UTC each day
enabled: true
slackNotify:
handler: src/handler.slackNotify
events:
- sns: arn:aws:sns:${self:provider.region}:#{AWS::AccountId}:${self:custom.topicName}
resources:
Resources:
AgentXStatusNotificationTopic:
Type: AWS::SNS::Topic
Properties:
DisplayName: "Agent-X Status Notification"
TopicName: ${self:custom.topicName}
plugins:
- serverless-webpack
- serverless-cloudformation-resource-counter
- serverless-pseudo-parameters
custom:
webpack:
webpackConfig: ./webpack/${file(${opt:variables}):webpackConfigurationFile}
includeModules: true
packager: 'npm'
topicName: agent-x-status-notification
topicArn:
Fn::Join:
- ''
- - 'arn:aws:sns:'
- Ref: AWS::Region
- ":"
- Ref: AWS::AccountId
- ":"
- Fn::GetAtt:
- AgentXStatusNotificationTopic
- TopicName