How to use the @aws-cdk/aws-apigateway.CfnUsagePlanKey function in @aws-cdk/aws-apigateway

To help you get started, we’ve selected a few @aws-cdk/aws-apigateway examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github seagull-js / seagull / packages / deploy / src / lib / cdk / stack.ts View on Github external
const usagePlanConfig = {
      apiStages: [
        { apiId: new Token(this.apiGateway.restApiId), stage: 'prod' },
      ],
      description: 'universal plan to secure the api gateway',
      usagePlanName: 'universal plan',
    }
    const apiKey = new CfnApiKey(this, 'lambdaApiKey', apiKeyConfig)
    const usagePlan = new CfnUsagePlan(this, 'usagePlan', usagePlanConfig)
    const usageKeyConfig = {
      keyId: new Token(apiKey.apiKeyId),
      keyType: 'API_KEY',
      usagePlanId: new Token(usagePlan.usagePlanId),
    }
    // tslint:disable-next-line:no-unused-expression
    new CfnUsagePlanKey(this, 'usageKey', usageKeyConfig)

    const proxy = this.apiGateway.root.addResource('{any+}')
    this.apiGateway.root.addMethod('GET', this.defaultIntegration, {
      apiKeyRequired: true,
    })
    this.apiGateway.root.addMethod('POST', this.defaultIntegration, {
      apiKeyRequired: true,
    })
    this.apiGateway.root.addMethod('DELETE', this.defaultIntegration, {
      apiKeyRequired: true,
    })
    proxy.addMethod('GET', this.defaultIntegration, { apiKeyRequired: true })
    proxy.addMethod('POST', this.defaultIntegration, { apiKeyRequired: true })
    proxy.addMethod('DELETE', this.defaultIntegration, { apiKeyRequired: true })
    this.apiGatewayDomain = getApiGatewayDomain(this.apiGateway.url)
    this.apiGatewayOriginPath = getApiGatewayPath(this.apiGateway.url)