-
Notifications
You must be signed in to change notification settings - Fork 10
CS-1124 Cloud Formation Template for Sugar Portal Chat #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
rogeryang-sugarcrm
wants to merge
1
commit into
sugarcrm:master
Choose a base branch
from
rogeryang-sugarcrm:cs-1124
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,151 @@ | ||
| AWSTemplateFormatVersion: '2010-09-09' | ||
|
|
||
| Description: > | ||
| SugarCRM Portal Chat AWS Cloud Formation Template | ||
|
|
||
| Mappings: | ||
| LambdaMap: | ||
| Layer: | ||
| S3Path: 'sugar/lambda/layers/' # The S3 path to Lambda Layer files | ||
| ChatSDKLayerS3Key: 'aws-connect-chat-sdk.zip' # The S3 key of the AWS Connect Chat SDK | ||
| Function: | ||
| S3Path: 'sugar/lambda/functions/' # The S3 path to Lambda Function files | ||
| StartChatLambdaS3Key: 'aws-connect-start-chat.zip' # The S3 key of AWS Connect start chat Lambda | ||
| RuntimeMap: | ||
| Node: | ||
| 12x: 'nodejs12.x' | ||
|
|
||
| Parameters: | ||
| lambdaS3Bucket: | ||
| Type: String | ||
| Description: > | ||
| The S3 bucket name for Lambda resources required by this template. | ||
| The bucket must be in the region as this CloudFormation stack | ||
| awsConnectInstanceId: | ||
| Type: String | ||
| Description: > | ||
| The ID of the AWS Connect Instance | ||
| AllowedPattern: '\w{8}-\w{4}-\w{4}-\w{4}-\w{12}' | ||
| awsConnectContactFlowId: | ||
| Type: String | ||
| Description: > | ||
| The ID of the AWS Connect Contact Flow that will be used for Sugar Portal Chat | ||
| AllowedPattern: '\w{8}-\w{4}-\w{4}-\w{4}-\w{12}' | ||
|
|
||
| Resources: | ||
| #### Lambda ##### | ||
| AwsConnectChatSDKLayer: | ||
| Type: AWS::Lambda::LayerVersion | ||
| Properties: | ||
| CompatibleRuntimes: | ||
| - !FindInMap [RuntimeMap, Node, 12x] | ||
| Content: | ||
| S3Bucket: !Ref lambdaS3Bucket | ||
| S3Key: | ||
| !Join | ||
| - '' | ||
| - - !FindInMap [LambdaMap, Layer, S3Path] | ||
| - !FindInMap [LambdaMap, Layer, ChatSDKLayerS3Key] | ||
| Description: > | ||
| The Lambda layer for AWS Connect Chat | ||
| AwsConnectStartChatLambda: | ||
| Type: 'AWS::Lambda::Function' | ||
| Properties: | ||
| Description: AWS Lambda Function to initiate the chat with the end user | ||
| Handler: 'awsConnectStartChatContact.handler' #todo: update with Lambda function name | ||
| Role: !GetAtt AwsConnectStartChatLambdaExecutionRole.Arn | ||
| Runtime: !FindInMap [RuntimeMap, Node, 12x] | ||
| MemorySize: 128 | ||
| Timeout: 30 | ||
| Layers: | ||
| - !Ref AwsConnectChatSDKLayer | ||
| Environment: | ||
| Variables: | ||
| INSTANCE_ID: !Ref awsConnectInstanceId | ||
| CONTACT_FLOW_ID: !Ref awsConnectContactFlowId | ||
| Code: | ||
| S3Bucket: !Ref lambdaS3Bucket | ||
| S3Key: | ||
| !Join | ||
| - '' | ||
| - - !FindInMap [LambdaMap, Function, S3Path] | ||
| - !FindInMap [LambdaMap, Function, StartChatLambdaS3Key] | ||
| AwsConnectStartChatLambdaExecutionRole: | ||
| Type: 'AWS::IAM::Role' | ||
| Properties: | ||
| AssumeRolePolicyDocument: | ||
| Version: '2012-10-17' | ||
| Statement: | ||
| - Effect: 'Allow' | ||
| Principal: | ||
| Service: | ||
| - 'lambda.amazonaws.com' | ||
| Action: | ||
| - 'sts:AssumeRole' | ||
| Path: '/' | ||
| Policies: | ||
| - PolicyName: aws-connect-start-chat-execution-policy | ||
| PolicyDocument: | ||
| Version: '2012-10-17' | ||
| Statement: | ||
| - Effect: 'Allow' # Grant write access to CloudWatch logs | ||
| Action: | ||
| - 'logs:CreateLogGroup' | ||
| - 'logs:CreateLogStream' | ||
| - 'logs:PutLogEvents' | ||
| Resource: | ||
| - !Sub 'arn:${AWS::Partition}:logs:${AWS::Region}:${AWS::AccountId}:log-group:/aws/lambda/*' | ||
| - Effect: 'Allow' # Grant access to start a new chat in AWS Connect | ||
| Action: | ||
| - 'connect:StartChatContact' | ||
| Resource: | ||
| - !Sub 'arn:${AWS::Partition}:connect:${AWS::Region}:${AWS::AccountId}:instance/${awsConnectInstanceId}' | ||
| - !Sub 'arn:${AWS::Partition}:connect:${AWS::Region}:${AWS::AccountId}:instance/${awsConnectInstanceId}/*' | ||
|
|
||
| #### API Gateway ##### | ||
| AwsConnectChatRestApi: | ||
| Type: AWS::ApiGateway::RestApi | ||
| Properties: | ||
| Name: 'AwsConnectChatRestApi' | ||
| Description: > | ||
| REST API to initiate chat with AWS Connect | ||
| LambdaApiGatewayInvokePermission: | ||
| Type: AWS::Lambda::Permission | ||
| Properties: | ||
| Action: 'lambda:InvokeFunction' | ||
| FunctionName: !GetAtt AwsConnectStartChatLambda.Arn | ||
| Principal: 'apigateway.amazonaws.com' | ||
| SourceArn: !Sub 'arn:aws:execute-api:${AWS::Region}:${AWS::AccountId}:${AwsConnectChatRestApi}/*' | ||
| ApiGatewayDeployment: | ||
| Type: AWS::ApiGateway::Deployment | ||
| DependsOn: | ||
| - ApiGatewayRootMethod | ||
| Properties: | ||
| RestApiId: !Ref AwsConnectChatRestApi | ||
| StageName: 'Prod' | ||
| ApiGatewayRootMethod: | ||
| Type: AWS::ApiGateway::Method | ||
| DependsOn: LambdaApiGatewayInvokePermission | ||
| Properties: | ||
| AuthorizationType: 'NONE' | ||
| HttpMethod: 'POST' | ||
| Integration: | ||
| IntegrationHttpMethod: 'POST' | ||
| Type: 'AWS_PROXY' | ||
| Uri: !Sub | ||
| - 'arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${lambdaArn}/invocations' | ||
| - lambdaArn: !GetAtt AwsConnectStartChatLambda.Arn | ||
| PassthroughBehavior: WHEN_NO_MATCH | ||
| ResourceId: !GetAtt AwsConnectChatRestApi.RootResourceId | ||
| RestApiId: !Ref AwsConnectChatRestApi | ||
| MethodResponses: | ||
| - StatusCode: '200' | ||
| ResponseParameters: | ||
| method.response.header.Access-Control-Allow-Origin: true | ||
| ResponseModels: | ||
| application/json: Empty | ||
| - StatusCode: '500' | ||
| ResponseParameters: | ||
| method.response.header.Access-Control-Allow-Origin: true | ||
| ResponseModels: | ||
| application/json: Empty | ||
Binary file not shown.
Binary file not shown.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to make sure to update this to the actual Lambda function name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we have a ticket for this? if not, can we create one so we don't forget about this. Also please don't forget to link these tickets