forked from amazon-archives/lightsail-auto-snapshots
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lightsail-auto-snapshots.yaml
48 lines (43 loc) · 1.27 KB
/
lightsail-auto-snapshots.yaml
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
AWSTemplateFormatVersion: 2010-09-09
Transform: AWS::Serverless-2016-10-31
Description: >
Automatically create snapshots from all Lightsail Virtual Private Servers
each day and prune snapshots after a retention period.
Parameters:
RetentionDays:
Type: String
Description: The number of days to retain snapshots.
Default: 30
Metadata:
AWS::CloudFormation::Interface:
ParameterLabels:
RetentionDays:
default: Retention Days
Resources:
AutoSnapshot:
Type: AWS::Serverless::Function
Properties:
Description: >
Automatically create snapshots from all Lightsail Virtual Private
Servers and prune snapshots after a retention period.
CodeUri: ./lambda
Runtime: python2.7
Timeout: 60
Handler: index.handler
Environment:
Variables:
RETENTION_DAYS: !Ref RetentionDays
Events:
Daily:
Type: Schedule
Properties:
Schedule: rate(1 day)
Policies:
Statement:
- Resource: "*"
Effect: Allow
Action:
- lightsail:GetInstances
- lightsail:GetInstanceSnapshots
- lightsail:CreateInstanceSnapshot
- lightsail:DeleteInstanceSnapshot