AWS Fundamentals Logo
AWS Fundamentals
L2 Construct

ApiKey

An API Gateway ApiKey. An ApiKey can be distributed to API clients that are executing requests for Method resources that require an Api Key.

Import

import { ApiKey } from 'aws-cdk-lib/aws-apigateway';

Or use the module namespace:

import * as apigateway from 'aws-cdk-lib/aws-apigateway';
// apigateway.ApiKey

Properties

Configuration passed to the constructor as ApiKeyProps.

customerIdOptional
string

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

Default: none

enabledOptional
boolean

Indicates whether the API key can be used by clients.

Default: true

generateDistinctIdOptional
boolean

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

Default: false

resourcesOptionalDeprecated
IRestApi[]

A list of resources this api key is associated with.

Default: none

Deprecated: - use `stages` instead

stagesOptional
IStage[]

A list of Stages this api key is associated with.

Default: - the api key is not associated with any stages

3 properties inherited from ApiKeyOptions
apiKeyNameOptionalinherited from ApiKeyOptions
string

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.

Default: automically generated name

descriptionOptionalinherited from ApiKeyOptions
string

A description of the purpose of the API key.

Default: none

valueOptionalinherited from ApiKeyOptions
string

The value of the API key. Must be at least 20 characters long.

Default: none

3 properties inherited from ResourceOptions
defaultCorsPreflightOptionsOptionalinherited from ResourceOptions
CorsOptions

Adds a CORS preflight OPTIONS method to this resource and all child resources. You can add CORS at the resource-level using `addCorsPreflight`.

Default: - CORS is disabled

defaultIntegrationOptionalinherited from ResourceOptions
Integration

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

Default: - Inherited from parent.

defaultMethodOptionsOptionalinherited from ResourceOptions
MethodOptions

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

Default: - Inherited from parent.

Get the Amazon API Gateway Cheat Sheet

Everything you need to know about Amazon API Gateway on one page. HD quality, print-friendly.

Download Free Infographic