I am trying to automate the api-config and api-gateway creation to expose cloud run service using terraform. Till yesterday it was working well, & api-gateway was serving traffic. But considering a large volume of requests hitting the API Gateway, I decided to increase the quota for read-requests to a higher number & that's when I modified the openapi swagger file to add in quota for my API.
It worked well for sometime but now when I am triggering my pipeline, it failed with an internal server error. I tried using cloud commands also for creating an API gateway with verbosity set to DEBUG but could not find anything useful. The api & API config gets created using the openapi file but creation of API Gateway has stopped...with an internal server error.
Attaching my openapi file for reference.:
swagger: "2.0"
info:
version: 1.0.0
title: Offer api
description: API to get personalized offrs
produces:
- application/json
schemes:
- https
x-google-management:
metrics:
# Define a metric for read requests.
- name: "read-requests"
displayName: "Read requests"
valueType: INT64
metricKind: DELTA
quota:
limits:
# Define the limit or the read-requests metric.
- name: "read-limit"
metric: "read-requests"
unit: "1/min/{project}"
values:
STANDARD: 20000
paths:
/offers: #/{deviceID}/{restaurantID}:
get:
description: get personalized offers
operationId: app.get_offers
x-google-backend:
address: ${backend_address}
parameters:
- name: deviceID
in: header
required: True
type: string
- name: storeID
in: header
required: True
type: string
x-google-quota:
metricCosts:
"read-requests": 1
security:
- APIKeyHeader: []
responses:
200:
description: Successful Operation
schema:
$ref: '#/definitions/APIResponse'
#headers:
# Content-Type:
# schema:
# type: string
# Content-Encoding?:
# schema:
# type: string
# mcd-apiversion:
# type: string
# mcd-uuid:
# schema:
# type: string
# Cache-Control?:
# schema:
# type: string
# ETag:
# schema:
# type: string
400:
description: Bad Request - Invalid ID Supplied
schema:
$ref: '#/definitions/APIErrorResponse'
# headers:
# Content-Type:
# schema:
# type: string
# Content-Encoding?:
# schema:
# type: string
# 401:
# description: "Not Authorized - API KEY is invalid"
# content:
# application/json:
# schema:
# $ref: "#/responses/UnauthorizedError"
404:
description: "Resource not available - ID not found"
schema:
$ref: '#/definitions/APIErrorResponse'
# headers:
# Content-Type:
# type: "string"
# Content-Encoding?:
# type: "string"
415:
description: "Unsupported media Type. Please check the content type in request"
schema:
$ref: '#/definitions/APIErrorResponse'
# headers:
# Content-Type:
# type: "string"
# Content-Encoding?:
# type: "string"
500:
description: "Internal Server Error. Please refer logs for further details."
schema:
$ref: '#/definitions/APIErrorResponse'
# headers:
# Content-Type:
# type: "string"
# Content-Encoding?:
# type: "string"
503:
description: "Service is unavailable. Please try after some time"
schema:
$ref: '#/definitions/APIErrorResponse'
# headers:
# Content-Type:
# type: "string"
# Content-Encoding?:
# type: "string"
definitions:
APIResponse:
type: object
required:
- customerID
- coupon
properties:
customerID:
type: string
example: "0000"
coupon:
type: string
example: "Christmas100"
APIErrorResponse:
type: object
required:
- code
- message
properties:
code:
type: integer
type:
type: string
message:
type: string
path:
type: string
service:
type: string
property:
type: string
securityDefinitions:
# This section configures basic authentication with an API key.
APIKeyHeader:
type: apiKey
name: x-api-key
in: header
EDIT The issue is resolved. But there seems to be more to it, does anybody has any idea on how to define quota for per day requests? From GCP documentation I am able to find out that we can define per minute requests count.(Read and write) But is there a way to define per day limit on no.of requests for our APIs?