-
Notifications
You must be signed in to change notification settings - Fork 50
/
template.yml
57 lines (57 loc) · 1.89 KB
/
template.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
AWSTemplateFormatVersion: '2010-09-09'
Transform: 'AWS::Serverless-2016-10-31'
Description: 'Create pipeline-dashboard application.'
Parameters:
PipelinePattern:
Description: 'The pattern of pipeline names to allow access to describe. Recommended value: *'
Type: String
BucketName:
Description: 'S3 BucketName for Node functions. For example: pipeline-dashboard'
Type: String
Default: "pipeline-dashboard-node-0811"
CodeKey:
Description: 'S3 Key for Node functions. For example: pipeline-dashboard.zip'
Type: String
Default: "pipeline-dashboard.zip"
Resources:
PipelineDashboardEventHandler:
Type: 'AWS::Serverless::Function'
Properties:
Description: Create CloudWatch metrics from CodePipeline events
Handler: index.handlePipelineEvent
Runtime: nodejs12.x
CodeUri:
Bucket: !Ref BucketName
Key: !Ref CodeKey
Events:
PipelineEventRule:
Type: CloudWatchEvent
Properties:
Pattern:
source:
- "aws.codepipeline"
detail-type:
- "CodePipeline Pipeline Execution State Change"
- "CodePipeline Stage Execution State Change"
- "CodePipeline Action Execution State Change"
Policies:
- CloudWatchPutMetricPolicy: {}
- CodePipelineReadOnlyPolicy:
PipelineName: !Ref PipelinePattern
PipelineDashboardGenerator:
Type: 'AWS::Serverless::Function'
Properties:
Description: Build CloudWatch dashboard from CloudWatch metrics
Handler: index.generateDashboard
Runtime: nodejs12.x
CodeUri:
Bucket: !Ref BucketName
Key: !Ref CodeKey
Timeout: 60
Events:
DashboardEventRule:
Type: Schedule
Properties:
Schedule: "cron(*/5 * * * ? *)"
Policies:
- CloudWatchDashboardPolicy: {}