cloudformationTemplates/asyncCustomerChatUX/cloudformation.yaml [578:682]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
            ResponseTemplates:
              application/json: ''
            StatusCode: '200'
        PassthroughBehavior: NEVER
        RequestTemplates:
          application/json: '{"statusCode": 200}'
      MethodResponses:
        - ResponseModels:
            application/json: Empty
          ResponseParameters:
            method.response.header.Access-Control-Allow-Headers: true
            method.response.header.Access-Control-Allow-Methods: true
            method.response.header.Access-Control-Allow-Origin: true
          StatusCode: '200'

  ### Generate Index.html file ####

  ChatUXCreator:
    Type: "AWS::Lambda::Function"
    Properties:
      Description:  >
        AWS Lambda Function that will create the chat UX and upload it to the S3 bucket
      Handler: "websiteCreator.handler"
      Role: !GetAtt ChatUXCreatorRole.Arn
      Runtime: "nodejs10.x"
      MemorySize: 256
      Timeout: 120
      Code:
        S3Bucket:
          !Join
            - '.'
            - - !Ref 'AWS::Region'
              - !FindInMap [FunctionMap, Configuration, S3Bucket]
        S3Key: !Join ["", [!FindInMap [FunctionMap, Configuration, S3Key], 'create-website.zip']]

  InvokeChatUXCreator:
    Type: Custom::CreateChatUX
    DependsOn:
      - CreateWebsiteS3Bucket
    Properties:
      S3Bucket:
        !Ref WebsiteS3BucketName
      ApiGatewayId:
        !Ref ApiGatewayRestAPI
      Region:
        !Ref AWS::Region
      ServiceToken:
        !GetAtt ChatUXCreator.Arn
      InstanceId:
        !Ref instanceId
      ContactFlowId:
        !Ref contactFlowId
      EnableAttachments:
        !Ref enableAttachments

  ChatUXCreatorRole:
    Type: "AWS::IAM::Role"
    Properties:
      AssumeRolePolicyDocument:
        Version: "2012-10-17"
        Statement:
          - Effect: "Allow"
            Principal:
              Service:
                - "lambda.amazonaws.com"
            Action:
              - "sts:AssumeRole"
      Path: "/"
      Policies:
        - PolicyName: contact-flow-creator-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:
                  - "s3:PutObject"
                Resource:
                  - !Sub ${CreateWebsiteS3Bucket.Arn}/*

Outputs:
  cloudFrontDistribution:
    Description:  The domain name of the CloudFront Distribution to host the chat website
    Value: !GetAtt CloudFrontDistribution.DomainName
  initiateChatLambda:
    Description:  The ARN of the Lambda function created to initiate chat
    Value: !GetAtt InitiateChatLambda.Arn
  apiGatewayEndpoint:
    Description:  The ARN of the API Gateway endpoint that triggers the Lambda function to initiate the chat
    Value: !Ref ApiGatewayRestAPI
  InitiateChatLambdaExecutionRole:
    Description:  The ARN of the IAM role used by the Lambda function to initiate the chat
    Value: !GetAtt InitiateChatLambdaExecutionRole.Arn
  websiteS3Bucket:
    Description:  The ARN of the S3 Bucket used to host the website
    Value: !GetAtt CreateWebsiteS3Bucket.Arn
  chatContactDataTable:
    Description: Name of the new table to store the contact data related to chats.
    Value: !Ref chatContactDataTable
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



cloudformationTemplates/urlPreviewForAsyncChat/cloudformation.yaml [724:828]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
            ResponseTemplates:
              application/json: ''
            StatusCode: '200'
        PassthroughBehavior: NEVER
        RequestTemplates:
          application/json: '{"statusCode": 200}'
      MethodResponses:
        - ResponseModels:
            application/json: Empty
          ResponseParameters:
            method.response.header.Access-Control-Allow-Headers: true
            method.response.header.Access-Control-Allow-Methods: true
            method.response.header.Access-Control-Allow-Origin: true
          StatusCode: '200'
  
  ### Generate Index.html file ####

  ChatUXCreator:
    Type: "AWS::Lambda::Function"
    Properties:
      Description:  >
        AWS Lambda Function that will create the chat UX and upload it to the S3 bucket
      Handler: "websiteCreator.handler"
      Role: !GetAtt ChatUXCreatorRole.Arn
      Runtime: "nodejs10.x"
      MemorySize: 256
      Timeout: 120
      Code:
        S3Bucket:
          !Join
            - '.'
            - - !Ref 'AWS::Region'
              - !FindInMap [FunctionMap, Configuration, S3Bucket]
        S3Key: !Join ["", [!FindInMap [FunctionMap, Configuration, S3Key], 'create-website.zip']]

  InvokeChatUXCreator:
    Type: Custom::CreateChatUX
    DependsOn:
      - CreateWebsiteS3Bucket
    Properties:
      S3Bucket:
        !Ref WebsiteS3BucketName
      ApiGatewayId:
        !Ref ApiGatewayRestAPI
      Region:
        !Ref AWS::Region
      ServiceToken:
        !GetAtt ChatUXCreator.Arn
      InstanceId:
        !Ref instanceId
      ContactFlowId:
        !Ref contactFlowId
      EnableAttachments:
        !Ref enableAttachments

  ChatUXCreatorRole:
    Type: "AWS::IAM::Role"
    Properties:
      AssumeRolePolicyDocument:
        Version: "2012-10-17"
        Statement:
          - Effect: "Allow"
            Principal:
              Service:
                - "lambda.amazonaws.com"
            Action:
              - "sts:AssumeRole"
      Path: "/"
      Policies:
        - PolicyName: contact-flow-creator-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:
                  - "s3:PutObject"
                Resource:
                  - !Sub ${CreateWebsiteS3Bucket.Arn}/*

Outputs:
  cloudFrontDistribution:
    Description:  The domain name of the CloudFront Distribution to host the chat website
    Value: !GetAtt CloudFrontDistribution.DomainName
  initiateChatLambda:
    Description:  The ARN of the Lambda function created to initiate chat
    Value: !GetAtt InitiateChatLambda.Arn
  apiGatewayEndpoint:
    Description:  The ARN of the API Gateway endpoint that triggers the Lambda function to initiate the chat
    Value: !Ref ApiGatewayRestAPI
  InitiateChatLambdaExecutionRole:
    Description:  The ARN of the IAM role used by the Lambda function to initiate the chat
    Value: !GetAtt InitiateChatLambdaExecutionRole.Arn
  websiteS3Bucket:
    Description:  The ARN of the S3 Bucket used to host the website
    Value: !GetAtt CreateWebsiteS3Bucket.Arn
  chatContactDataTable:
    Description: Name of the new table to store the contact data related to chats.
    Value: !Ref chatContactDataTable
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



