Skip to content

Commit 1d8fcf0

Browse files
authored
Merge pull request #759 from aws-samples/feat/streamingqna
feat: streaming support for qnabot II
2 parents a9b47d2 + 08be466 commit 1d8fcf0

File tree

3 files changed

+8
-22
lines changed

3 files changed

+8
-22
lines changed

config/utils/merge-config.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ module.exports = function mergeConfig(baseConfig, srcConfig) {
3333
key=== 'initialText' ||
3434
key=== 'avatarImageUrl' ||
3535
key=== 'toolbarLogo' ||
36+
key=== 'streamingWebSocketEndpoint' ||
37+
key=== 'streamingDynamoDbTable' ||
3638
!isEmpty(srcConfig[key]) ) {
3739
value = (typeof (baseConfig[key]) === 'object') ?
3840
// recursively merge sub-objects in both directions

templates/codebuild-deploy.yaml

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -546,13 +546,7 @@ Parameters:
546546
Type: String
547547
Default: ''
548548
Description: >
549-
If not using the Web socket endpoint created via AllowStreamingResponses, you can optionally specify an alternative streaming endpoint here
550-
551-
StreamingDynamoDbTable:
552-
Type: String
553-
Default: ''
554-
Description: >
555-
If not using the DynamoDB table through Lex Web UI, you can optionally specify an alternative table for streaming purposes here
549+
If you have an existing WebSocket API Gateway endpoint, you can specify it using this parameter. This requires parameter AllowStreamingResponses set to True.
556550
557551
ShouldEnableUpload:
558552
Type: String
@@ -587,8 +581,7 @@ Conditions:
587581
UseDefaultCloudfrontUrl: !Or [ !Equals [!Ref WebAppConfCname, ''], !Equals [!Ref WebAppAcmCertificateArn, ''] ]
588582
ShouldNotSpecifyWafAcl: !Equals [!Ref WebAppWafAclArn, '']
589583
EnableStreaming: !Equals [!Ref AllowStreamingResponses, true]
590-
HasStreamingWebSocketEndpoint: !Not [!Equals [!Ref StreamingWebSocketEndpoint, ""]]
591-
HasStreamingDynamoDbTable: !Not [!Equals [!Ref StreamingDynamoDbTable, ""]]
584+
DeployStreamingStack: !And [!Equals [!Ref AllowStreamingResponses, true], !Equals [!Ref StreamingWebSocketEndpoint, ""]]
592585
EnableUpload: !Equals [!Ref ShouldEnableUpload, true]
593586
NeedsVpc: !And [ !Not [ !Equals [!Ref VpcSubnetId, ''] ], !Not [ !Equals [!Ref VpcSecurityGroupId, ''] ] ]
594587

@@ -816,7 +809,7 @@ Resources:
816809

817810
StreamingSupport:
818811
Type: AWS::CloudFormation::Stack
819-
Condition: EnableStreaming
812+
Condition: DeployStreamingStack
820813
Properties:
821814
TimeoutInMinutes: 15
822815
TemplateURL: !Sub "https://${SourceBucket}.s3.${AWS::Region}.amazonaws.com/${SourcePrefix}/templates/streaming-support.yaml"
@@ -980,9 +973,9 @@ Resources:
980973
- Name: ALLOW_STREAMING_RESPONSES
981974
Value: !Ref AllowStreamingResponses
982975
- Name: STREAMING_WEB_SOCKET_ENDPOINT
983-
Value: !If [EnableStreaming, !If [HasStreamingWebSocketEndpoint, !Ref StreamingWebSocketEndpoint, !Sub "wss://${StreamingSupport.Outputs.WebSocketId}.execute-api.${AWS::Region}.amazonaws.com/Prod"], ""]
976+
Value: !If [DeployStreamingStack, !Sub "wss://${StreamingSupport.Outputs.WebSocketId}.execute-api.${AWS::Region}.amazonaws.com/Prod", !If [EnableStreaming, !Ref StreamingWebSocketEndpoint, ""]]
984977
- Name: STREAMING_DYNAMO_TABLE
985-
Value: !If [EnableStreaming, !If [HasStreamingDynamoDbTable, !Ref StreamingDynamoDbTable, !Sub "${StreamingSupport.Outputs.DynamoTableName}"], ""]
978+
Value: !If [DeployStreamingStack, !Sub "${StreamingSupport.Outputs.DynamoTableName}", ""]
986979
- Name: ENABLE_UPLOAD
987980
Value: !Ref ShouldEnableUpload
988981
- Name: UPLOAD_BUCKET_NAME
@@ -1074,7 +1067,6 @@ Resources:
10741067
BotAvatarImgUrl: !Ref BotAvatarImgUrl
10751068
AllowStreamingResponses: !Ref AllowStreamingResponses
10761069
StreamingWebSocketEndpoint: !Ref StreamingWebSocketEndpoint
1077-
StreamingDynamoDbTable: !Ref StreamingDynamoDbTable
10781070
ShouldEnableUpload: !Ref ShouldEnableUpload
10791071
UploadBucket: !Ref UploadBucket
10801072
Timestamp: !Ref Timestamp

templates/master.yaml

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -574,13 +574,7 @@ Parameters:
574574
Type: String
575575
Default: ''
576576
Description: >
577-
If not using the Web socket endpoint created via AllowStreamingResponses, you can optionally specify an alternative streaming endpoint here
578-
579-
StreamingDynamoDbTable:
580-
Type: String
581-
Default: ''
582-
Description: >
583-
If not using the DynamoDB table through Lex Web UI, you can optionally specify an alternative table for streaming purposes here
577+
If you have an existing WebSocket API Gateway endpoint, you can specify it using this parameter. This requires parameter AllowStreamingResponses set to True.
584578
585579
ShouldEnableUpload:
586580
Type: String
@@ -675,7 +669,6 @@ Metadata:
675669
- retryCountPostTextTimeout
676670
- AllowStreamingResponses
677671
- StreamingWebSocketEndpoint
678-
- StreamingDynamoDbTable
679672
- ShouldEnableUpload
680673
- UploadBucket
681674
- Label:
@@ -812,7 +805,6 @@ Resources:
812805
SourceBucket: !Ref BootstrapBucket
813806
SourcePrefix: !Ref BootstrapPrefix
814807
StreamingWebSocketEndpoint: !Ref StreamingWebSocketEndpoint
815-
StreamingDynamoDbTable: !Ref StreamingDynamoDbTable
816808
SourceObject: !Sub "${BootstrapPrefix}/src-v0.21.6.zip"
817809
CustomResourceCodeObject: !Sub "${BootstrapPrefix}/custom-resources-v0.21.6.zip"
818810
InitiateChatLambdaCodeObject: !Sub "${BootstrapPrefix}/initiate-chat-lambda-v0.21.6.zip"

0 commit comments

Comments
 (0)