1 | import { Duration, IResource, Resource } from '@aws-cdk/core';
|
2 | import { Construct } from 'constructs';
|
3 | import { AccessLogFormat, IAccessLogDestination } from './access-log';
|
4 | import { Deployment } from './deployment';
|
5 | import { IRestApi } from './restapi';
|
6 | /**
|
7 | * Represents an APIGateway Stage.
|
8 | */
|
9 | export interface IStage extends IResource {
|
10 | /**
|
11 | * Name of this stage.
|
12 | * @attribute
|
13 | */
|
14 | readonly stageName: string;
|
15 | /**
|
16 | * RestApi to which this stage is associated.
|
17 | */
|
18 | readonly restApi: IRestApi;
|
19 | }
|
20 | export interface StageOptions extends MethodDeploymentOptions {
|
21 | /**
|
22 | * The name of the stage, which API Gateway uses as the first path segment
|
23 | * in the invoked Uniform Resource Identifier (URI).
|
24 | *
|
25 | * @default - "prod"
|
26 | */
|
27 | readonly stageName?: string;
|
28 | /**
|
29 | * The CloudWatch Logs log group.
|
30 | *
|
31 | * @default - No destination
|
32 | */
|
33 | readonly accessLogDestination?: IAccessLogDestination;
|
34 | /**
|
35 | * A single line format of access logs of data, as specified by selected $content variables.
|
36 | * The format must include at least `AccessLogFormat.contextRequestId()`.
|
37 | * @see https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-mapping-template-reference.html#context-variable-reference
|
38 | *
|
39 | * @default - Common Log Format
|
40 | */
|
41 | readonly accessLogFormat?: AccessLogFormat;
|
42 | /**
|
43 | * Specifies whether Amazon X-Ray tracing is enabled for this method.
|
44 | *
|
45 | * @default false
|
46 | */
|
47 | readonly tracingEnabled?: boolean;
|
48 | /**
|
49 | * Indicates whether cache clustering is enabled for the stage.
|
50 | *
|
51 | * @default - Disabled for the stage.
|
52 | */
|
53 | readonly cacheClusterEnabled?: boolean;
|
54 | /**
|
55 | * The stage's cache cluster size.
|
56 | * @default 0.5
|
57 | */
|
58 | readonly cacheClusterSize?: string;
|
59 | /**
|
60 | * The identifier of the client certificate that API Gateway uses to call
|
61 | * your integration endpoints in the stage.
|
62 | *
|
63 | * @default - None.
|
64 | */
|
65 | readonly clientCertificateId?: string;
|
66 | /**
|
67 | * A description of the purpose of the stage.
|
68 | *
|
69 | * @default - No description.
|
70 | */
|
71 | readonly description?: string;
|
72 | /**
|
73 | * The version identifier of the API documentation snapshot.
|
74 | *
|
75 | * @default - No documentation version.
|
76 | */
|
77 | readonly documentationVersion?: string;
|
78 | /**
|
79 | * A map that defines the stage variables. Variable names must consist of
|
80 | * alphanumeric characters, and the values must match the following regular
|
81 | * expression: [A-Za-z0-9-._~:/?#&=,]+.
|
82 | *
|
83 | * @default - No stage variables.
|
84 | */
|
85 | readonly variables?: {
|
86 | [key: string]: string;
|
87 | };
|
88 | /**
|
89 | * Method deployment options for specific resources/methods. These will
|
90 | * override common options defined in `StageOptions#methodOptions`.
|
91 | *
|
92 | * @param path is {resource_path}/{http_method} (i.e. /api/toys/GET) for an
|
93 | * individual method override. You can use `*` for both {resource_path} and {http_method}
|
94 | * to define options for all methods/resources.
|
95 | *
|
96 | * @default - Common options will be used.
|
97 | */
|
98 | readonly methodOptions?: {
|
99 | [path: string]: MethodDeploymentOptions;
|
100 | };
|
101 | }
|
102 | export interface StageProps extends StageOptions {
|
103 | /**
|
104 | * The deployment that this stage points to [disable-awslint:ref-via-interface].
|
105 | */
|
106 | readonly deployment: Deployment;
|
107 | }
|
108 | export declare enum MethodLoggingLevel {
|
109 | OFF = "OFF",
|
110 | ERROR = "ERROR",
|
111 | INFO = "INFO"
|
112 | }
|
113 | export interface MethodDeploymentOptions {
|
114 | /**
|
115 | * Specifies whether Amazon CloudWatch metrics are enabled for this method.
|
116 | *
|
117 | * @default false
|
118 | */
|
119 | readonly metricsEnabled?: boolean;
|
120 | /**
|
121 | * Specifies the logging level for this method, which effects the log
|
122 | * entries pushed to Amazon CloudWatch Logs.
|
123 | *
|
124 | * @default - Off
|
125 | */
|
126 | readonly loggingLevel?: MethodLoggingLevel;
|
127 | /**
|
128 | * Specifies whether data trace logging is enabled for this method.
|
129 | * When enabled, API gateway will log the full API requests and responses.
|
130 | * This can be useful to troubleshoot APIs, but can result in logging sensitive data.
|
131 | * We recommend that you don't enable this feature for production APIs.
|
132 | *
|
133 | * @default false
|
134 | */
|
135 | readonly dataTraceEnabled?: boolean;
|
136 | /**
|
137 | * Specifies the throttling burst limit.
|
138 | * The total rate of all requests in your AWS account is limited to 5,000 requests.
|
139 | * @see https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-request-throttling.html
|
140 | *
|
141 | * @default - No additional restriction.
|
142 | */
|
143 | readonly throttlingBurstLimit?: number;
|
144 | /**
|
145 | * Specifies the throttling rate limit.
|
146 | * The total rate of all requests in your AWS account is limited to 10,000 requests per second (rps).
|
147 | * @see https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-request-throttling.html
|
148 | *
|
149 | * @default - No additional restriction.
|
150 | */
|
151 | readonly throttlingRateLimit?: number;
|
152 | /**
|
153 | * Specifies whether responses should be cached and returned for requests. A
|
154 | * cache cluster must be enabled on the stage for responses to be cached.
|
155 | *
|
156 | * @default - Caching is Disabled.
|
157 | */
|
158 | readonly cachingEnabled?: boolean;
|
159 | /**
|
160 | * Specifies the time to live (TTL), in seconds, for cached responses. The
|
161 | * higher the TTL, the longer the response will be cached.
|
162 | * @see https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-caching.html
|
163 | *
|
164 | * @default Duration.minutes(5)
|
165 | */
|
166 | readonly cacheTtl?: Duration;
|
167 | /**
|
168 | * Indicates whether the cached responses are encrypted.
|
169 | *
|
170 | * @default false
|
171 | */
|
172 | readonly cacheDataEncrypted?: boolean;
|
173 | }
|
174 | export declare class Stage extends Resource implements IStage {
|
175 | readonly stageName: string;
|
176 | readonly restApi: IRestApi;
|
177 | private enableCacheCluster?;
|
178 | constructor(scope: Construct, id: string, props: StageProps);
|
179 | /**
|
180 | * Returns the invoke URL for a certain path.
|
181 | * @param path The resource path
|
182 | */
|
183 | urlForPath(path?: string): string;
|
184 | /**
|
185 | * Returns the resource ARN for this stage:
|
186 | *
|
187 | * arn:aws:apigateway:{region}::/restapis/{restApiId}/stages/{stageName}
|
188 | *
|
189 | * Note that this is separate from the execute-api ARN for methods and resources
|
190 | * within this stage.
|
191 | *
|
192 | *
|
193 | */
|
194 | get stageArn(): string;
|
195 | private renderMethodSettings;
|
196 | }
|