Skip to content

Commit 3419759

Browse files
authored
Merge branch 'main' into main
2 parents d92840c + b1f7b34 commit 3419759

File tree

12 files changed

+492
-0
lines changed

12 files changed

+492
-0
lines changed

typescript/connect-cdk/.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
*.js
2+
!jest.config.js
3+
*.d.ts
4+
node_modules
5+
6+
# CDK asset staging directory
7+
.cdk.staging
8+
cdk.out

typescript/connect-cdk/.npmignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
*.ts
2+
!*.d.ts
3+
4+
# CDK asset staging directory
5+
.cdk.staging
6+
cdk.out

typescript/connect-cdk/README.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Amazon Connect fully deployed with CDK
2+
3+
<!--BEGIN STABILITY BANNER-->
4+
---
5+
6+
![Stability: Stable](https://img.shields.io/badge/stability-Stable-success.svg?style=for-the-badge)
7+
8+
> **This is a stable example. It should successfully build out of the box**
9+
>
10+
> This example is built on Construct Libraries marked "Stable" and does not have any infrastructure prerequisites to build.
11+
---
12+
<!--END STABILITY BANNER-->
13+
14+
## Overview
15+
16+
A fully infrastructure-as-code Amazon Connect solution that includes a simple call flow itegrated with Lambda.
17+
18+
## Solution
19+
20+
Some of the key services in use:
21+
* Amazon Connect
22+
* AWS Lambda
23+
24+
### Connect Call Flows
25+
The following Connect flows/modules are found in the `callFlows`:
26+
* `MainFlow.json` -- the main flow
27+
28+
***Modifying the json can be performed via the Connect user interface, followed by an export operation. Note that string replacements are performed prior to loading the json flows into the resource, they will need to be reset after exporting. This is responsible for ARN and other dependency resolution and is contained to the contact attributes parameters.***
29+
30+
## Tagging
31+
The follow tag is set for all taggable resources in `bin/connect_cdk_simple.ts`:
32+
* `application: 'Github Location'`
33+
34+
## Deploying
35+
36+
This project contains a Lambda function that use the CDK to deploy. It is written in Python, but des not require any further building or packaging.
37+
38+
This project uses the Cloud Development Kit (CDK) in Typescript.
39+
40+
```bash
41+
cdk deploy
42+
```
43+
44+
## Cleanup
45+
To cleanup this solution or avoid further or on-going charges
46+
47+
```bash
48+
cdk destroy
49+
```
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env node
2+
import 'source-map-support/register';
3+
import * as cdk from 'aws-cdk-lib';
4+
import { ConnectCdkStack as ConnectCdkStack } from '../lib/connect_cdk-stack';
5+
6+
const app = new cdk.App();
7+
8+
new ConnectCdkStack(app, 'ConnectCdkStack');
Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
{
2+
"Version": "2019-10-30",
3+
"StartAction": "d3f90ab2-eb2a-467f-a349-323422ad8bec",
4+
"Metadata": {
5+
"entryPointPosition": {
6+
"x": -10.4,
7+
"y": -28
8+
},
9+
"ActionMetadata": {
10+
"51bffcc2-8bda-46a4-8b29-6c327c109cfe": {
11+
"position": {
12+
"x": 271.2,
13+
"y": -29.6
14+
}
15+
},
16+
"d3f90ab2-eb2a-467f-a349-323422ad8bec": {
17+
"position": {
18+
"x": 80,
19+
"y": 188.8
20+
}
21+
},
22+
"52f73b71-7081-4cf0-b6f6-4202cfba2863": {
23+
"position": {
24+
"x": 512,
25+
"y": 12.8
26+
}
27+
},
28+
"6a6556e1-b596-4f5b-b0c1-c5ac5ab965a3": {
29+
"position": {
30+
"x": 1228.8,
31+
"y": 196.8
32+
}
33+
},
34+
"049fca85-b0bd-49d6-8517-2943c248cdc3": {
35+
"position": {
36+
"x": 734.4,
37+
"y": -100.8
38+
},
39+
"parameters": {
40+
"LambdaFunctionARN": {
41+
"useDynamic": true
42+
}
43+
},
44+
"dynamicMetadata": {},
45+
"useDynamic": true
46+
},
47+
"3e5551e7-b4b8-4051-a438-019dfe5b760b": {
48+
"position": {
49+
"x": 1025.6,
50+
"y": -50.4
51+
}
52+
}
53+
},
54+
"Annotations": [],
55+
"name": "MainFlow",
56+
"description": "",
57+
"type": "contactFlow",
58+
"status": "published",
59+
"hash": {}
60+
},
61+
"Actions": [
62+
{
63+
"Parameters": {
64+
"FlowAttributes": {
65+
"HelloLambdaArn": {
66+
"Value": "HelloLambdaArnValue"
67+
}
68+
}
69+
},
70+
"Identifier": "51bffcc2-8bda-46a4-8b29-6c327c109cfe",
71+
"Type": "UpdateFlowAttributes",
72+
"Transitions": {
73+
"NextAction": "52f73b71-7081-4cf0-b6f6-4202cfba2863",
74+
"Errors": [
75+
{
76+
"NextAction": "6a6556e1-b596-4f5b-b0c1-c5ac5ab965a3",
77+
"ErrorType": "NoMatchingError"
78+
}
79+
]
80+
}
81+
},
82+
{
83+
"Parameters": {
84+
"FlowLoggingBehavior": "Enabled"
85+
},
86+
"Identifier": "d3f90ab2-eb2a-467f-a349-323422ad8bec",
87+
"Type": "UpdateFlowLoggingBehavior",
88+
"Transitions": {
89+
"NextAction": "51bffcc2-8bda-46a4-8b29-6c327c109cfe"
90+
}
91+
},
92+
{
93+
"Parameters": {
94+
"Text": "Hello"
95+
},
96+
"Identifier": "52f73b71-7081-4cf0-b6f6-4202cfba2863",
97+
"Type": "MessageParticipant",
98+
"Transitions": {
99+
"NextAction": "049fca85-b0bd-49d6-8517-2943c248cdc3",
100+
"Errors": [
101+
{
102+
"NextAction": "6a6556e1-b596-4f5b-b0c1-c5ac5ab965a3",
103+
"ErrorType": "NoMatchingError"
104+
}
105+
]
106+
}
107+
},
108+
{
109+
"Parameters": {},
110+
"Identifier": "6a6556e1-b596-4f5b-b0c1-c5ac5ab965a3",
111+
"Type": "DisconnectParticipant",
112+
"Transitions": {}
113+
},
114+
{
115+
"Parameters": {
116+
"LambdaFunctionARN": "$.FlowAttributes.HelloLambdaArn",
117+
"InvocationTimeLimitSeconds": "3",
118+
"ResponseValidation": {
119+
"ResponseType": "JSON"
120+
}
121+
},
122+
"Identifier": "049fca85-b0bd-49d6-8517-2943c248cdc3",
123+
"Type": "InvokeLambdaFunction",
124+
"Transitions": {
125+
"NextAction": "3e5551e7-b4b8-4051-a438-019dfe5b760b",
126+
"Errors": [
127+
{
128+
"NextAction": "6a6556e1-b596-4f5b-b0c1-c5ac5ab965a3",
129+
"ErrorType": "NoMatchingError"
130+
}
131+
]
132+
}
133+
},
134+
{
135+
"Parameters": {
136+
"SSML": "<speak> <say-as interpret-as=\"date\" format=\"mmddyyyy\"> $.External.body.response </say-as> </speak>"
137+
},
138+
"Identifier": "3e5551e7-b4b8-4051-a438-019dfe5b760b",
139+
"Type": "MessageParticipant",
140+
"Transitions": {
141+
"NextAction": "6a6556e1-b596-4f5b-b0c1-c5ac5ab965a3",
142+
"Errors": [
143+
{
144+
"NextAction": "6a6556e1-b596-4f5b-b0c1-c5ac5ab965a3",
145+
"ErrorType": "NoMatchingError"
146+
}
147+
]
148+
}
149+
}
150+
]
151+
}

typescript/connect-cdk/cdk.json

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
{
2+
"app": "npx ts-node --prefer-ts-exts bin/connect_cdk.ts",
3+
"watch": {
4+
"include": [
5+
"**"
6+
],
7+
"exclude": [
8+
"README.md",
9+
"cdk*.json",
10+
"**/*.d.ts",
11+
"**/*.js",
12+
"tsconfig.json",
13+
"package*.json",
14+
"yarn.lock",
15+
"node_modules",
16+
"test"
17+
]
18+
},
19+
"context": {
20+
"@aws-cdk/aws-lambda:recognizeLayerVersion": true,
21+
"@aws-cdk/core:checkSecretUsage": true,
22+
"@aws-cdk/core:target-partitions": [
23+
"aws",
24+
"aws-cn"
25+
],
26+
"@aws-cdk-containers/ecs-service-extensions:enableDefaultLogDriver": true,
27+
"@aws-cdk/aws-ec2:uniqueImdsv2TemplateName": true,
28+
"@aws-cdk/aws-ecs:arnFormatIncludesClusterName": true,
29+
"@aws-cdk/aws-iam:minimizePolicies": true,
30+
"@aws-cdk/core:validateSnapshotRemovalPolicy": true,
31+
"@aws-cdk/aws-codepipeline:crossAccountKeyAliasStackSafeResourceName": true,
32+
"@aws-cdk/aws-s3:createDefaultLoggingPolicy": true,
33+
"@aws-cdk/aws-sns-subscriptions:restrictSqsDescryption": true,
34+
"@aws-cdk/aws-apigateway:disableCloudWatchRole": true,
35+
"@aws-cdk/core:enablePartitionLiterals": true,
36+
"@aws-cdk/aws-events:eventsTargetQueueSameAccount": true,
37+
"@aws-cdk/aws-ecs:disableExplicitDeploymentControllerForCircuitBreaker": true,
38+
"@aws-cdk/aws-iam:importedRoleStackSafeDefaultPolicyName": true,
39+
"@aws-cdk/aws-s3:serverAccessLogsUseBucketPolicy": true,
40+
"@aws-cdk/aws-route53-patters:useCertificate": true,
41+
"@aws-cdk/customresources:installLatestAwsSdkDefault": false,
42+
"@aws-cdk/aws-rds:databaseProxyUniqueResourceName": true,
43+
"@aws-cdk/aws-codedeploy:removeAlarmsFromDeploymentGroup": true,
44+
"@aws-cdk/aws-apigateway:authorizerChangeDeploymentLogicalId": true,
45+
"@aws-cdk/aws-ec2:launchTemplateDefaultUserData": true,
46+
"@aws-cdk/aws-secretsmanager:useAttachedSecretResourcePolicyForSecretTargetAttachments": true,
47+
"@aws-cdk/aws-redshift:columnId": true,
48+
"@aws-cdk/aws-stepfunctions-tasks:enableEmrServicePolicyV2": true,
49+
"@aws-cdk/aws-ec2:restrictDefaultSecurityGroup": true,
50+
"@aws-cdk/aws-apigateway:requestValidatorUniqueId": true,
51+
"@aws-cdk/aws-kms:aliasNameRef": true,
52+
"@aws-cdk/aws-autoscaling:generateLaunchTemplateInsteadOfLaunchConfig": true,
53+
"@aws-cdk/core:includePrefixInUniqueNameGeneration": true,
54+
"@aws-cdk/aws-efs:denyAnonymousAccess": true,
55+
"@aws-cdk/aws-opensearchservice:enableOpensearchMultiAzWithStandby": true,
56+
"@aws-cdk/aws-lambda-nodejs:useLatestRuntimeVersion": true,
57+
"@aws-cdk/aws-efs:mountTargetOrderInsensitiveLogicalId": true,
58+
"@aws-cdk/aws-rds:auroraClusterChangeScopeOfInstanceParameterGroupWithEachParameters": true,
59+
"@aws-cdk/aws-appsync:useArnForSourceApiAssociationIdentifier": true,
60+
"@aws-cdk/aws-rds:preventRenderingDeprecatedCredentials": true,
61+
"@aws-cdk/aws-codepipeline-actions:useNewDefaultBranchForCodeCommitSource": true,
62+
"@aws-cdk/aws-cloudwatch-actions:changeLambdaPermissionLogicalIdForLambdaAction": true,
63+
"@aws-cdk/aws-codepipeline:crossAccountKeysDefaultValueToFalse": true,
64+
"@aws-cdk/aws-codepipeline:defaultPipelineTypeToV2": true,
65+
"@aws-cdk/aws-kms:reduceCrossAccountRegionPolicyScope": true,
66+
"@aws-cdk/aws-eks:nodegroupNameAttribute": true,
67+
"@aws-cdk/aws-ec2:ebsDefaultGp3Volume": true,
68+
"@aws-cdk/aws-ecs:removeDefaultDeploymentAlarm": true,
69+
"@aws-cdk/custom-resources:logApiResponseDataPropertyTrueDefault": false,
70+
"@aws-cdk/aws-s3:keepNotificationInImportedBucket": false
71+
}
72+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import boto3
2+
from datetime import datetime, timedelta
3+
import logging
4+
5+
# Establish logging configuration
6+
logger = logging.getLogger()
7+
8+
def lambda_handler(event, context):
9+
10+
response = {
11+
12+
'response': "the current date is " + datetime.now().strftime("%m-%d-%Y")
13+
}
14+
15+
logger.info(response)
16+
17+
return {
18+
'statusCode': 200,
19+
'body': response
20+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module.exports = {
2+
testEnvironment: 'node',
3+
roots: ['<rootDir>/test'],
4+
testMatch: ['**/*.test.ts'],
5+
transform: {
6+
'^.+\\.tsx?$': 'ts-jest'
7+
}
8+
};

0 commit comments

Comments
 (0)