質問編集履歴

2

解答を受けての捕捉追加

2021/06/24 01:37

投稿

te_ff
te_ff

スコア13

title CHANGED
File without changes
body CHANGED
@@ -87,4 +87,42 @@
87
87
  Properties:
88
88
  Path: /create_project
89
89
  Method: POST
90
+ ```
91
+
92
+ ### 捕捉
93
+ RestApiからAPIに変更し、Function>Events>Propertiesに RestApiId: !Ref ApiGatewayApi を追加すると紐づけ自体は行われているのですが、Corsの設定がうまくできていないようです。
94
+
95
+ 参考
96
+ ・RestAPI
97
+ https://docs.aws.amazon.com/ja_jp/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-restapi.html
98
+
99
+ ・API
100
+ https://docs.aws.amazon.com/ja_jp/serverless-application-model/latest/developerguide/sam-resource-api.html
101
+
102
+ ・Function>Events>Properties>Api
103
+ https://docs.aws.amazon.com/ja_jp/serverless-application-model/latest/developerguide/sam-property-function-api.html
104
+ ```
105
+ ...省略
106
+ ApiGatewayApi:
107
+ Type: AWS::Serverless::Api
108
+ Properties:
109
+ StageName: Prod
110
+ Cors: "'*'"
111
+
112
+ GetProjectFunction:
113
+ Type: AWS::Serverless::Function
114
+ Properties:
115
+ CodeUri: lambdas/get_project/
116
+ Handler: app.lambda_handler
117
+ Layers:
118
+ - arn:aws:lambda:ap-northeast-1:898466741470:layer:psycopg2-py38:1
119
+ Runtime: python3.8
120
+ Events:
121
+ GetProject:
122
+ Type: Api
123
+ Properties:
124
+ Path: /get_project
125
+ Method: get
126
+ RestApiId: !Ref ApiGatewayApi
127
+ ...省略
90
128
  ```

1

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

2021/06/24 01:37

投稿

te_ff
te_ff

スコア13

title CHANGED
File without changes
body CHANGED
@@ -3,7 +3,7 @@
3
3
  AWSにて、APIServerを構築しています。
4
4
  Lambda関数リクエスト時には問題ないのですが、Lambda関数レスポンス時にCORSではじかれる状況です。
5
5
 
6
- https://docs.aws.amazon.com/ja_jp/serverless-application-model/latest/developerguide/sam-property-api-corsconfiguration.html
6
+ https://docs.aws.amazon.com/ja_jp/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-gatewayresponse.html
7
7
 
8
8
  こちらを参考にCloudFormationで管理しようと思ったのですが、
9
9