comparison template.yaml @ 2:561bc303784f

customize api gateway resources
author Dennis Concepcion Martin <dennisconcepcionmartin@gmail.com>
date Thu, 16 Sep 2021 11:36:21 +0200
parents 0277e7fc0f0a
children 5c36f51105c2
comparison
equal deleted inserted replaced
1:0277e7fc0f0a 2:561bc303784f
9 Tags: 9 Tags:
10 application-id: "tweet-analysis" 10 application-id: "tweet-analysis"
11 Api: 11 Api:
12 Auth: 12 Auth:
13 ApiKeyRequired: true 13 ApiKeyRequired: true
14 UsagePlan:
15 CreateUsagePlan: PER_API
16 14
17 Resources: 15 Resources:
16 ##
17 ### START API GATEWAY CONFIGURATION ###
18 ##
19
20 # Create Api version v1
21 V1Stage:
22 Type: AWS::ApiGateway::Stage
23 Properties:
24 DeploymentId: !Ref V1StageDeployment
25 Description: Api version 1
26 RestApiId: !Ref ServerlessRestApi
27 StageName: v1
28 Tags:
29 - Key: "application-id"
30 Value: "tweet-analysis"
31 - Key: "Name"
32 Value: "tweet-analysis::rest-api::v1"
33
34 # Deploy Api version 1
35 V1StageDeployment:
36 Type: AWS::ApiGateway::Deployment
37 Properties:
38 Description: Deployment of Api version 1
39 RestApiId: !Ref ServerlessRestApi
40
41 # Create usage plan
42 PaidUsagePlan:
43 Type: AWS::ApiGateway::UsagePlan
44 Properties:
45 ApiStages:
46 - ApiId: !Ref ServerlessRestApi
47 Stage: !Ref V1Stage
48 Description: Api usage plan
49 Quota:
50 Limit: 10000
51 Period: MONTH
52 Throttle:
53 BurstLimit: 100
54 RateLimit: 20
55 UsagePlanName: PaidUsagePlan
56 Tags:
57 - Key: "application-id"
58 Value: "tweet-analysis"
59 - Key: "Name"
60 Value: "tweet-analysis::rest-api::paid-usage-plan"
61
62 # Create Api key
63 PaidApiKey:
64 Type: AWS::ApiGateway::ApiKey
65 Properties:
66 Description: Api key for paid usage plan
67 Enabled: true
68 StageKeys:
69 - RestApiId: !Ref ServerlessRestApi
70 StageName: !Ref V1Stage
71 Tags:
72 - Key: "application-id"
73 Value: "tweet-analysis"
74 - Key: "Name"
75 Value: "tweet-analysis::rest-api::key"
76
77 # Attach the created api key to the usage plan
78 PaidUsagePlanKey:
79 Type: AWS::ApiGateway::UsagePlanKey
80 Properties:
81 KeyId: !Ref PaidApiKey
82 KeyType: API_KEY
83 UsagePlanId: !Ref PaidUsagePlan
84
18 # Create custom domain in Api Gateway 85 # Create custom domain in Api Gateway
19 Domain: 86 Domain:
20 Type: AWS::ApiGateway::DomainName 87 Type: AWS::ApiGateway::DomainName
21 Properties: 88 Properties:
22 RegionalCertificateArn: !Ref DomainCertificate 89 RegionalCertificateArn: !Ref DomainCertificate
28 Tags: 95 Tags:
29 - Key: "application-id" 96 - Key: "application-id"
30 Value: "tweet-analysis" 97 Value: "tweet-analysis"
31 - Key: "Name" 98 - Key: "Name"
32 Value: "tweet-analysis::api-custom-domain" 99 Value: "tweet-analysis::api-custom-domain"
100
101 ##
102 ### END API CONFIGURATION ###
103 ##
104
105 ##
106 ### START DOMAIN CONFIGURATION ###
107 ##
33 108
34 # Create domain SSL certificate 109 # Create domain SSL certificate
35 DomainCertificate: 110 DomainCertificate:
36 Type: AWS::CertificateManager::Certificate 111 Type: AWS::CertificateManager::Certificate
37 Properties: 112 Properties:
62 PathMapping: 137 PathMapping:
63 Type: AWS::ApiGateway::BasePathMapping 138 Type: AWS::ApiGateway::BasePathMapping
64 Properties: 139 Properties:
65 DomainName: !Ref Domain 140 DomainName: !Ref Domain
66 RestApiId: !Ref ServerlessRestApi 141 RestApiId: !Ref ServerlessRestApi
67 Stage: Prod 142 Stage: v1
143
144 ##
145 ### END DOMAIN CONFIGURATION ###
146 ##
147
148 ##
149 ### START FUNCTION CONFIGURATION ###
150 ##
68 151
69 # Define lambda functions 152 # Define lambda functions
70 GetTweetSentimentFunction: 153 GetTweetSentimentFunction:
71 Type: AWS::Serverless::Function 154 Type: AWS::Serverless::Function
72 Properties: 155 Properties:
80 CallGetTweetSentiment: 163 CallGetTweetSentiment:
81 Type: Api 164 Type: Api
82 Properties: 165 Properties:
83 Path: /sentiment 166 Path: /sentiment
84 Method: get 167 Method: get
168
169 ##
170 ### END FUNCTION CONFIGURATION ###
171 ##