This repository has been archived by the owner on May 10, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
template.yaml
176 lines (166 loc) · 6.43 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
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
AWSTemplateFormatVersion: '2010-09-09'
Description: >
" Deploys the AWS resources required to demonstrate the use case in the Contact Center Blog - Use Real-Time Contact Lens to deliver AI powered context on agent transfers
- Node.js Lambda function triggered by Amazon Connect to get real-time call analytics from Contact Lens
- Node.js Lambda functions triggered by CloudFormation to create contact flows and a quick connect
- Creates a custom resource to trigger the CreateContactFlows Lambda function"
Mappings:
FunctionMap:
Configuration:
S3Bucket: "amazon-connect-clrt-blog-assets"
S3Key: "aws-lambda-functions.zip"
Parameters:
instanceIdParam:
Type: String
AllowedPattern: '\w{8}-\w{4}-\w{4}-\w{4}-\w{12}'
ConstraintDescription: "Invalid Amazon Connect instance Id"
Description: Amazon Connect Instance ID (Ensure you it is entered accurately in the format xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx ).
basicQueueArnParam:
Type: String
ConstraintDescription: "Invalid Amazon Connect Queue ARN"
Description: Basic Queue ARN.
fraudQueueArnParam:
Type: String
ConstraintDescription: "Invalid Amazon Connect Queue ARN"
Description: Fraud Queue ARN.
Metadata:
'AWS::CloudFormation::Interface':
ParameterGroups:
- Label:
default: Amazon Connect Configuration
Parameters:
- instanceIdParam
- basicQueueArnParam
- fraudQueueArnParam
ParameterLabels:
instanceIdParam:
default: Instance ID
basicQueueArnParam:
default: Basic Queue ARN
fraudQueueArnParam:
default: Fraud Queue ARN
Outputs:
getRealTimeCallAnalyticsFromContactLens:
Description: >
Lambda function triggered by Amazon Connect to get real-time call analytics from Contact Lens.
Value: !Ref getRealTimeCallAnalyticsFromContactLens
getRealTimeCallAnalyticsFromContactLensARN:
Description: ARN for the GetRealTimeCallAnalyticsFromContactLensFunction
Value: !GetAtt getRealTimeCallAnalyticsFromContactLens.Arn
createContactFlows:
Description: >
Lambda function triggered by CFT to create Contact Flows.
Value: !Ref CreateContactFlows
createAgentWhisperFlowARN:
Description: ARN for the CreateAgentWhisperFlowFunction
Value: !GetAtt CreateContactFlows.Arn
Resources:
allowConnectToLambda:
Type: 'AWS::Lambda::Permission'
Properties:
FunctionName: !Ref getRealTimeCallAnalyticsFromContactLens
Action: 'lambda:InvokeFunction'
Principal: connect.amazonaws.com
SourceAccount: !Ref 'AWS::AccountId'
GetRealTimeCallAnalyticsFromContactLensRole:
Type: "AWS::IAM::Role"
Properties:
AssumeRolePolicyDocument:
Version: "2012-10-17"
Statement:
-
Effect: "Allow"
Principal:
Service:
- "lambda.amazonaws.com"
Action:
- "sts:AssumeRole"
Path: "/"
Policies:
-
PolicyName: !Sub ${AWS::StackName}-realtime-call-analytics-from-contactLens-policy
PolicyDocument:
Version: "2012-10-17"
Statement:
-
Effect: "Allow"
Action:
- 'logs:CreateLogGroup'
- 'logs:CreateLogStream'
- 'logs:PutLogEvents'
Resource:
- !Sub "arn:${AWS::Partition}:logs:${AWS::Region}:${AWS::AccountId}:log-group:/aws/lambda/*"
-
Effect: "Allow"
Action:
- 'connect:*'
Resource:
- "*"
getRealTimeCallAnalyticsFromContactLens:
Type: "AWS::Lambda::Function"
Properties:
Description: Lambda function triggered by Amazon Connect to get real-time call analytics from Contact Lens.
Runtime: nodejs12.x
Role: !GetAtt GetRealTimeCallAnalyticsFromContactLensRole.Arn
Handler: get-realtime-call-analytics-from-contactlens.handler
MemorySize: 128
Timeout: 30
Code: ./aws-resources-creator/
CreateContactFlowsRole:
Type: "AWS::IAM::Role"
Properties:
AssumeRolePolicyDocument:
Version: "2012-10-17"
Statement:
-
Effect: "Allow"
Principal:
Service:
- "lambda.amazonaws.com"
Action:
- "sts:AssumeRole"
Path: "/"
Policies:
-
PolicyName: !Sub ${AWS::StackName}-create-contact-flows-policy
PolicyDocument:
Version: "2012-10-17"
Statement:
-
Effect: "Allow"
Action:
- 'logs:CreateLogGroup'
- 'logs:CreateLogStream'
- 'logs:PutLogEvents'
Resource:
- !Sub "arn:${AWS::Partition}:logs:${AWS::Region}:${AWS::AccountId}:log-group:/aws/lambda/*"
-
Effect: "Allow"
Action:
- 'connect:*'
Resource:
- "*"
CreateContactFlows:
Type: "AWS::Lambda::Function"
Properties:
Description: Lambda function triggered by CFT to create Contact Flows.
Runtime: nodejs12.x
Role: !GetAtt CreateContactFlowsRole.Arn
Handler: create-contact-flows.handler
MemorySize: 128
Timeout: 30
Environment:
Variables:
CONNECT_INSTANCE_ID: !Ref instanceIdParam
Code: ./aws-resources-creator/
CreateContactFlowsLambdaRun:
Type: Custom::CreateContactFlowsLambdaRun
Properties:
ServiceToken: !GetAtt CreateContactFlows.Arn
LAMBDA_FUNCTION_ARN: !GetAtt getRealTimeCallAnalyticsFromContactLens.Arn
BASIC_QUEUE_ARN: !Ref basicQueueArnParam
FRAUD_QUEUE_ARN: !Ref fraudQueueArnParam
AGENT_WHISPER_FLOW_NAME: !Sub ${AWS::StackName}-CLRT-Agent-Whisper-Flow
QUEUE_TRANSFER_FLOW_NAME: !Sub ${AWS::StackName}-CLRT-Queue-Transfer-Flow
CONTACT_FLOW_NAME: !Sub ${AWS::StackName}-CLRT-Contact-Flow
QUICK_CONNECT_NAME: !Sub ${AWS::StackName}-CLRT-Quick-Connect