-
Notifications
You must be signed in to change notification settings - Fork 1
/
template.yaml
73 lines (66 loc) · 2.81 KB
/
template.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: Setup notifications from CodePipeline to AWS Chatbot
Metadata:
AWS::ServerlessRepo::Application:
Name: codepipeline-chatbot
Description: Setup notifications from CodePipeline to AWS Chatbot
Author: Symphonia
SpdxLicenseId: Apache-2.0
LicenseUrl: LICENSE
ReadmeUrl: README.md
Labels: ['codepipeline', 'cd', 'devops', 'chatbot', 'chatops', 'slack']
HomePageUrl: https://github.com/symphoniacloud/codepipline-chatbot
SourceCodeUrl: https://github.com/symphoniacloud/codepipline-chatbot
Parameters:
CodePipeline:
Description: The name of the CodePipeline to capture notifications from. Equal to the "Ref" value of the AWS::CodePipeline::Pipeline resource
Type: String
NotificationRuleName:
Description: Set if you wish to override the name given to the CodeStar Notification Rule. Defaults to the value of the CodePipeline parameter.
Type: String
Default: ''
MaxLength: 64
DetailType:
Description: The level of detail to include in the notifications for this resource. (see https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-codestarnotifications-notificationrule.html)
Default: FULL
Type: String
Conditions:
NotificationRuleNameIsSet: !Not [!Equals [ !Ref NotificationRuleName, '' ]]
Outputs:
SNSTopicName:
Description: Name of the SNS Topic that you can connect to AWS Chatbot
Value: !GetAtt PipelineNotificationsTopic.TopicName
Resources:
PipelineNotificationsTopic:
Type: AWS::SNS::Topic
PipelineNotificationsTopicPolicy:
Type: AWS::SNS::TopicPolicy
Properties:
Topics:
- !Ref PipelineNotificationsTopic
PolicyDocument:
Statement:
- Action: 'SNS:Publish'
Effect: Allow
Resource: !Ref PipelineNotificationsTopic
Principal:
Service: codestar-notifications.amazonaws.com
NotificationRule:
Type: AWS::CodeStarNotifications::NotificationRule
Properties:
# Name is required, unlike for most resource types
Name: !If [ NotificationRuleNameIsSet, !Ref NotificationRuleName, !Ref CodePipeline ]
Resource: !Sub "arn:aws:codepipeline:${AWS::Region}:${AWS::AccountId}:${CodePipeline}"
DetailType: !Ref DetailType
EventTypeIds:
- codepipeline-pipeline-pipeline-execution-failed
- codepipeline-pipeline-pipeline-execution-canceled
- codepipeline-pipeline-pipeline-execution-started
- codepipeline-pipeline-pipeline-execution-resumed
- codepipeline-pipeline-pipeline-execution-succeeded
- codepipeline-pipeline-pipeline-execution-superseded
- codepipeline-pipeline-manual-approval-needed
Targets:
- TargetType: SNS
TargetAddress: !Ref PipelineNotificationsTopic