AWS API Gateway API Key

This page shows how to write Terraform and CloudFormation for API Gateway API Key and write them securely.

code-icon

Fix issues in your cloud & app configurations

Test for misconfigurations of this resource in your cloud.

get-started-button

Terraform Example (aws_api_gateway_api_key)

Provides an API Gateway API Key.

NOTE: Since the API Gateway usage plans feature was launched on August 11, 2016, usage plans are now required to associate an API key with an API stage.

Parameters

Example Usage (from GitHub)

github-iconcloudskiff/driftctl
resource "aws_api_gateway_api_key" "foo" {
    name = "foo"
    description = "Foo Api Key"
    enabled = false
}

github-iconwellcomecollection/identity
resource "aws_api_gateway_api_key" "dummy" {
  # Only deploy the dummy client if it's a non-production environment...
  count = lower(terraform.workspace) != "prod" ? 1 : 0

  name = "dummy"

github-iconvgulkevic/Assets-Wallet
resource "aws_api_gateway_api_key" "temp_key" {
  name = var.api_key_name
}

resource "aws_api_gateway_usage_plan_key" "main" {
  key_id        = aws_api_gateway_api_key.temp_key.id

CloudFormation Example (AWS::ApiGateway::ApiKey)

The AWS::ApiGateway::ApiKey resource creates a unique key that you can distribute to clients who are executing API Gateway Method resources that require an API key. To specify which API key clients must use, map the API key with the RestApi and Stage resources that include the methods that require a key.

Parameters

Frequently asked questions

What is AWS API Gateway API Key?

AWS API Gateway API Key is a resource for API Gateway of Amazon Web Service. Settings can be wrote in Terraform and CloudFormation.

Where can I find the example code for the AWS API Gateway API Key?

For Terraform, the cloudskiff/driftctl, wellcomecollection/identity and vgulkevic/Assets-Wallet source code examples are useful. See the Terraform Example section for further details.