My lambda function creates api keys and I would like to attach them to a usage plan that is also generated by the cloudformation template where the function is defined. How can I pass in the id of the usage plan created by the serverless.yaml file since the usage plan ids are generated automatically.
function createUsageKey(key, plan_id) {
return new Promise((resolve, reject) => {
var params = {
keyId: key.id /* required */,
keyType: "API_KEY",
usagePlanId: plan_id /* required */
};
apigateway.createUsagePlanKey(params, function(err, data) {
if (err) {
console.log(err, err.stack);
reject(err);
}
// an error occurred
else resolve(data); // successful response
});
});
}
usagePlan:
quota:
limit: 1000
offset: 2
period: MONTH
throttle:
burstLimit: 20
rateLimit: 10