Skip to content
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

Fixed the CFN templates for the chatbot to use mappings for region #149

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -7,56 +7,59 @@ Parameters:
Default: "https://aws.amazon.com/blogs/database/category/database/amazon-neptune/"
Description: "The blog url"
Type: String
Mappings:
RegionMap:
us-east-1:
"bucket": "aws-neptune-customer-samples-us-east-1"
us-west-2:
"bucket": "aws-neptune-customer-samples-us-west-2"
Resources:
# Upload Layers
# Upload Layers
CRHelperLayer:
Type: AWS::Lambda::LayerVersion
Properties:
CompatibleRuntimes:
- python3.7
- python3.8
- python3.8
Content:
S3Bucket:
Fn::Join:
- ''
- - 'aws-neptune-customer-samples-'
- Ref: AWS::Region
S3Bucket:
Fn::FindInMap:
- RegionMap
- Ref: AWS::Region
- bucket
S3Key: chatbot-blog/crhelper-layer.zip
Description: Python 3.7 Lambda Layer with crhelper library for creating custom CFN resources
Description: Python 3.8 Lambda Layer with crhelper library for creating custom CFN resources
LayerName: crhelper
PillowLayer:
Type: AWS::Lambda::LayerVersion
Properties:
CompatibleRuntimes:
- python3.7
- python3.8
- python3.8
Content:
S3Bucket:
Fn::Join:
- ''
- - 'aws-neptune-customer-samples-'
- Ref: AWS::Region
S3Bucket:
Fn::FindInMap:
- RegionMap
- Ref: AWS::Region
- bucket
S3Key: chatbot-blog/Pillow.zip
Description: Python 3.7 Lambda Layer with aPillow
Description: Python 3.8 Lambda Layer with aPillow
LayerName: Pillow
BlogParserLayer:
Type: AWS::Lambda::LayerVersion
Properties:
CompatibleRuntimes:
- python3.7
- python3.8
- python3.8
Content:
S3Bucket:
Fn::Join:
- ''
- - 'aws-neptune-customer-samples-'
- Ref: AWS::Region
S3Bucket:
Fn::FindInMap:
- RegionMap
- Ref: AWS::Region
- bucket
S3Key: chatbot-blog/blogparser.zip
Description: Python 3.7 Lambda Layer with boto3, beautifulsoup, and requests
Description: Python 3.8 Lambda Layer with boto3, beautifulsoup, and requests
LayerName: blog-parser


#Create Lambda Role
#Create Lambda Role
BlogParserRole:
Type: AWS::IAM::Role
Properties:
Expand All @@ -70,7 +73,7 @@ Resources:
Action:
- sts:AssumeRole
ManagedPolicyArns:
- "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
- "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
Policies:
- PolicyName: blog-chatbot-blogparser
PolicyDocument:
Expand All @@ -79,7 +82,7 @@ Resources:
- Effect: Allow
Action:
- comprehend:BatchDetectEntities
Resource: "*"
Resource: "*"
- PolicyName: blog-chatbot-blogparser-lambda-role
PolicyDocument:
Version: '2012-10-17'
Expand All @@ -88,42 +91,42 @@ Resources:
Action:
- lambda:InvokeFunction
Resource: !Ref ChatBotDatabaseLoaderArn
# Upload Custom Deploy Function

# Upload Custom Deploy Function
BlogParserLambda:
Type: AWS::Lambda::Function
DependsOn:
- CRHelperLayer
- PillowLayer
- BlogParserLayer
- BlogParserRole
DependsOn:
- CRHelperLayer
- PillowLayer
- BlogParserLayer
- BlogParserRole
Properties:
Code:
S3Bucket:
Fn::Join:
- ''
- - 'aws-neptune-customer-samples-'
- Ref: AWS::Region
S3Bucket:
Fn::FindInMap:
- RegionMap
- Ref: AWS::Region
- bucket
S3Key: chatbot-blog/blog-chatbot-blog-parser.zip
Description: Custom CFN Resource for parsing the blogs
FunctionName: chatbot-blog-parser
Handler: lambda_function.lambda_handler
Layers:
- !Ref CRHelperLayer
- !Ref PillowLayer
- !Ref BlogParserLayer
- !Ref CRHelperLayer
- !Ref PillowLayer
- !Ref BlogParserLayer
Role: !GetAtt BlogParserRole.Arn
Runtime: python3.7
Runtime: python3.8
Timeout: 600

#Call Custom Function
BlogParserResource:
Type: "Custom::BlogParserLambda"
DependsOn:
- BlogParserLambda
DependsOn:
- BlogParserLambda
Properties:
ServiceToken: !GetAtt BlogParserLambda.Arn
URL: !Ref BlogURL
Outputs:
Sum:
Value: !GetAtt BlogParserResource.Status
Value: !GetAtt BlogParserResource.Status
Loading