aws-cdk-lib.aws_apigateway.ApiKeyOptions

interface ApiKeyOptions

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

The options for creating an API Key.

Example

declare const api: apigateway.RestApi;
const key = api.addApiKey('ApiKey', {
  apiKeyName: 'myApiKey1',
  value: 'MyApiKeyThatIsAtLeast20Characters',
});

Properties

NameTypeDescription
apiKeyName?stringA name for the API key.
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.
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.


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.


value?

Type: string (optional, default: none)

The value of the API key.

Must be at least 20 characters long.