api_keys
Creates, updates, deletes or gets an api_key resource or lists api_keys in a region
Overview
| Name | api_keys |
| Type | Resource |
| Description | 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. |
| Id | awscc.apigateway.api_keys |
Fields
- get (all properties)
- list (identifiers only)
| Name | Datatype | Description |
|---|---|---|
api_key_id | string | |
customer_id | string | |
description | string | |
enabled | boolean | |
generate_distinct_id | boolean | |
name | string | 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](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-name.html).<br />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_keys | array | |
tags | array | |
value | string | |
region | string | AWS region. |
| Name | Datatype | Description |
|---|---|---|
api_key_id | string | |
region | string | AWS region. |
For more information, see AWS::ApiGateway::ApiKey.
Methods
| Name | Resource | Accessible by | Required Params |
|---|---|---|---|
create_resource | api_keys | INSERT | region |
delete_resource | api_keys | DELETE | Identifier, region |
update_resource | api_keys | UPDATE | Identifier, PatchDocument, region |
list_resources | api_keys_list_only | SELECT | region |
get_resource | api_keys | SELECT | Identifier, region |
SELECT examples
- get (all properties)
- list (identifiers only)
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 = 'us-east-1' AND
Identifier = '{{ api_key_id }}';
Lists all api_keys in a region.
SELECT
region,
api_key_id
FROM awscc.apigateway.api_keys_list_only
WHERE
region = 'us-east-1';
INSERT example
Use the following StackQL query and manifest file to create a new api_key resource, using stack-deploy.
- Required Properties
- All Properties
- Manifest
/*+ 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 }}';
/*+ 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 }}';
version: 1
name: stack name
description: stack description
providers:
- aws
globals:
- name: region
value: '{{ vars.AWS_REGION }}'
resources:
- name: api_key
props:
- name: customer_id
value: '{{ customer_id }}'
- name: description
value: '{{ description }}'
- name: enabled
value: '{{ enabled }}'
- name: generate_distinct_id
value: '{{ generate_distinct_id }}'
- name: name
value: '{{ name }}'
- name: stage_keys
value:
- rest_api_id: '{{ rest_api_id }}'
stage_name: '{{ stage_name }}'
- name: tags
value:
- value: '{{ value }}'
key: '{{ key }}'
- name: value
value: '{{ value }}'
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 }}';
DELETE example
/*+ delete */
DELETE FROM awscc.apigateway.api_keys
WHERE
Identifier = '{{ api_key_id }}' AND
region = 'us-east-1';
Permissions
To operate on the api_keys resource, the following permissions are required:
- Create
- Read
- Update
- Delete
- List
apigateway:POST,
apigateway:GET,
apigateway:PUT
apigateway:GET
apigateway:GET,
apigateway:PATCH,
apigateway:PUT,
apigateway:DELETE
apigateway:DELETE,
apigateway:GET
apigateway:GET