-
Notifications
You must be signed in to change notification settings - Fork 0
/
template.yaml
59 lines (58 loc) · 1.78 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
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: SAM template for PipelineNotifier Application
Globals:
Function:
Runtime: python3.12
Timeout: 30
Parameters:
ServiceName:
Description: The name of the project
Type: String
Default: PipelineNotifier
PipelineTopicArn:
Description: The SNS topic ARN for pipeline notifications
Type: String
CustomizedNotificationTopicArn:
Description: The SNS topic ARN for sending customized notifications
Type: String
Resources:
LambdaRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Principal:
Service: lambda.amazonaws.com
Action:
- sts:AssumeRole
ManagedPolicyArns:
- !Sub "arn:aws:iam::${AWS::AccountId}:policy/SecretsViewOnly"
- !Sub "arn:aws:iam::aws:policy/AWSCodePipelineReadOnlyAccess"
- !Sub "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
Policies:
- PolicyName: "SNSPublishPolicy"
PolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: "Allow"
Action: "sns:Publish"
Resource: !Ref CustomizedNotificationTopicArn
CustomizeNotification:
Type: AWS::Serverless::Function
Properties:
FunctionName:
Fn::Sub: "${ServiceName}-CustomizeNotification"
CodeUri: aws-pipeline-notifier/
Handler: app.lambda_handler
Role: !GetAtt LambdaRole.Arn
Environment:
Variables:
CustomizedNotificationTopicArn: !Ref CustomizedNotificationTopicArn
Events:
SNSEvent:
Type: SNS
Properties:
Topic: !Ref PipelineTopicArn