Mercurial > public > tweet-analysis
diff template.yaml @ 5:54e71cf6e324
refactor code
author | Dennis Concepcion Martin <dennisconcepcionmartin@gmail.com> |
---|---|
date | Fri, 17 Sep 2021 17:42:30 +0200 |
parents | cfd876570008 |
children | 6541622b6127 |
line wrap: on
line diff
--- a/template.yaml Thu Sep 16 18:03:26 2021 +0200 +++ b/template.yaml Fri Sep 17 17:42:30 2021 +0200 @@ -13,6 +13,7 @@ ApiKeyRequired: true Resources: + ## ### START API GATEWAY CONFIGURATION ### ## @@ -38,7 +39,7 @@ Description: Deployment of Api version 1 RestApiId: !Ref ServerlessRestApi - # Create usage plan + # Create PaidUsagePlan usage plan PaidUsagePlan: Type: AWS::ApiGateway::UsagePlan Properties: @@ -59,7 +60,7 @@ - Key: "Name" Value: "tweet-analysis::rest-api::paid-usage-plan" - # Create Api key + # Create Api key for PaidUsagePlan PaidApiKey: Type: AWS::ApiGateway::ApiKey Properties: @@ -119,21 +120,22 @@ - Key: "application-id" Value: "tweet-analysis" - Key: "Name" - Value: "tweet-analysis::certificate::dennistech.io" + Value: "tweet-analysis::domain-certificate::dennistech.io" - # Map domain to the regional domain generated by Api Gateway + # Map tweet-analysis.dennistech.io to the regional domain generated by Api Gateway DomainMapping: Type: AWS::Route53::RecordSet Properties: + Name: tweet-analysis.dennistech.io + Comment: Map domain to the regional domain generated by Api Gateway HostedZoneId: Z0937998E3C5GEK4NHO9 - Name: tweet-analysis.dennistech.io Type: A AliasTarget: DNSName: !GetAtt Domain.RegionalDomainName EvaluateTargetHealth: true HostedZoneId: !GetAtt Domain.RegionalHostedZoneId - # Map paths from your domain name to your API stages + # Configure mapping in API Gateway custom domain to point to v1 stage PathMapping: Type: AWS::ApiGateway::BasePathMapping Properties: @@ -153,6 +155,7 @@ GetTweetSentimentFunction: Type: AWS::Serverless::Function Properties: + FunctionName: GetTweetSentimentFunction Description: Fetch tweets and analyse sentiment using AWS Comprehend CodeUri: src/ Handler: handlers/sentiment.get_tweet_sentiment @@ -161,15 +164,31 @@ - AWSSecretsManagerGetSecretValuePolicy: SecretArn: arn:aws:secretsmanager:eu-west-2:339008578167:secret:tweet-analysis-keys-gKo6DQ + Layers: + - !Ref TweetAnalysisSharedFunctions Events: CallGetTweetSentiment: Type: Api Properties: Path: /sentiment Method: get + RequestParameters: + - method.request.querystring.twitterUser: + Required: false + - method.request.querystring.numberOfTweets: + Required: false Tags: Name: "tweet-analysis::get-tweet-sentiment-function" + # Define dependencies + TweetAnalysisSharedFunctions: + Type: AWS::Serverless::LayerVersion + Properties: + Description: Shared functions across lambda functions + CompatibleRuntimes: + - python3.9 + ContentUri: dependencies/ + ## ### END FUNCTION CONFIGURATION ### ##