aws-cdk-lib.aws_apigateway.ApiKeyProps

interface ApiKeyProps

LanguageType name
.NETAmazon.CDK.AWS.APIGateway.ApiKeyProps
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awsapigateway#ApiKeyProps
Javasoftware.amazon.awscdk.services.apigateway.ApiKeyProps
Pythonaws_cdk.aws_apigateway.ApiKeyProps
TypeScript (source)aws-cdk-lib » aws_apigateway » ApiKeyProps

ApiKey Properties.

Example

// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import * as cdk from 'aws-cdk-lib';
import { aws_apigateway as apigateway } from 'aws-cdk-lib';

declare const authorizer: apigateway.Authorizer;
declare const integration: apigateway.Integration;
declare const model: apigateway.Model;
declare const requestValidator: apigateway.RequestValidator;
declare const restApi: apigateway.RestApi;
declare const stage: apigateway.Stage;
const apiKeyProps: apigateway.ApiKeyProps = {
  apiKeyName: 'apiKeyName',
  customerId: 'customerId',
  defaultCorsPreflightOptions: {
    allowOrigins: ['allowOrigins'],

    // the properties below are optional
    allowCredentials: false,
    allowHeaders: ['allowHeaders'],
    allowMethods: ['allowMethods'],
    disableCache: false,
    exposeHeaders: ['exposeHeaders'],
    maxAge: cdk.Duration.minutes(30),
    statusCode: 123,
  },
  defaultIntegration: integration,
  defaultMethodOptions: {
    apiKeyRequired: false,
    authorizationScopes: ['authorizationScopes'],
    authorizationType: apigateway.AuthorizationType.NONE,
    authorizer: authorizer,
    methodResponses: [{
      statusCode: 'statusCode',

      // the properties below are optional
      responseModels: {
        responseModelsKey: model,
      },
      responseParameters: {
        responseParametersKey: false,
      },
    }],
    operationName: 'operationName',
    requestModels: {
      requestModelsKey: model,
    },
    requestParameters: {
      requestParametersKey: false,
    },
    requestValidator: requestValidator,
    requestValidatorOptions: {
      requestValidatorName: 'requestValidatorName',
      validateRequestBody: false,
      validateRequestParameters: false,
    },
  },
  description: 'description',
  enabled: false,
  generateDistinctId: false,
  resources: [restApi],
  stages: [stage],
  value: 'value',
};

Properties

NameTypeDescription
apiKeyName?stringA name for the API key.
customerId?stringAn AWS Marketplace customer identifier to use when integrating with the AWS SaaS Marketplace.
defaultCorsPreflightOptions?CorsOptionsAdds a CORS preflight OPTIONS method to this resource and all child resources.
defaultIntegration?IntegrationAn integration to use as a default for all methods created within this API unless an integration is specified.
defaultMethodOptions?MethodOptionsMethod options to use as a default for all methods created within this API unless custom options are specified.
description?stringA description of the purpose of the API key.
enabled?booleanIndicates whether the API key can be used by clients.
generateDistinctId?booleanSpecifies whether the key identifier is distinct from the created API key value.
resources?⚠️IRestApi[]A list of resources this api key is associated with.
stages?IStage[]A list of Stages this api key is associated with.
value?stringThe value of the API key.

apiKeyName?

Type: string (optional, default: automically generated name)

A name for the API key.

If you don't specify a name, AWS CloudFormation generates a unique physical ID and uses that ID for the API key name.


customerId?

Type: string (optional, default: none)

An AWS Marketplace customer identifier to use when integrating with the AWS SaaS Marketplace.


defaultCorsPreflightOptions?

Type: CorsOptions (optional, default: CORS is disabled)

Adds a CORS preflight OPTIONS method to this resource and all child resources.

You can add CORS at the resource-level using addCorsPreflight.


defaultIntegration?

Type: Integration (optional, default: Inherited from parent.)

An integration to use as a default for all methods created within this API unless an integration is specified.


defaultMethodOptions?

Type: MethodOptions (optional, default: Inherited from parent.)

Method options to use as a default for all methods created within this API unless custom options are specified.


description?

Type: string (optional, default: none)

A description of the purpose of the API key.


enabled?

Type: boolean (optional, default: true)

Indicates whether the API key can be used by clients.


generateDistinctId?

Type: boolean (optional, default: false)

Specifies whether the key identifier is distinct from the created API key value.


resources?⚠️

⚠️ Deprecated: - use stages instead

Type: IRestApi[] (optional, default: none)

A list of resources this api key is associated with.


stages?

Type: IStage[] (optional, default: the api key is not associated with any stages)

A list of Stages this api key is associated with.


value?

Type: string (optional, default: none)

The value of the API key.

Must be at least 20 characters long.