UNPKG

5.02 kBTypeScriptView Raw
1import * as iam from '@aws-cdk/aws-iam';
2import { IResource as IResourceBase, Resource } from '@aws-cdk/core';
3import { Construct } from 'constructs';
4import { ResourceOptions } from './resource';
5import { IRestApi } from './restapi';
6import { QuotaSettings, ThrottleSettings, UsagePlanPerApiStage } from './usage-plan';
7/**
8 * API keys are alphanumeric string values that you distribute to
9 * app developer customers to grant access to your API
10 */
11export interface IApiKey extends IResourceBase {
12 /**
13 * The API key ID.
14 * @attribute
15 */
16 readonly keyId: string;
17 /**
18 * The API key ARN.
19 */
20 readonly keyArn: string;
21}
22/**
23 * The options for creating an API Key.
24 */
25export interface ApiKeyOptions extends ResourceOptions {
26 /**
27 * 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.
28 * @link http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-apikey.html#cfn-apigateway-apikey-name
29 * @default automically generated name
30 */
31 readonly apiKeyName?: string;
32 /**
33 * The value of the API key. Must be at least 20 characters long.
34 * @link https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-apikey.html#cfn-apigateway-apikey-value
35 * @default none
36 */
37 readonly value?: string;
38 /**
39 * A description of the purpose of the API key.
40 * @link http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-apikey.html#cfn-apigateway-apikey-description
41 * @default none
42 */
43 readonly description?: string;
44}
45/**
46 * ApiKey Properties.
47 */
48export interface ApiKeyProps extends ApiKeyOptions {
49 /**
50 * A list of resources this api key is associated with.
51 * @default none
52 */
53 readonly resources?: IRestApi[];
54 /**
55 * An AWS Marketplace customer identifier to use when integrating with the AWS SaaS Marketplace.
56 * @link http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-apikey.html#cfn-apigateway-apikey-customerid
57 * @default none
58 */
59 readonly customerId?: string;
60 /**
61 * Indicates whether the API key can be used by clients.
62 * @link http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-apikey.html#cfn-apigateway-apikey-enabled
63 * @default true
64 */
65 readonly enabled?: boolean;
66 /**
67 * Specifies whether the key identifier is distinct from the created API key value.
68 * @link http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-apikey.html#cfn-apigateway-apikey-generatedistinctid
69 * @default false
70 */
71 readonly generateDistinctId?: boolean;
72}
73/**
74 * Base implementation that is common to the various implementations of IApiKey
75 */
76declare abstract class ApiKeyBase extends Resource implements IApiKey {
77 abstract readonly keyId: string;
78 abstract readonly keyArn: string;
79 /**
80 * Permits the IAM principal all read operations through this key
81 *
82 * @param grantee The principal to grant access to
83 */
84 grantRead(grantee: iam.IGrantable): iam.Grant;
85 /**
86 * Permits the IAM principal all write operations through this key
87 *
88 * @param grantee The principal to grant access to
89 */
90 grantWrite(grantee: iam.IGrantable): iam.Grant;
91 /**
92 * Permits the IAM principal all read and write operations through this key
93 *
94 * @param grantee The principal to grant access to
95 */
96 grantReadWrite(grantee: iam.IGrantable): iam.Grant;
97}
98/**
99 * An API Gateway ApiKey.
100 *
101 * An ApiKey can be distributed to API clients that are executing requests
102 * for Method resources that require an Api Key.
103 */
104export declare class ApiKey extends ApiKeyBase {
105 /**
106 * Import an ApiKey by its Id
107 */
108 static fromApiKeyId(scope: Construct, id: string, apiKeyId: string): IApiKey;
109 readonly keyId: string;
110 readonly keyArn: string;
111 constructor(scope: Construct, id: string, props?: ApiKeyProps);
112 private renderStageKeys;
113}
114/**
115 * RateLimitedApiKey properties.
116 */
117export interface RateLimitedApiKeyProps extends ApiKeyProps {
118 /**
119 * API Stages to be associated with the RateLimitedApiKey.
120 * @default none
121 */
122 readonly apiStages?: UsagePlanPerApiStage[];
123 /**
124 * Number of requests clients can make in a given time period.
125 * @default none
126 */
127 readonly quota?: QuotaSettings;
128 /**
129 * Overall throttle settings for the API.
130 * @default none
131 */
132 readonly throttle?: ThrottleSettings;
133}
134/**
135 * An API Gateway ApiKey, for which a rate limiting configuration can be specified.
136 *
137 * @resource AWS::ApiGateway::ApiKey
138 */
139export declare class RateLimitedApiKey extends ApiKeyBase {
140 readonly keyId: string;
141 readonly keyArn: string;
142 constructor(scope: Construct, id: string, props?: RateLimitedApiKeyProps);
143}
144export {};