Mercurial > public > tweet-analysis
comparison 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 |
comparison
equal
deleted
inserted
replaced
4:cfd876570008 | 5:54e71cf6e324 |
---|---|
11 Api: | 11 Api: |
12 Auth: | 12 Auth: |
13 ApiKeyRequired: true | 13 ApiKeyRequired: true |
14 | 14 |
15 Resources: | 15 Resources: |
16 | |
16 ## | 17 ## |
17 ### START API GATEWAY CONFIGURATION ### | 18 ### START API GATEWAY CONFIGURATION ### |
18 ## | 19 ## |
19 | 20 |
20 # Create Api version v1 | 21 # Create Api version v1 |
36 Type: AWS::ApiGateway::Deployment | 37 Type: AWS::ApiGateway::Deployment |
37 Properties: | 38 Properties: |
38 Description: Deployment of Api version 1 | 39 Description: Deployment of Api version 1 |
39 RestApiId: !Ref ServerlessRestApi | 40 RestApiId: !Ref ServerlessRestApi |
40 | 41 |
41 # Create usage plan | 42 # Create PaidUsagePlan usage plan |
42 PaidUsagePlan: | 43 PaidUsagePlan: |
43 Type: AWS::ApiGateway::UsagePlan | 44 Type: AWS::ApiGateway::UsagePlan |
44 Properties: | 45 Properties: |
45 ApiStages: | 46 ApiStages: |
46 - ApiId: !Ref ServerlessRestApi | 47 - ApiId: !Ref ServerlessRestApi |
57 - Key: "application-id" | 58 - Key: "application-id" |
58 Value: "tweet-analysis" | 59 Value: "tweet-analysis" |
59 - Key: "Name" | 60 - Key: "Name" |
60 Value: "tweet-analysis::rest-api::paid-usage-plan" | 61 Value: "tweet-analysis::rest-api::paid-usage-plan" |
61 | 62 |
62 # Create Api key | 63 # Create Api key for PaidUsagePlan |
63 PaidApiKey: | 64 PaidApiKey: |
64 Type: AWS::ApiGateway::ApiKey | 65 Type: AWS::ApiGateway::ApiKey |
65 Properties: | 66 Properties: |
66 Description: Api key for paid usage plan | 67 Description: Api key for paid usage plan |
67 Enabled: true | 68 Enabled: true |
117 HostedZoneId: Z0937998E3C5GEK4NHO9 | 118 HostedZoneId: Z0937998E3C5GEK4NHO9 |
118 Tags: | 119 Tags: |
119 - Key: "application-id" | 120 - Key: "application-id" |
120 Value: "tweet-analysis" | 121 Value: "tweet-analysis" |
121 - Key: "Name" | 122 - Key: "Name" |
122 Value: "tweet-analysis::certificate::dennistech.io" | 123 Value: "tweet-analysis::domain-certificate::dennistech.io" |
123 | 124 |
124 # Map domain to the regional domain generated by Api Gateway | 125 # Map tweet-analysis.dennistech.io to the regional domain generated by Api Gateway |
125 DomainMapping: | 126 DomainMapping: |
126 Type: AWS::Route53::RecordSet | 127 Type: AWS::Route53::RecordSet |
127 Properties: | 128 Properties: |
129 Name: tweet-analysis.dennistech.io | |
130 Comment: Map domain to the regional domain generated by Api Gateway | |
128 HostedZoneId: Z0937998E3C5GEK4NHO9 | 131 HostedZoneId: Z0937998E3C5GEK4NHO9 |
129 Name: tweet-analysis.dennistech.io | |
130 Type: A | 132 Type: A |
131 AliasTarget: | 133 AliasTarget: |
132 DNSName: !GetAtt Domain.RegionalDomainName | 134 DNSName: !GetAtt Domain.RegionalDomainName |
133 EvaluateTargetHealth: true | 135 EvaluateTargetHealth: true |
134 HostedZoneId: !GetAtt Domain.RegionalHostedZoneId | 136 HostedZoneId: !GetAtt Domain.RegionalHostedZoneId |
135 | 137 |
136 # Map paths from your domain name to your API stages | 138 # Configure mapping in API Gateway custom domain to point to v1 stage |
137 PathMapping: | 139 PathMapping: |
138 Type: AWS::ApiGateway::BasePathMapping | 140 Type: AWS::ApiGateway::BasePathMapping |
139 Properties: | 141 Properties: |
140 DomainName: !Ref Domain | 142 DomainName: !Ref Domain |
141 RestApiId: !Ref ServerlessRestApi | 143 RestApiId: !Ref ServerlessRestApi |
151 | 153 |
152 # Define lambda functions | 154 # Define lambda functions |
153 GetTweetSentimentFunction: | 155 GetTweetSentimentFunction: |
154 Type: AWS::Serverless::Function | 156 Type: AWS::Serverless::Function |
155 Properties: | 157 Properties: |
158 FunctionName: GetTweetSentimentFunction | |
156 Description: Fetch tweets and analyse sentiment using AWS Comprehend | 159 Description: Fetch tweets and analyse sentiment using AWS Comprehend |
157 CodeUri: src/ | 160 CodeUri: src/ |
158 Handler: handlers/sentiment.get_tweet_sentiment | 161 Handler: handlers/sentiment.get_tweet_sentiment |
159 Runtime: python3.9 | 162 Runtime: python3.9 |
160 Policies: | 163 Policies: |
161 - AWSSecretsManagerGetSecretValuePolicy: | 164 - AWSSecretsManagerGetSecretValuePolicy: |
162 SecretArn: | 165 SecretArn: |
163 arn:aws:secretsmanager:eu-west-2:339008578167:secret:tweet-analysis-keys-gKo6DQ | 166 arn:aws:secretsmanager:eu-west-2:339008578167:secret:tweet-analysis-keys-gKo6DQ |
167 Layers: | |
168 - !Ref TweetAnalysisSharedFunctions | |
164 Events: | 169 Events: |
165 CallGetTweetSentiment: | 170 CallGetTweetSentiment: |
166 Type: Api | 171 Type: Api |
167 Properties: | 172 Properties: |
168 Path: /sentiment | 173 Path: /sentiment |
169 Method: get | 174 Method: get |
175 RequestParameters: | |
176 - method.request.querystring.twitterUser: | |
177 Required: false | |
178 - method.request.querystring.numberOfTweets: | |
179 Required: false | |
170 Tags: | 180 Tags: |
171 Name: "tweet-analysis::get-tweet-sentiment-function" | 181 Name: "tweet-analysis::get-tweet-sentiment-function" |
182 | |
183 # Define dependencies | |
184 TweetAnalysisSharedFunctions: | |
185 Type: AWS::Serverless::LayerVersion | |
186 Properties: | |
187 Description: Shared functions across lambda functions | |
188 CompatibleRuntimes: | |
189 - python3.9 | |
190 ContentUri: dependencies/ | |
172 | 191 |
173 ## | 192 ## |
174 ### END FUNCTION CONFIGURATION ### | 193 ### END FUNCTION CONFIGURATION ### |
175 ## | 194 ## |