-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMultilanguageBot.yaml
56 lines (49 loc) · 1.68 KB
/
MultilanguageBot.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: Multilanguage Bot.
Parameters:
CognitoStackName:
Description: Name of a Cloudformation stack containing the cross-stack Cognito resources for AuthN
Type: String
AllowedPattern : "^[a-zA-Z][a-zA-Z0-9]*$"
Resources:
# Bot API
# FYI, a good reference to setup Cognito Auth per API methods:
# https://github.com/awslabs/serverless-application-model/blob/master/examples/2016-10-31/api_cognito_auth/template.yaml
MultilanguageBotApi:
Type: AWS::Serverless::Api
Properties:
StageName: PROD
Cors: "'*'"
Auth:
DefaultAuthorizer: MyCognitoAuthorizer
Authorizers:
MyCognitoAuthorizer:
UserPoolArn: !Sub
- arn:aws:cognito-idp:${AWS::Region}:${AWS::AccountId}:userpool/${CognitoUserPoolId}
- CognitoUserPoolId:
Fn::ImportValue: !Sub ${CognitoStackName}-UserPool
MultilanguageBotFunction:
Type: AWS::Serverless::Function
Properties:
Handler: lex/botTranslator.lambda_handler
Runtime: python3.6
CodeUri: ./
Events:
MultilanguageBotApi:
Type: Api
Properties:
RestApiId: !Ref MultilanguageBotApi
Path: /MultilanguageBot
Method: POST
Policies:
- AWSLambdaExecute # Managed Policy
- AmazonLexReadOnly # Managed Policy
- ComprehendReadOnly # Managed Policy
- AmazonLexRunBotsOnly # Managed Policy
- TranslateReadOnly # Managed Policy
Outputs:
MultilanguageBotFunction:
Value: !Ref MultilanguageBotFunction
MultilanguageBotApi:
Value: !Ref MultilanguageBotApi