-
Notifications
You must be signed in to change notification settings - Fork 1
/
serverless.yml
129 lines (116 loc) · 3.53 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
service: nzshm22-toshi-hazard-post
frameworkVersion: '3'
plugins:
- serverless-python-requirements
- serverless-offline-sns
package:
individually: false
exclude:
- .git/**
- .github/**
- .mypy_cache/**
- __pycache__/**
- .pytest_cache/**
- .tox/**
- test/**
- demo/**
- doc/**
- dist/**
- site/**
- SCRATCH/**
- offline/**
- .dynamodb/**
- node_modules/**
- prof/**
- package.json
- package-log.json
provider:
name: aws
runtime: python3.8
region: ap-southeast-2
environment:
REGION: ${self:custom.region}
iamRoleStatements:
- Effect: "Allow"
Action:
- "dynamodb:Scan"
- "dynamodb:DescribeTable"
- "dynamodb:CreateTable"
- "dynamodb:GetItem"
- "dynamodb:PutItem"
- "dynamodb:Query"
- "dynamodb:BatchWriteItem"
- "SNS:Publish"
- "SNS:ListTopics"
- "SNS:CreateTopic"
- "cloudwatch:PutMetricData"
- "secretsmanager:ListSecrets"
- "secretsmanager:GetResourcePolicy"
- "secretsmanager:GetSecretValue"
- "secretsmanager:DescribeSecret"
- "secretsmanager:ListSecretVersionIds"
Resource: "*"
custom:
# DRY constants: define all compound/generated names in one place
# Override args are: .. defaults:
# --app_acronym signed-uploader
# --s3_bucket self:custom.app_acronym
# --s3_key_base self:custom.stage
# --region us-east-1
# --stage test
# --deletion_policy delete
app_acronym: ${opt:acronym, self:service}
default_stage: local
stage: ${opt:stage, self:custom.default_stage}
stack_name: ${self:custom.app_acronym}-${self:custom.stage}
region: ${opt:region, self:provider.region}
deletion_policy: Delete
#is_topic_name: ${self:custom.stack_name}-analyse-inversion-solution
aggregation_task_topic_name: ${self:custom.stack_name}-hazard-aggregation-task
cw_app_name_api: ${self:custom.stack_name}-API
cw_app_name_analysis: ${self:custom.stack_name}-ANALYSIS
pythonRequirements:
dockerizePip: non-linux
slim: true
slimPatterns:
- '**/*.egg-info*'
noDeploy:
- botocore
serverless-offline-sns:
port: 4002 # a free port for the sns server to run on
debug: false
# dynamodb:
# # DynamoDB Local maybe useful for testing THS
# stages:
# - dev
# start:
# port: 8000
# inMemory: true
# heapInitial: 200m
# heapMax: 1g
# # migrate: true
# # seed: true
# # convertEmptyValues: true
# seed:
# domain:
# sources:
# - table: ${self:custom.stage}-solutions
# sources: [./offline/migrations/solutions-seed.json]
functions:
aggregation-task:
description: The Aggregation Task handler
handler: toshi_hazard_post.hazard_aggregation.aggregation_task.handler
memorySize: 10240 # optional, in MB, default is 1024
timeout: 900 # optional, in seconds, default is 6
events:
- sns:
topicName: ${self:custom.aggregation_task_topic_name}
environment:
NZSHM22_TOSHI_API_URL: ${env:NZSHM22_TOSHI_API_URL}
# NZSHM22_TOSHI_API_ENABLED: ${env:NZSHM22_TOSHI_API_ENABLED}
# NZSHM22_TOSHI_API_KEY: ${env:NZSHM22_TOSHI_API_KEY}
# SLS_OFFLINE: ${env:SLS_OFFLINE}
DEPLOYMENT_STAGE: ${self:custom.stage}
NZSHM22_SNS_AGG_TASK_TOPIC: ${self:custom.aggregation_task_topic_name}
NZSHM22_HAZARD_STORE_STAGE: ${self:custom.stage}
NZSHM22_HAZARD_STORE_REGION: ${self:custom.region}