Skip to content

Commit ddff359

Browse files
committed
add docs and fix tests
1 parent 467fef9 commit ddff359

File tree

4 files changed

+314
-525
lines changed

4 files changed

+314
-525
lines changed
Lines changed: 101 additions & 168 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
{
22
"Parameters": {
3-
"MyHostedZone": {
4-
"Default": "myregionalhostedzoneid",
3+
"ACMCertificateArn": {
4+
"Default": "cert-arn-in-us-east-1",
55
"Type": "String"
66
},
7-
"MyDomainName": {
8-
"Default": "api-edge.com",
9-
"Type": "String"
10-
},
11-
"MyDomainCert": {
12-
"Default": "my-edge-api-arn",
7+
"DomainName": {
8+
"Default": "example.com",
139
"Type": "String"
1410
}
1511
},
@@ -36,7 +32,7 @@
3632
]
3733
}
3834
},
39-
"MyFunctionImplicitGetPermissionProd": {
35+
"MyFunctionFetchPermissionProd": {
4036
"Type": "AWS::Lambda::Permission",
4137
"Properties": {
4238
"Action": "lambda:invokeFunction",
@@ -46,109 +42,146 @@
4642
},
4743
"SourceArn": {
4844
"Fn::Sub": [
49-
"arn:aws:execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__}/${__Stage__}/POST/implicit",
45+
"arn:aws:execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__}/${__Stage__}/POST/fetch",
5046
{
5147
"__Stage__": "*",
5248
"__ApiId__": {
53-
"Ref": "ServerlessRestApi"
49+
"Ref": "MyApi"
5450
}
5551
}
5652
]
5753
}
5854
}
5955
},
60-
"RecordSetGroup2102f285a7": {
56+
"ApiGatewayDomainName0caaf24ab1": {
57+
"Type": "AWS::ApiGateway::DomainName",
58+
"Properties": {
59+
"CertificateArn": "cert-arn-in-us-east-1",
60+
"EndpointConfiguration": {
61+
"Types": [
62+
"EDGE"
63+
]
64+
},
65+
"DomainName": "example.com"
66+
}
67+
},
68+
"MyApiProdStage": {
69+
"Type": "AWS::ApiGateway::Stage",
70+
"Properties": {
71+
"DeploymentId": {
72+
"Ref": "MyApiDeployment967cf1a6ff"
73+
},
74+
"RestApiId": {
75+
"Ref": "MyApi"
76+
},
77+
"StageName": "Prod"
78+
}
79+
},
80+
"RecordSetGroupbd00d962a4": {
6181
"Type": "AWS::Route53::RecordSetGroup",
6282
"Properties": {
63-
"HostedZoneId": "myregionalhostedzoneid",
83+
"HostedZoneId": "ZQ1UAL4EFZVME",
6484
"RecordSets": [
6585
{
6686
"AliasTarget": {
67-
"EvaluateTargetHealth": true,
68-
"HostedZoneId": {
87+
"HostedZoneId": "Z2FDTNDATAQYW2",
88+
"DNSName": {
6989
"Fn::GetAtt": [
70-
"ApiGatewayDomainNameb4325e3ba6",
71-
"RegionalHostedZoneId"
90+
"Distribution",
91+
"DomainName"
7292
]
73-
},
93+
}
94+
},
95+
"Type": "A",
96+
"Name": "example.com"
97+
},
98+
{
99+
"AliasTarget": {
100+
"HostedZoneId": "Z2FDTNDATAQYW2",
74101
"DNSName": {
75102
"Fn::GetAtt": [
76-
"ApiGatewayDomainNameb4325e3ba6",
77-
"RegionalDomainName"
103+
"Distribution",
104+
"DomainName"
78105
]
79106
}
80107
},
81-
"Type": "A",
82-
"Name": "api-edge.com"
108+
"Type": "AAAA",
109+
"Name": "example.com"
83110
}
84111
]
85112
}
86113
},
87-
"ServerlessRestApiBasePathMapping": {
114+
"MyApifetchBasePathMapping": {
88115
"Type": "AWS::ApiGateway::BasePathMapping",
89116
"Properties": {
90-
"DomainName": "api-edge.com",
117+
"BasePath": "fetch",
118+
"DomainName": "example.com",
91119
"RestApiId": {
92-
"Ref": "ServerlessRestApi"
120+
"Ref": "MyApi"
93121
},
94122
"Stage": {
95-
"Ref": "ServerlessRestApiProdStage"
123+
"Ref": "MyApiProdStage"
96124
}
97125
}
98126
},
99-
"MyFunctionFetchPermissionProd": {
100-
"Type": "AWS::Lambda::Permission",
127+
"Distribution": {
128+
"Type": "AWS::CloudFront::Distribution",
101129
"Properties": {
102-
"Action": "lambda:invokeFunction",
103-
"Principal": "apigateway.amazonaws.com",
104-
"FunctionName": {
105-
"Ref": "MyFunction"
106-
},
107-
"SourceArn": {
108-
"Fn::Sub": [
109-
"arn:aws:execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__}/${__Stage__}/POST/fetch/another",
130+
"DistributionConfig": {
131+
"Origins": [
110132
{
111-
"__Stage__": "*",
112-
"__ApiId__": {
113-
"Ref": "MyApi"
133+
"DomainName": {
134+
"Ref": "DomainName"
135+
},
136+
"Id": {
137+
"Ref": "DomainName"
138+
},
139+
"CustomOriginConfig": {
140+
"OriginProtocolPolicy": "https-only",
141+
"HTTPPort": 80,
142+
"HTTPSPort": 443
114143
}
115144
}
116-
]
145+
],
146+
"PriceClass": "PriceClass_100",
147+
"Enabled": true,
148+
"DefaultCacheBehavior": {
149+
"Compress": true,
150+
"TargetOriginId": {
151+
"Ref": "DomainName"
152+
},
153+
"ViewerProtocolPolicy": "redirect-to-https",
154+
"ForwardedValues": {
155+
"QueryString": false
156+
},
157+
"SmoothStreaming": false,
158+
"AllowedMethods": [
159+
"HEAD",
160+
"DELETE",
161+
"POST",
162+
"GET",
163+
"OPTIONS",
164+
"PUT",
165+
"PATCH"
166+
]
167+
},
168+
"ViewerCertificate": {
169+
"SslSupportMethod": "sni-only",
170+
"AcmCertificateArn": {
171+
"Ref": "ACMCertificateArn"
172+
}
173+
},
174+
"HttpVersion": "http2"
117175
}
118176
}
119177
},
120-
"ServerlessRestApiProdStage": {
121-
"Type": "AWS::ApiGateway::Stage",
122-
"Properties": {
123-
"DeploymentId": {
124-
"Ref": "ServerlessRestApiDeployment5332408c06"
125-
},
126-
"RestApiId": {
127-
"Ref": "ServerlessRestApi"
128-
},
129-
"StageName": "Prod"
130-
}
131-
},
132-
"MyApiDeploymentb23755fe76": {
178+
"MyApiDeployment967cf1a6ff": {
133179
"Type": "AWS::ApiGateway::Deployment",
134180
"Properties": {
135181
"RestApiId": {
136182
"Ref": "MyApi"
137183
},
138-
"Description": "RestApi deployment id: b23755fe76eda84d559e1656bb6251c157662141"
139-
}
140-
},
141-
"MyApifetchBasePathMapping": {
142-
"Type": "AWS::ApiGateway::BasePathMapping",
143-
"Properties": {
144-
"BasePath": "fetch",
145-
"DomainName": "api-regional.com",
146-
"RestApiId": {
147-
"Ref": "MyApi"
148-
},
149-
"Stage": {
150-
"Ref": "MyApiProdStage"
151-
}
184+
"Description": "RestApi deployment id: 967cf1a6ff8e58a6e739bf5b7b59a7d658e01a40"
152185
}
153186
},
154187
"MyFunctionRole": {
@@ -175,42 +208,6 @@
175208
}
176209
}
177210
},
178-
"RecordSetGroup3505b49f8a": {
179-
"Type": "AWS::Route53::RecordSetGroup",
180-
"Properties": {
181-
"HostedZoneId": "my-edge-hosted-zone",
182-
"RecordSets": [
183-
{
184-
"AliasTarget": {
185-
"EvaluateTargetHealth": true,
186-
"HostedZoneId": "Z2FDTNDATAQYW2",
187-
"DNSName": "api-regional.com"
188-
},
189-
"Type": "AAAA",
190-
"Name": "api-regional.com"
191-
},
192-
{
193-
"AliasTarget": {
194-
"EvaluateTargetHealth": true,
195-
"HostedZoneId": "Z2FDTNDATAQYW2",
196-
"DNSName": "api-regional.com"
197-
},
198-
"Type": "AAAA",
199-
"Name": "api-regional.com"
200-
}
201-
]
202-
}
203-
},
204-
"ServerlessRestApiDeployment5332408c06": {
205-
"Type": "AWS::ApiGateway::Deployment",
206-
"Properties": {
207-
"RestApiId": {
208-
"Ref": "ServerlessRestApi"
209-
},
210-
"Description": "RestApi deployment id: 5332408c060674292fe4785c8cfe8b3a70858887",
211-
"StageName": "Stage"
212-
}
213-
},
214211
"MyApi": {
215212
"Type": "AWS::ApiGateway::RestApi",
216213
"Properties": {
@@ -222,7 +219,7 @@
222219
}
223220
},
224221
"paths": {
225-
"/fetch/another": {
222+
"/fetch": {
226223
"post": {
227224
"x-amazon-apigateway-integration": {
228225
"httpMethod": "POST",
@@ -238,70 +235,6 @@
238235
"openapi": "3.0.1"
239236
}
240237
}
241-
},
242-
"ApiGatewayDomainNameb4325e3ba6": {
243-
"Type": "AWS::ApiGateway::DomainName",
244-
"Properties": {
245-
"EndpointConfiguration": {
246-
"Types": [
247-
"REGIONAL"
248-
]
249-
},
250-
"RegionalCertificateArn": "my-edge-api-arn",
251-
"DomainName": "api-edge.com"
252-
}
253-
},
254-
"ApiGatewayDomainName80a04c0ec3": {
255-
"Type": "AWS::ApiGateway::DomainName",
256-
"Properties": {
257-
"CertificateArn": "my-regional-cert-arn",
258-
"EndpointConfiguration": {
259-
"Types": [
260-
"EDGE"
261-
]
262-
},
263-
"DomainName": "api-regional.com"
264-
}
265-
},
266-
"MyApiProdStage": {
267-
"Type": "AWS::ApiGateway::Stage",
268-
"Properties": {
269-
"DeploymentId": {
270-
"Ref": "MyApiDeploymentb23755fe76"
271-
},
272-
"RestApiId": {
273-
"Ref": "MyApi"
274-
},
275-
"StageName": "Prod"
276-
}
277-
},
278-
"ServerlessRestApi": {
279-
"Type": "AWS::ApiGateway::RestApi",
280-
"Properties": {
281-
"Body": {
282-
"info": {
283-
"version": "1.0",
284-
"title": {
285-
"Ref": "AWS::StackName"
286-
}
287-
},
288-
"paths": {
289-
"/implicit": {
290-
"post": {
291-
"x-amazon-apigateway-integration": {
292-
"httpMethod": "POST",
293-
"type": "aws_proxy",
294-
"uri": {
295-
"Fn::Sub": "arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${MyFunction.Arn}/invocations"
296-
}
297-
},
298-
"responses": {}
299-
}
300-
}
301-
},
302-
"swagger": "2.0"
303-
}
304-
}
305238
}
306239
}
307240
}

0 commit comments

Comments
 (0)