Skip to content

CreateUsagePlanKey

Source: src/AWS/ApiGateway/CreateUsagePlanKey.ts

Runtime binding for enrolling an API key in a UsagePlan (apigateway:POST on /usageplans/{id}/keys).

The core of a self-service API-key onboarding flow: issue a key with ApiGateway.CreateApiKey, then attach it to the plan that throttles and meters it. Provide ApiGateway.CreateUsagePlanKeyHttp on the Function effect to implement the binding.

// init
const createApiKey = yield* ApiGateway.CreateApiKey();
const createUsagePlanKey = yield* ApiGateway.CreateUsagePlanKey(plan);
// runtime
const key = yield* createApiKey({ name: customerId, enabled: true });
yield* createUsagePlanKey({ keyId: key.id! });