質問編集履歴

2

解答を受けての捕捉追加

2021/06/24 01:37

投稿

te_ff
te_ff

スコア13

test CHANGED
File without changes
test CHANGED
@@ -177,3 +177,79 @@
177
177
  Method: POST
178
178
 
179
179
  ```
180
+
181
+
182
+
183
+ ### 捕捉
184
+
185
+ RestApiからAPIに変更し、Function>Events>Propertiesに RestApiId: !Ref ApiGatewayApi を追加すると紐づけ自体は行われているのですが、Corsの設定がうまくできていないようです。
186
+
187
+
188
+
189
+ 参考
190
+
191
+ ・RestAPI
192
+
193
+ https://docs.aws.amazon.com/ja_jp/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-restapi.html
194
+
195
+
196
+
197
+ ・API
198
+
199
+ https://docs.aws.amazon.com/ja_jp/serverless-application-model/latest/developerguide/sam-resource-api.html
200
+
201
+
202
+
203
+ ・Function>Events>Properties>Api
204
+
205
+ https://docs.aws.amazon.com/ja_jp/serverless-application-model/latest/developerguide/sam-property-function-api.html
206
+
207
+ ```
208
+
209
+ ...省略
210
+
211
+ ApiGatewayApi:
212
+
213
+ Type: AWS::Serverless::Api
214
+
215
+ Properties:
216
+
217
+ StageName: Prod
218
+
219
+ Cors: "'*'"
220
+
221
+
222
+
223
+ GetProjectFunction:
224
+
225
+ Type: AWS::Serverless::Function
226
+
227
+ Properties:
228
+
229
+ CodeUri: lambdas/get_project/
230
+
231
+ Handler: app.lambda_handler
232
+
233
+ Layers:
234
+
235
+ - arn:aws:lambda:ap-northeast-1:898466741470:layer:psycopg2-py38:1
236
+
237
+ Runtime: python3.8
238
+
239
+ Events:
240
+
241
+ GetProject:
242
+
243
+ Type: Api
244
+
245
+ Properties:
246
+
247
+ Path: /get_project
248
+
249
+ Method: get
250
+
251
+ RestApiId: !Ref ApiGatewayApi
252
+
253
+ ...省略
254
+
255
+ ```

1

参考URLが間違っていたため修正

2021/06/24 01:37

投稿

te_ff
te_ff

スコア13

test CHANGED
File without changes
test CHANGED
@@ -8,7 +8,7 @@
8
8
 
9
9
 
10
10
 
11
- https://docs.aws.amazon.com/ja_jp/serverless-application-model/latest/developerguide/sam-property-api-corsconfiguration.html
11
+ https://docs.aws.amazon.com/ja_jp/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-gatewayresponse.html
12
12
 
13
13
 
14
14