-
Notifications
You must be signed in to change notification settings - Fork 0
/
digitized_image_notifications_template.yaml
132 lines (121 loc) · 4.27 KB
/
digitized_image_notifications_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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
AWSTemplateFormatVersion: '2010-09-09'
Description: >
digitized-image-notifications
Handles notifications for validation and packaging of incoming digitized still image and textual assets.
Parameters:
ApplicationEnvironment:
Type: String
Description: The environment in which the application should be deployed.
AllowedValues:
- dev
- prod
ApplicationName:
Type: String
Description: The name of the application to be deployed.
TeamsUrl:
Type: String
Description: URL for a Teams channel webhook.
Resources:
HandleDigitizedImageNotificationsRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Principal:
Service:
- lambda.amazonaws.com
Action:
- 'sts:AssumeRole'
Description: !Sub 'Allows ${ApplicationName} lambda to be executed successfully.'
Policies:
- PolicyName: DigitizedImageParameterStorePolicy
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- 'ssm:GetParametersByPath*'
Resource: !Sub 'arn:aws:ssm:${AWS::Region}:${AWS::AccountId}:parameter/${ApplicationEnvironment}/${ApplicationName}*'
- PolicyName: DigitizedImageLogPolicy
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- 'logs:CreateLogGroup'
- 'logs:CreateLogStream'
- 'logs:PutLogEvents'
Resource:
- !GetAtt NotificationsLogGroup.Arn
DigitizedImageEventsTopic:
Type: AWS::SNS::Topic
Properties:
TopicName: digitized-image-events
TeamsUrlParameter:
Type: AWS::SSM::Parameter
Properties:
Description: URL for Teams Channel webhook.
Name: !Sub /${ApplicationEnvironment}/${ApplicationName}/TEAMS_URL
Tags:
Environment: !Ref ApplicationEnvironment
Application: !Ref ApplicationName
Type: String
Value: !Ref TeamsUrl
HandleDigitizedImageNotificationsFunction:
Type: AWS::Lambda::Function
Properties:
Code:
S3Bucket: !Sub 'rac-${ApplicationEnvironment}-lambda'
S3Key: !Sub '${ApplicationName}.zip'
FunctionName: !Ref ApplicationName
Handler: handle_digitized_image_notifications.lambda_handler
Role: !GetAtt HandleDigitizedImageNotificationsRole.Arn
Runtime: python3.11
Timeout: 30
Environment:
Variables:
ENV: !Ref ApplicationEnvironment
APP_CONFIG_PATH: !Ref ApplicationName
Tags:
- Key: Environment
Value: !Ref ApplicationEnvironment
- Key: Application
Value: !Ref ApplicationName
Architectures:
- x86_64
NotificationsLogGroup:
Type: AWS::Logs::LogGroup
Properties:
LogGroupName: !Sub "/aws/lambda/${ApplicationName}"
RetentionInDays: 90
HandleDigitizedImageNotificationsFunctionDigitizedImageEventsPermission:
Type: AWS::Lambda::Permission
Properties:
Action: lambda:InvokeFunction
FunctionName: !Ref HandleDigitizedImageNotificationsFunction
Principal: sns.amazonaws.com
SourceArn: !Ref DigitizedImageEventsTopic
HandleDigitizedImageNotificationsFunctionDigitizedImageEventsTravisEcRPermission:
Type: AWS::Lambda::Permission
Properties:
FunctionName: !Ref HandleDigitizedImageNotificationsFunction
Action: "lambda:UpdateFunctionCode"
Principal: "arn:aws:iam::817658541382:user/TravisECR"
HandleDigitizedImageNotificationsFunctionDigitizedImageEvents:
Type: AWS::SNS::Subscription
Properties:
Endpoint: !GetAtt HandleDigitizedImageNotificationsFunction.Arn
Protocol: lambda
TopicArn: !Ref DigitizedImageEventsTopic
Outputs:
HandleDigitizedImageNotificationsFunction:
Description: 'Handle Digitized Image Notifications Lambda Function ARN'
Value: !GetAtt HandleDigitizedImageNotificationsFunction.Arn
DigitizedImageEventsTopic:
Description: 'Digitized Image Events SNS Topic ARN'
Value: !Ref DigitizedImageEventsTopic
Export:
Name:
DigitizedImage-SNSTopicArn