-
Notifications
You must be signed in to change notification settings - Fork 3
/
serverless.yml
80 lines (78 loc) · 2.03 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
service: scheduler
disabledDeprecations: '*'
useDotenv: true
plugins:
- serverless-python-requirements
- serverless-dotenv-plugin
- serverless-plugin-resource-tagging
custom:
pythonRequirements:
dockerizePip: true
provider:
name: aws
runtime: python3.11
memorySize: 128
timeout: 900
region: ${env:REGION}
stackTags:
Source: "https://github.com/leonardobiffi/aws-schedules"
environment:
DEGUG: ${env:DEGUG}
TAG: schedule
TIME: ${env:TIME}
DYNAMODB_TABLE: ${env:DYNAMODB_TABLE}
RDS_SCHEDULE: ${env:RDS_SCHEDULE}
EC2_SCHEDULE: ${env:EC2_SCHEDULE}
ECS_SCHEDULE: ${env:ECS_SCHEDULE}
ASG_SCHEDULE: ${env:ASG_SCHEDULE}
iamRoleStatements:
- Effect: "Allow"
Action:
- "ec2:DescribeInstances"
- "ec2:DescribeRegions"
- "ec2:StartInstances"
- "ec2:StopInstances"
- "rds:DescribeDBInstances"
- "rds:DescribeDBClusters"
- "rds:StartDBInstance"
- "rds:StartDBCluster"
- "rds:StopDBInstance"
- "rds:StopDBCluster"
- "rds:ListTagsForResource"
- "ecs:*"
- "autoscaling:*"
- "logs:*"
- "application-autoscaling:*"
Resource:
- "*"
- Effect: Allow
Action:
- dynamodb:Query
- dynamodb:Scan
- dynamodb:GetItem
- dynamodb:PutItem
- dynamodb:UpdateItem
- dynamodb:DeleteItem
Resource:
- "arn:aws:dynamodb:${opt:region, self:provider.region}:*:table/${self:provider.environment.DYNAMODB_TABLE}"
resources:
Resources:
ECSScheduleTable:
Type: AWS::DynamoDB::Table
DeletionPolicy: Retain
Properties:
AttributeDefinitions:
- AttributeName: service
AttributeType: S
KeySchema:
- AttributeName: service
KeyType: HASH
BillingMode: PAY_PER_REQUEST
TableName: ${env:DYNAMODB_TABLE}
functions:
function:
handler: scheduler.handler
events:
- schedule:
rate: cron(0 * * * ? *)
enabled: true