Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions typescript/connect-cdk/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
*.js
!jest.config.js
*.d.ts
node_modules

# CDK asset staging directory
.cdk.staging
cdk.out
6 changes: 6 additions & 0 deletions typescript/connect-cdk/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
*.ts
!*.d.ts

# CDK asset staging directory
.cdk.staging
cdk.out
49 changes: 49 additions & 0 deletions typescript/connect-cdk/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Amazon Connect fully deployed with CDK

<!--BEGIN STABILITY BANNER-->
---

![Stability: Stable](https://img.shields.io/badge/stability-Stable-success.svg?style=for-the-badge)

> **This is a stable example. It should successfully build out of the box**
>
> This example is built on Construct Libraries marked "Stable" and does not have any infrastructure prerequisites to build.
---
<!--END STABILITY BANNER-->

## Overview

A fully infrastructure-as-code Amazon Connect solution that includes a simple call flow itegrated with Lambda.

## Solution

Some of the key services in use:
* Amazon Connect
* AWS Lambda

### Connect Call Flows
The following Connect flows/modules are found in the `callFlows`:
* `MainFlow.json` -- the main flow

***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.***

## Tagging
The follow tag is set for all taggable resources in `bin/connect_cdk_simple.ts`:
* `application: 'Github Location'`

## Deploying

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.

This project uses the Cloud Development Kit (CDK) in Typescript.

```bash
cdk deploy
```

## Cleanup
To cleanup this solution or avoid further or on-going charges

```bash
cdk destroy
```
8 changes: 8 additions & 0 deletions typescript/connect-cdk/bin/connect_cdk.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env node
import 'source-map-support/register';
import * as cdk from 'aws-cdk-lib';
import { ConnectCdkStack as ConnectCdkStack } from '../lib/connect_cdk-stack';

const app = new cdk.App();

new ConnectCdkStack(app, 'ConnectCdkStack');
151 changes: 151 additions & 0 deletions typescript/connect-cdk/callFlows/MainFlow.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
{
"Version": "2019-10-30",
"StartAction": "d3f90ab2-eb2a-467f-a349-323422ad8bec",
"Metadata": {
"entryPointPosition": {
"x": -10.4,
"y": -28
},
"ActionMetadata": {
"51bffcc2-8bda-46a4-8b29-6c327c109cfe": {
"position": {
"x": 271.2,
"y": -29.6
}
},
"d3f90ab2-eb2a-467f-a349-323422ad8bec": {
"position": {
"x": 80,
"y": 188.8
}
},
"52f73b71-7081-4cf0-b6f6-4202cfba2863": {
"position": {
"x": 512,
"y": 12.8
}
},
"6a6556e1-b596-4f5b-b0c1-c5ac5ab965a3": {
"position": {
"x": 1228.8,
"y": 196.8
}
},
"049fca85-b0bd-49d6-8517-2943c248cdc3": {
"position": {
"x": 734.4,
"y": -100.8
},
"parameters": {
"LambdaFunctionARN": {
"useDynamic": true
}
},
"dynamicMetadata": {},
"useDynamic": true
},
"3e5551e7-b4b8-4051-a438-019dfe5b760b": {
"position": {
"x": 1025.6,
"y": -50.4
}
}
},
"Annotations": [],
"name": "MainFlow",
"description": "",
"type": "contactFlow",
"status": "published",
"hash": {}
},
"Actions": [
{
"Parameters": {
"FlowAttributes": {
"HelloLambdaArn": {
"Value": "HelloLambdaArnValue"
}
}
},
"Identifier": "51bffcc2-8bda-46a4-8b29-6c327c109cfe",
"Type": "UpdateFlowAttributes",
"Transitions": {
"NextAction": "52f73b71-7081-4cf0-b6f6-4202cfba2863",
"Errors": [
{
"NextAction": "6a6556e1-b596-4f5b-b0c1-c5ac5ab965a3",
"ErrorType": "NoMatchingError"
}
]
}
},
{
"Parameters": {
"FlowLoggingBehavior": "Enabled"
},
"Identifier": "d3f90ab2-eb2a-467f-a349-323422ad8bec",
"Type": "UpdateFlowLoggingBehavior",
"Transitions": {
"NextAction": "51bffcc2-8bda-46a4-8b29-6c327c109cfe"
}
},
{
"Parameters": {
"Text": "Hello"
},
"Identifier": "52f73b71-7081-4cf0-b6f6-4202cfba2863",
"Type": "MessageParticipant",
"Transitions": {
"NextAction": "049fca85-b0bd-49d6-8517-2943c248cdc3",
"Errors": [
{
"NextAction": "6a6556e1-b596-4f5b-b0c1-c5ac5ab965a3",
"ErrorType": "NoMatchingError"
}
]
}
},
{
"Parameters": {},
"Identifier": "6a6556e1-b596-4f5b-b0c1-c5ac5ab965a3",
"Type": "DisconnectParticipant",
"Transitions": {}
},
{
"Parameters": {
"LambdaFunctionARN": "$.FlowAttributes.HelloLambdaArn",
"InvocationTimeLimitSeconds": "3",
"ResponseValidation": {
"ResponseType": "JSON"
}
},
"Identifier": "049fca85-b0bd-49d6-8517-2943c248cdc3",
"Type": "InvokeLambdaFunction",
"Transitions": {
"NextAction": "3e5551e7-b4b8-4051-a438-019dfe5b760b",
"Errors": [
{
"NextAction": "6a6556e1-b596-4f5b-b0c1-c5ac5ab965a3",
"ErrorType": "NoMatchingError"
}
]
}
},
{
"Parameters": {
"SSML": "<speak> <say-as interpret-as=\"date\" format=\"mmddyyyy\"> $.External.body.response </say-as> </speak>"
},
"Identifier": "3e5551e7-b4b8-4051-a438-019dfe5b760b",
"Type": "MessageParticipant",
"Transitions": {
"NextAction": "6a6556e1-b596-4f5b-b0c1-c5ac5ab965a3",
"Errors": [
{
"NextAction": "6a6556e1-b596-4f5b-b0c1-c5ac5ab965a3",
"ErrorType": "NoMatchingError"
}
]
}
}
]
}
72 changes: 72 additions & 0 deletions typescript/connect-cdk/cdk.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
{
"app": "npx ts-node --prefer-ts-exts bin/connect_cdk.ts",
"watch": {
"include": [
"**"
],
"exclude": [
"README.md",
"cdk*.json",
"**/*.d.ts",
"**/*.js",
"tsconfig.json",
"package*.json",
"yarn.lock",
"node_modules",
"test"
]
},
"context": {
"@aws-cdk/aws-lambda:recognizeLayerVersion": true,
"@aws-cdk/core:checkSecretUsage": true,
"@aws-cdk/core:target-partitions": [
"aws",
"aws-cn"
],
"@aws-cdk-containers/ecs-service-extensions:enableDefaultLogDriver": true,
"@aws-cdk/aws-ec2:uniqueImdsv2TemplateName": true,
"@aws-cdk/aws-ecs:arnFormatIncludesClusterName": true,
"@aws-cdk/aws-iam:minimizePolicies": true,
"@aws-cdk/core:validateSnapshotRemovalPolicy": true,
"@aws-cdk/aws-codepipeline:crossAccountKeyAliasStackSafeResourceName": true,
"@aws-cdk/aws-s3:createDefaultLoggingPolicy": true,
"@aws-cdk/aws-sns-subscriptions:restrictSqsDescryption": true,
"@aws-cdk/aws-apigateway:disableCloudWatchRole": true,
"@aws-cdk/core:enablePartitionLiterals": true,
"@aws-cdk/aws-events:eventsTargetQueueSameAccount": true,
"@aws-cdk/aws-ecs:disableExplicitDeploymentControllerForCircuitBreaker": true,
"@aws-cdk/aws-iam:importedRoleStackSafeDefaultPolicyName": true,
"@aws-cdk/aws-s3:serverAccessLogsUseBucketPolicy": true,
"@aws-cdk/aws-route53-patters:useCertificate": true,
"@aws-cdk/customresources:installLatestAwsSdkDefault": false,
"@aws-cdk/aws-rds:databaseProxyUniqueResourceName": true,
"@aws-cdk/aws-codedeploy:removeAlarmsFromDeploymentGroup": true,
"@aws-cdk/aws-apigateway:authorizerChangeDeploymentLogicalId": true,
"@aws-cdk/aws-ec2:launchTemplateDefaultUserData": true,
"@aws-cdk/aws-secretsmanager:useAttachedSecretResourcePolicyForSecretTargetAttachments": true,
"@aws-cdk/aws-redshift:columnId": true,
"@aws-cdk/aws-stepfunctions-tasks:enableEmrServicePolicyV2": true,
"@aws-cdk/aws-ec2:restrictDefaultSecurityGroup": true,
"@aws-cdk/aws-apigateway:requestValidatorUniqueId": true,
"@aws-cdk/aws-kms:aliasNameRef": true,
"@aws-cdk/aws-autoscaling:generateLaunchTemplateInsteadOfLaunchConfig": true,
"@aws-cdk/core:includePrefixInUniqueNameGeneration": true,
"@aws-cdk/aws-efs:denyAnonymousAccess": true,
"@aws-cdk/aws-opensearchservice:enableOpensearchMultiAzWithStandby": true,
"@aws-cdk/aws-lambda-nodejs:useLatestRuntimeVersion": true,
"@aws-cdk/aws-efs:mountTargetOrderInsensitiveLogicalId": true,
"@aws-cdk/aws-rds:auroraClusterChangeScopeOfInstanceParameterGroupWithEachParameters": true,
"@aws-cdk/aws-appsync:useArnForSourceApiAssociationIdentifier": true,
"@aws-cdk/aws-rds:preventRenderingDeprecatedCredentials": true,
"@aws-cdk/aws-codepipeline-actions:useNewDefaultBranchForCodeCommitSource": true,
"@aws-cdk/aws-cloudwatch-actions:changeLambdaPermissionLogicalIdForLambdaAction": true,
"@aws-cdk/aws-codepipeline:crossAccountKeysDefaultValueToFalse": true,
"@aws-cdk/aws-codepipeline:defaultPipelineTypeToV2": true,
"@aws-cdk/aws-kms:reduceCrossAccountRegionPolicyScope": true,
"@aws-cdk/aws-eks:nodegroupNameAttribute": true,
"@aws-cdk/aws-ec2:ebsDefaultGp3Volume": true,
"@aws-cdk/aws-ecs:removeDefaultDeploymentAlarm": true,
"@aws-cdk/custom-resources:logApiResponseDataPropertyTrueDefault": false,
"@aws-cdk/aws-s3:keepNotificationInImportedBucket": false
}
}
20 changes: 20 additions & 0 deletions typescript/connect-cdk/hellolambda/lambda_function.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import boto3
from datetime import datetime, timedelta
import logging

# Establish logging configuration
logger = logging.getLogger()

def lambda_handler(event, context):

response = {

'response': "the current date is " + datetime.now().strftime("%m-%d-%Y")
}

logger.info(response)

return {
'statusCode': 200,
'body': response
}
8 changes: 8 additions & 0 deletions typescript/connect-cdk/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = {
testEnvironment: 'node',
roots: ['<rootDir>/test'],
testMatch: ['**/*.test.ts'],
transform: {
'^.+\\.tsx?$': 'ts-jest'
}
};
Loading
Loading