Skip to main content

api_keys

Creates, updates, deletes or gets an api_key resource or lists api_keys in a region

Overview

Nameapi_keys
TypeResource
DescriptionThe 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.
Idawscc.apigateway.api_keys

Fields

NameDatatypeDescription
api_key_idstring
customer_idstring
descriptionstring
enabledboolean
generate_distinct_idboolean
namestring
A name for the API key. If you don't specify a name, CFN generates a unique physical ID and uses that ID for the API key name. For more information, see Name Type.If you specify a name, you cannot perform updates that require replacement of this resource. You can perform updates that require no or some interruption. If you must replace the resource, specify a new name.
stage_keysarray
tagsarray
valuestring
regionstringAWS region.

For more information, see AWS::ApiGateway::ApiKey.

Methods

NameResourceAccessible byRequired Params
create_resourceapi_keysINSERTregion
delete_resourceapi_keysDELETEIdentifier, region
update_resourceapi_keysUPDATEIdentifier, PatchDocument, region
list_resourcesapi_keys_list_onlySELECTregion
get_resourceapi_keysSELECTIdentifier, region

SELECT examples

Gets all properties from an individual api_key.

SELECT
region,
api_key_id,
customer_id,
description,
enabled,
generate_distinct_id,
name,
stage_keys,
tags,
value
FROM awscc.apigateway.api_keys
WHERE
region = '{{ region }}' AND
Identifier = '{{ api_key_id }}';

INSERT example

Use the following StackQL query and manifest file to create a new api_key resource, using stack-deploy.

/*+ create */
INSERT INTO awscc.apigateway.api_keys (
CustomerId,
Description,
Enabled,
GenerateDistinctId,
Name,
StageKeys,
Tags,
Value,
region
)
SELECT
'{{ customer_id }}',
'{{ description }}',
'{{ enabled }}',
'{{ generate_distinct_id }}',
'{{ name }}',
'{{ stage_keys }}',
'{{ tags }}',
'{{ value }}',
'{{ region }}'
RETURNING
ErrorCode,
EventTime,
Identifier,
Operation,
OperationStatus,
RequestToken,
ResourceModel,
RetryAfter,
StatusMessage,
TypeName
;

UPDATE example

Use the following StackQL query and manifest file to update a api_key resource, using stack-deploy.

/*+ update */
UPDATE awscc.apigateway.api_keys
SET PatchDocument = string('{{ {
"CustomerId": customer_id,
"Description": description,
"Enabled": enabled,
"StageKeys": stage_keys,
"Tags": tags
} | generate_patch_document }}')
WHERE
region = '{{ region }}' AND
Identifier = '{{ api_key_id }}'
RETURNING
ErrorCode,
EventTime,
Identifier,
Operation,
OperationStatus,
RequestToken,
ResourceModel,
RetryAfter,
StatusMessage,
TypeName
;

DELETE example

/*+ delete */
DELETE FROM awscc.apigateway.api_keys
WHERE
Identifier = '{{ api_key_id }}' AND
region = '{{ region }}'
RETURNING
ErrorCode,
EventTime,
Identifier,
Operation,
OperationStatus,
RequestToken,
ResourceModel,
RetryAfter,
StatusMessage,
TypeName
;

Additional Parameters

Mutable resources in the Cloud Control provider support additional optional parameters which can be supplied with INSERT, UPDATE, or DELETE operations. These include:

ParameterDescription
ClientToken
A unique identifier to ensure the idempotency of the resource request.This allows the provider to accurately distinguish between retries and new requests.
A client token is valid for 36 hours once used.
After that, a resource request with the same client token is treated as a new request.
If you do not specify a client token, one is generated for inclusion in the request.
RoleArn
The ARN of the IAM role used to perform this resource operation.The role specified must have the permissions required for this operation.
If you do not specify a role, a temporary session is created using your AWS user credentials.
TypeVersionId
For private resource types, the type version to use in this resource operation.If you do not specify a resource version, the default version is used.

Permissions

To operate on the api_keys resource, the following permissions are required:

apigateway:POST,
apigateway:GET,
apigateway:PUT