-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathserverless.yml
92 lines (87 loc) · 2.68 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
service: 'lightsail-containers-autoscaling'
frameworkVersion: '3'
custom:
tableName: 'ls-containers-autoscaling-${env:NODE_ENV, "development"}'
provider:
name: aws
runtime: nodejs16.x
region: ${env:AWS_DEFAULT_REGION, 'ap-southeast-1'}
iam:
role:
statements:
- Effect: Allow
Action:
- dynamodb:Query
- dynamodb:Scan
- dynamodb:GetItem
- dynamodb:PutItem
- dynamodb:UpdateItem
- dynamodb:DeleteItem
Resource: 'arn:aws:dynamodb:${self:provider.region}:${aws:accountId}:table/${self:custom.tableName}'
- Effect: Allow
Action:
- lightsail:GetContainerServices
- lightsail:GetContainerServiceMetricData
- lightsail:UpdateContainerService
Resource: 'arn:aws:lightsail:${self:provider.region}:${aws:accountId}:*'
functions:
autoscaling:
handler: src/index.handler
events:
- schedule:
rate: rate(10 minutes)
enabled: true
input:
name: lightsail-containers-autoscaler
rules:
- enabled: true
dry_run: false
scaling_type: dynamic
nodes: 3
power: nano
metric: cpu
average: 20
average_operator: gte
average_duration_minutes: 10
wait_after_last_deployment_minutes: 10
- enabled: true
dry_run: false
scaling_type: dynamic
nodes: 1
power: nano
metric: cpu
average: 5
average_operator: lte
average_duration_minutes: 15
wait_after_last_deployment_minutes: 30
- enabled: true
dry_run: false
scaling_type: scheduled
nodes: 2
power: micro
run_at: "* * 21 * * *"
wait_after_last_deployment_minutes: 30
environment:
APP_TABLE_NAME: ${self:custom.tableName}
APP_REGION: ${env:AWS_DEFAULT_REGION, 'ap-southeast-1'}
APP_CONTAINER_SVC_NAME: ${env:APP_CONTAINER_SVC_NAME}
resources:
Resources:
BotDemoTable:
Type: AWS::DynamoDB::Table
Properties:
AttributeDefinitions:
- AttributeName: pk
AttributeType: S
- AttributeName: sk
AttributeType: S
KeySchema:
- AttributeName: pk
KeyType: HASH
- AttributeName: sk
KeyType: RANGE
BillingMode: PAY_PER_REQUEST
TableName: ${self:custom.tableName}
TimeToLiveSpecification:
AttributeName: ttl
Enabled: true