File tree Expand file tree Collapse file tree 1 file changed +57
-0
lines changed Expand file tree Collapse file tree 1 file changed +57
-0
lines changed Original file line number Diff line number Diff line change @@ -193,6 +193,63 @@ aws lambda update-function-code --function-name my-prod-function-name --s3-bucke
193
193
194
194
...or some variation thereof. You get the idea.
195
195
196
+ ## Debugging API Gateway
197
+
198
+ If something isn't working right with your API Gateway, set ` api_gateway_logging_level = "INFO" ` . Additionally, you need to add the following ** global configuration** for your API Gateway:
199
+
200
+ ``` tf
201
+ resource "aws_api_gateway_account" "this" {
202
+ cloudwatch_role_arn = "${aws_iam_role.apigateway_cloudwatch_logging.arn}"
203
+ }
204
+
205
+ resource "aws_iam_role" "apigateway_cloudwatch_logging" {
206
+ name = "apigateway-cloudwatch-logging"
207
+
208
+ assume_role_policy = <<EOF
209
+ {
210
+ "Version": "2012-10-17",
211
+ "Statement": [
212
+ {
213
+ "Effect": "Allow",
214
+ "Principal": {
215
+ "Service": "apigateway.amazonaws.com"
216
+ },
217
+ "Action": "sts:AssumeRole"
218
+ }
219
+ ]
220
+ }
221
+ EOF
222
+ }
223
+
224
+ resource "aws_iam_role_policy" "apigateway_cloudwatch_logging" {
225
+ name = "apigateway-cloudwatch-logging"
226
+ role = "${aws_iam_role.apigateway_cloudwatch_logging.id}"
227
+
228
+ policy = <<EOF
229
+ {
230
+ "Version": "2012-10-17",
231
+ "Statement": [
232
+ {
233
+ "Effect": "Allow",
234
+ "Action": [
235
+ "logs:CreateLogGroup",
236
+ "logs:CreateLogStream",
237
+ "logs:DescribeLogGroups",
238
+ "logs:DescribeLogStreams",
239
+ "logs:PutLogEvents",
240
+ "logs:GetLogEvents",
241
+ "logs:FilterLogEvents"
242
+ ],
243
+ "Resource": "*"
244
+ }
245
+ ]
246
+ }
247
+ EOF
248
+ }
249
+ ```
250
+
251
+ Otherwise API Gateway won't have permission to write logs to CloudWatch.
252
+
196
253
<!-- terraform-docs:begin -->
197
254
## Inputs
198
255
You can’t perform that action at this time.
0 commit comments