forked from awslabs/amazon-redshift-utils
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy-schedule.yaml
52 lines (52 loc) · 2.1 KB
/
deploy-schedule.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
49
50
51
52
Parameters:
LambdaFunctionARN:
Default: arn:aws:lambda:myregion:123456789012:function:LambdaRedshiftRunner
Description: The ARN of the currently deployed LambdaRedshiftRunner function
Type: String
AllowedPattern: ^arn\:aws\:lambda\:([\w-])+\:[0-9]{12}\:function\:(.*)$
UtilityName:
Default: AnalyzeVacuumUtility
Description: Utility to run with this instance of the Scheduled Event
Type: String
AllowedValues:
- Analyze
- Vacuum
- AnalyzeVacuumUtility
- ColumnEncodingUtility
- Monitoring
- SystemTablePersistence
S3ConfigPath:
Default: s3://my-bucket/prefix/config-file.json
Description: Configuration File for this Utility instance
Type: String
AllowedPattern: ^s3:\/\/([A-z\-]+)\/(.*)$
CronExpression:
Default: 0 0 * * ? *
Description: Cron expression indicating how frequently to run the specified utility (default is once a day at midnight)
Type: String
AllowedPattern: ^([0-5]?[0-9]|\*|[0-5]?[0-9]\,[0-5]?[0-9]|[0-5]?[0-9]\-[0-5]?[0-9]|0\/[0-5]?[0-9]) ([ 01]?[0-9]|2[0-3]|\*|\,|\-|\/) ([ 012]?[1-9]|3[01]|JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC|\*|\,|\-|\/|\?|L|W) ([0]?[1-9]|1[0-2]|\*|\,|\-|\/) ([1-7]|MON|TUE|WED|THU|FRI|SAT|SUN|\*|\,|\-|\/|\?|L|\#) (19[7-9][0-9]|2[01][0-9][0-9]|\*|\,|\-|\/)$
Resources:
UtilityEventRule:
Type: "AWS::Events::Rule"
Properties:
Description: CloudWatch Events Rule to Invoke Lambda Runner
Name: !Sub InvokeLambdaRedshiftRunner-${UtilityName}
ScheduleExpression: !Sub cron(${CronExpression})
State: ENABLED
Targets:
- Arn: !Ref LambdaFunctionARN
Id: LambdaRedshiftRunner
Input:
!Sub |
{
"ExecuteUtility":"${UtilityName}",
"ConfigLocation":"${S3ConfigPath}"
}
LambdaInvokePermission:
Type: 'AWS::Lambda::Permission'
Properties:
FunctionName: !Ref LambdaFunctionARN
Action: 'lambda:InvokeFunction'
Principal: events.amazonaws.com
SourceAccount: !Ref 'AWS::AccountId'
SourceArn: !GetAtt UtilityEventRule.Arn