-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemplate.yml
More file actions
41 lines (38 loc) · 1.23 KB
/
template.yml
File metadata and controls
41 lines (38 loc) · 1.23 KB
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
AWSTemplateFormatVersion: '2010-09-09'
Transform: 'AWS::Serverless-2016-10-31'
Description: "Auto start-stop functionality for the account's EC2 containers."
Resources:
AutoStartStopFunction:
Type: AWS::Serverless::Function
Properties:
FunctionName: 'auto-start-stop'
Description: "Auto start-stop functionality for the account's EC2 containers."
CodeUri: app/
Handler: main.handler
Runtime: python3.7
MemorySize: 128 # MB
Timeout: 15 # seconds
Environment:
Variables:
TIMEZONE: 'America/New_York'
Policies:
-
Version: '2012-10-17'
Statement:
- Sid: LambdaCanStartStopInstances
Effect: Allow
Action:
- 'ec2:Describe*'
- 'ec2:StartInstances'
- 'ec2:StopInstances'
Resource: !Sub 'arn:aws:ec2:*:${AWS::AccountId}:*'
Events:
AutoStartStopExecution:
Type: Schedule
Properties:
Schedule: 'cron(0/10 * * * ? *)' # Fires every 10 minutes
Outputs:
AutoStartStopFunctionArn:
Value: !GetAtt AutoStartStopFunction.Arn
AutoStartStopFunctionIamRole:
Value: !GetAtt AutoStartStopFunctionRole.Arn