In below API usage cft I unable to parameterize the api resource and meythod.
ApiUsagePlan:
Type: "AWS::ApiGateway::UsagePlan"
Properties:
Throttle:
RateLimit: 1000
BurstLimit: 5000
ApiStages:
- ApiId: !Ref MyApiGatewayApi
Stage: !Ref MyApiStage
Throttle:
"/hello/world/GET": <--- How to get this parameterised
RateLimit: 50
BurstLimit: 50
I am getting below error instead
esource handler returned message: "Invalid patch path '/apiStages/sk4knm4yub:ppe-auth/throttle/!Ref MethodName/burstLimit' specified for op 'replace'. Must be one of:
[/name, /description, /productCode, /quota/period, /quota/limit, /quota/offset, /throttle/rateLimit, /throttle/burstLimit, /apiStages/<apidId:stageName>/throttle/<resourcePath>/<httpMethod>/rateLimit, /apiStages/<apidId:stageName>/throttle/<resourcePath>/<httpMethod>/burstLimit, /apiStages/<apidId:stageName>/throttle] (Service: ApiGateway, Status Code: 400, Request ID: 5ff7c212-bb69-4284-9a4b-6fa2305d5945)" (RequestToken: 7ae87cae-198e-01d7-ef3e-afdfa2a6472b, HandlerErrorCode: InvalidRequest)
expecting to apply the input parameter for resource and method
2
Answers
Its not possible with CloudFormation. You would have to developed per-processing procedure of the template before uploading or using some macro or a custom resource.
The error occurs because CloudFormation does not support directly parameterizing API Gateway resource paths (/hello/world) and HTTP methods (GET) inside the Throttle configuration. But, you can use the !Sub function to dynamically construct the path based on parameters.
This is an example:
Now with this approach we can the Throttle key dynamically resolves to something like "/hello/world/GET" during stack creation.