ApiKeyProps

class aws_cdk.aws_apigateway.ApiKeyProps(*, default_cors_preflight_options=None, default_integration=None, default_method_options=None, api_key_name=None, description=None, value=None, customer_id=None, enabled=None, generate_distinct_id=None, resources=None)

Bases: aws_cdk.aws_apigateway.ApiKeyOptions

ApiKey Properties.

Parameters
  • default_cors_preflight_options (Optional[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

  • default_integration (Optional[Integration]) – An integration to use as a default for all methods created within this API unless an integration is specified. Default: - Inherited from parent.

  • default_method_options (Optional[MethodOptions]) – Method options to use as a default for all methods created within this API unless custom options are specified. Default: - Inherited from parent.

  • api_key_name (Optional[str]) – 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

  • description (Optional[str]) – A description of the purpose of the API key. Default: none

  • value (Optional[str]) – The value of the API key. Must be at least 20 characters long. Default: none

  • customer_id (Optional[str]) – An AWS Marketplace customer identifier to use when integrating with the AWS SaaS Marketplace. Default: none

  • enabled (Optional[bool]) – Indicates whether the API key can be used by clients. Default: true

  • generate_distinct_id (Optional[bool]) – Specifies whether the key identifier is distinct from the created API key value. Default: false

  • resources (Optional[Sequence[IRestApi]]) – A list of resources this api key is associated with. Default: none

ExampleMetadata

fixture=_generated

Example:

# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
import aws_cdk.aws_apigateway as apigateway
import aws_cdk.core as cdk

# authorizer is of type Authorizer
# integration is of type Integration
# model is of type Model
# request_validator is of type RequestValidator
# rest_api is of type RestApi

api_key_props = apigateway.ApiKeyProps(
    api_key_name="apiKeyName",
    customer_id="customerId",
    default_cors_preflight_options=apigateway.CorsOptions(
        allow_origins=["allowOrigins"],

        # the properties below are optional
        allow_credentials=False,
        allow_headers=["allowHeaders"],
        allow_methods=["allowMethods"],
        disable_cache=False,
        expose_headers=["exposeHeaders"],
        max_age=cdk.Duration.minutes(30),
        status_code=123
    ),
    default_integration=integration,
    default_method_options=apigateway.MethodOptions(
        api_key_required=False,
        authorization_scopes=["authorizationScopes"],
        authorization_type=apigateway.AuthorizationType.NONE,
        authorizer=authorizer,
        method_responses=[apigateway.MethodResponse(
            status_code="statusCode",

            # the properties below are optional
            response_models={
                "response_models_key": model
            },
            response_parameters={
                "response_parameters_key": False
            }
        )],
        operation_name="operationName",
        request_models={
            "request_models_key": model
        },
        request_parameters={
            "request_parameters_key": False
        },
        request_validator=request_validator,
        request_validator_options=apigateway.RequestValidatorOptions(
            request_validator_name="requestValidatorName",
            validate_request_body=False,
            validate_request_parameters=False
        )
    ),
    description="description",
    enabled=False,
    generate_distinct_id=False,
    resources=[rest_api],
    value="value"
)

Attributes

api_key_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.

Default

automically generated name

Link

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-apikey.html#cfn-apigateway-apikey-name

Return type

Optional[str]

customer_id

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

Default

none

Link

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-apikey.html#cfn-apigateway-apikey-customerid

Return type

Optional[str]

default_cors_preflight_options

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

Return type

Optional[CorsOptions]

default_integration

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

Default
  • Inherited from parent.

Return type

Optional[Integration]

default_method_options

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

Default
  • Inherited from parent.

Return type

Optional[MethodOptions]

description

A description of the purpose of the API key.

Default

none

Link

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-apikey.html#cfn-apigateway-apikey-description

Return type

Optional[str]

enabled

Indicates whether the API key can be used by clients.

Default

true

Link

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-apikey.html#cfn-apigateway-apikey-enabled

Return type

Optional[bool]

generate_distinct_id

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

Default

false

Link

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-apikey.html#cfn-apigateway-apikey-generatedistinctid

Return type

Optional[bool]

resources

A list of resources this api key is associated with.

Default

none

Return type

Optional[List[IRestApi]]

value

The value of the API key.

Must be at least 20 characters long.

Default

none

Link

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-apikey.html#cfn-apigateway-apikey-value

Return type

Optional[str]