Context
A typical ApiGatewayRestApi object looks like this,
const apiGatewayRestApi = new aws.apiGatewayRestApi.ApiGatewayRestApi(this, "awpigw-rest-api", {
name: "my-apigw",
body: myOpenApiSpecification
})
Initial intuition and instruction to update API Gateway's API_KEY_SOURCE is to add x-amazon-apigateway-api-key-source
to OpenAPI specification and pass it as the body for initializing ApiGatewayRestApi.
Problem
Adding x-amazon-apigateway-api-key-source
to OpenAPI specification and setting it in the body does not update API Gateway's API_KEY_SOURCE
{
"openapi" : "3.0.1",
"info" : {
"title" : "Test1"
},
"servers" : [ {
"url" : "/{basePath}",
"variables" : {
"basePath" : {
"default" : "import"
}
}
} ],
"x-amazon-apigateway-api-key-source" : "HEADER",
.
.
.
}
Solution
In order to add the change the API Gateways's API_KEY_SOURCE, we only need to add one more line of configuration while initializing ApiGatewayRestApi,
const apiGatewayRestApi = new aws.apiGatewayRestApi.ApiGatewayRestApi(this, "awpigw-rest-api", {
name: "my-apigw",
body: myOpenApiSpecification,
apiKeySource: "AUTHORIZER"
})
There is no need to configure it in the 'myOpenApiSpecification' as specified here.
Top comments (0)