forked from leonardobiffi/aws-schedules
-
Notifications
You must be signed in to change notification settings - Fork 0
/
serverless.yml
73 lines (70 loc) · 1.82 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
service: scheduler-${env:REGION}
useDotenv: true
plugins:
- serverless-python-requirements
provider:
name: aws
runtime: python3.8
memorySize: 128
timeout: 900
region: ${env:REGION}
environment:
DEGUG: ${env:DEGUG}
TAG: schedule
TIME: ${env:TIME}
REGION: ${env:REGION}
DYNAMODB_TABLE: ecs-schedule
RDS_SCHEDULE: ${env:RDS_SCHEDULE}
EC2_SCHEDULE: ${env:EC2_SCHEDULE}
ECS_SCHEDULE: ${env:ECS_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:*"
- "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: ${self:provider.environment.DYNAMODB_TABLE}
functions:
function:
handler: scheduler.handler
events:
- schedule: cron(0 * * * ? *)
custom:
pythonRequirements:
dockerizePip: non-linux