1 | import * as iam from '@aws-cdk/aws-iam';
|
2 | import { Duration } from '@aws-cdk/core';
|
3 | import { Method } from './method';
|
4 | import { IVpcLink } from './vpc-link';
|
5 | export interface IntegrationOptions {
|
6 | /**
|
7 | * A list of request parameters whose values are to be cached. It determines
|
8 | * request parameters that will make it into the cache key.
|
9 | */
|
10 | readonly cacheKeyParameters?: string[];
|
11 | /**
|
12 | * An API-specific tag group of related cached parameters.
|
13 | */
|
14 | readonly cacheNamespace?: string;
|
15 | /**
|
16 | * Specifies how to handle request payload content type conversions.
|
17 | *
|
18 | * @default none if this property isn't defined, the request payload is passed
|
19 | * through from the method request to the integration request without
|
20 | * modification, provided that the `passthroughBehaviors` property is
|
21 | * configured to support payload pass-through.
|
22 | */
|
23 | readonly contentHandling?: ContentHandling;
|
24 | /**
|
25 | * An IAM role that API Gateway assumes.
|
26 | *
|
27 | * Mutually exclusive with `credentialsPassThrough`.
|
28 | *
|
29 | * @default A role is not assumed
|
30 | */
|
31 | readonly credentialsRole?: iam.IRole;
|
32 | /**
|
33 | * Requires that the caller's identity be passed through from the request.
|
34 | *
|
35 | * @default Caller identity is not passed through
|
36 | */
|
37 | readonly credentialsPassthrough?: boolean;
|
38 | /**
|
39 | * Specifies the pass-through behavior for incoming requests based on the
|
40 | * Content-Type header in the request, and the available mapping templates
|
41 | * specified as the requestTemplates property on the Integration resource.
|
42 | * There are three valid values: WHEN_NO_MATCH, WHEN_NO_TEMPLATES, and
|
43 | * NEVER.
|
44 | */
|
45 | readonly passthroughBehavior?: PassthroughBehavior;
|
46 | /**
|
47 | * The request parameters that API Gateway sends with the backend request.
|
48 | * Specify request parameters as key-value pairs (string-to-string
|
49 | * mappings), with a destination as the key and a source as the value.
|
50 | *
|
51 | * Specify the destination by using the following pattern
|
52 | * integration.request.location.name, where location is querystring, path,
|
53 | * or header, and name is a valid, unique parameter name.
|
54 | *
|
55 | * The source must be an existing method request parameter or a static
|
56 | * value. You must enclose static values in single quotation marks and
|
57 | * pre-encode these values based on their destination in the request.
|
58 | */
|
59 | readonly requestParameters?: {
|
60 | [dest: string]: string;
|
61 | };
|
62 | /**
|
63 | * A map of Apache Velocity templates that are applied on the request
|
64 | * payload. The template that API Gateway uses is based on the value of the
|
65 | * Content-Type header that's sent by the client. The content type value is
|
66 | * the key, and the template is the value (specified as a string), such as
|
67 | * the following snippet:
|
68 | *
|
69 | * ```
|
70 | * { "application/json": "{ \"statusCode\": 200 }" }
|
71 | * ```
|
72 | *
|
73 | * @see http://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-mapping-template-reference.html
|
74 | */
|
75 | readonly requestTemplates?: {
|
76 | [contentType: string]: string;
|
77 | };
|
78 | /**
|
79 | * The maximum amount of time an integration will run before it returns without a response.
|
80 | * Must be between 50 milliseconds and 29 seconds.
|
81 | *
|
82 | * @default Duration.seconds(29)
|
83 | */
|
84 | readonly timeout?: Duration;
|
85 | /**
|
86 | * The response that API Gateway provides after a method's backend completes
|
87 | * processing a request. API Gateway intercepts the response from the
|
88 | * backend so that you can control how API Gateway surfaces backend
|
89 | * responses. For example, you can map the backend status codes to codes
|
90 | * that you define.
|
91 | */
|
92 | readonly integrationResponses?: IntegrationResponse[];
|
93 | /**
|
94 | * The type of network connection to the integration endpoint.
|
95 | * @default - ConnectionType.VPC_LINK if `vpcLink` property is configured; ConnectionType.Internet otherwise.
|
96 | */
|
97 | readonly connectionType?: ConnectionType;
|
98 | /**
|
99 | * The VpcLink used for the integration.
|
100 | * Required if connectionType is VPC_LINK
|
101 | */
|
102 | readonly vpcLink?: IVpcLink;
|
103 | }
|
104 | export interface IntegrationProps {
|
105 | /**
|
106 | * Specifies an API method integration type.
|
107 | */
|
108 | readonly type: IntegrationType;
|
109 | /**
|
110 | * The Uniform Resource Identifier (URI) for the integration.
|
111 | *
|
112 | * - If you specify HTTP for the `type` property, specify the API endpoint URL.
|
113 | * - If you specify MOCK for the `type` property, don't specify this property.
|
114 | * - If you specify AWS for the `type` property, specify an AWS service that
|
115 | * follows this form: `arn:partition:apigateway:region:subdomain.service|service:path|action/service_api.`
|
116 | * For example, a Lambda function URI follows this form:
|
117 | * arn:partition:apigateway:region:lambda:path/path. The path is usually in the
|
118 | * form /2015-03-31/functions/LambdaFunctionARN/invocations.
|
119 | *
|
120 | * @see https://docs.aws.amazon.com/apigateway/api-reference/resource/integration/#uri
|
121 | */
|
122 | readonly uri?: any;
|
123 | /**
|
124 | * The integration's HTTP method type.
|
125 | * Required unless you use a MOCK integration.
|
126 | */
|
127 | readonly integrationHttpMethod?: string;
|
128 | /**
|
129 | * Integration options.
|
130 | */
|
131 | readonly options?: IntegrationOptions;
|
132 | }
|
133 | /**
|
134 | * Result of binding an Integration to a Method.
|
135 | */
|
136 | export interface IntegrationConfig {
|
137 | /**
|
138 | * Integration options.
|
139 | * @default - no integration options
|
140 | */
|
141 | readonly options?: IntegrationOptions;
|
142 | /**
|
143 | * Specifies an API method integration type.
|
144 | */
|
145 | readonly type: IntegrationType;
|
146 | /**
|
147 | * The Uniform Resource Identifier (URI) for the integration.
|
148 | * @see https://docs.aws.amazon.com/apigateway/api-reference/resource/integration/#uri
|
149 | * @default - no URI. Usually applies to MOCK integration
|
150 | */
|
151 | readonly uri?: string;
|
152 | /**
|
153 | * The integration's HTTP method type.
|
154 | * @default - no integration method specified.
|
155 | */
|
156 | readonly integrationHttpMethod?: string;
|
157 | /**
|
158 | * This value is included in computing the Deployment's fingerprint. When the fingerprint
|
159 | * changes, a new deployment is triggered.
|
160 | * This property should contain values associated with the Integration that upon changing
|
161 | * should trigger a fresh the Deployment needs to be refreshed.
|
162 | * @default undefined deployments are not triggered for any change to this integration.
|
163 | */
|
164 | readonly deploymentToken?: string;
|
165 | }
|
166 | /**
|
167 | * Base class for backend integrations for an API Gateway method.
|
168 | *
|
169 | * Use one of the concrete classes such as `MockIntegration`, `AwsIntegration`, `LambdaIntegration`
|
170 | * or implement on your own by specifying the set of props.
|
171 | */
|
172 | export declare class Integration {
|
173 | private readonly props;
|
174 | constructor(props: IntegrationProps);
|
175 | /**
|
176 | * Can be overridden by subclasses to allow the integration to interact with the method
|
177 | * being integrated, access the REST API object, method ARNs, etc.
|
178 | */
|
179 | bind(_method: Method): IntegrationConfig;
|
180 | }
|
181 | export declare enum ContentHandling {
|
182 | /**
|
183 | * Converts a request payload from a base64-encoded string to a binary blob.
|
184 | */
|
185 | CONVERT_TO_BINARY = "CONVERT_TO_BINARY",
|
186 | /**
|
187 | * Converts a request payload from a binary blob to a base64-encoded string.
|
188 | */
|
189 | CONVERT_TO_TEXT = "CONVERT_TO_TEXT"
|
190 | }
|
191 | export declare enum IntegrationType {
|
192 | /**
|
193 | * For integrating the API method request with an AWS service action,
|
194 | * including the Lambda function-invoking action. With the Lambda
|
195 | * function-invoking action, this is referred to as the Lambda custom
|
196 | * integration. With any other AWS service action, this is known as AWS
|
197 | * integration.
|
198 | */
|
199 | AWS = "AWS",
|
200 | /**
|
201 | * For integrating the API method request with the Lambda function-invoking
|
202 | * action with the client request passed through as-is. This integration is
|
203 | * also referred to as the Lambda proxy integration
|
204 | */
|
205 | AWS_PROXY = "AWS_PROXY",
|
206 | /**
|
207 | * For integrating the API method request with an HTTP endpoint, including a
|
208 | * private HTTP endpoint within a VPC. This integration is also referred to
|
209 | * as the HTTP custom integration.
|
210 | */
|
211 | HTTP = "HTTP",
|
212 | /**
|
213 | * For integrating the API method request with an HTTP endpoint, including a
|
214 | * private HTTP endpoint within a VPC, with the client request passed
|
215 | * through as-is. This is also referred to as the HTTP proxy integration
|
216 | */
|
217 | HTTP_PROXY = "HTTP_PROXY",
|
218 | /**
|
219 | * For integrating the API method request with API Gateway as a "loop-back"
|
220 | * endpoint without invoking any backend.
|
221 | */
|
222 | MOCK = "MOCK"
|
223 | }
|
224 | export declare enum PassthroughBehavior {
|
225 | /**
|
226 | * Passes the request body for unmapped content types through to the
|
227 | * integration back end without transformation.
|
228 | */
|
229 | WHEN_NO_MATCH = "WHEN_NO_MATCH",
|
230 | /**
|
231 | * Rejects unmapped content types with an HTTP 415 'Unsupported Media Type'
|
232 | * response
|
233 | */
|
234 | NEVER = "NEVER",
|
235 | /**
|
236 | * Allows pass-through when the integration has NO content types mapped to
|
237 | * templates. However if there is at least one content type defined,
|
238 | * unmapped content types will be rejected with the same 415 response.
|
239 | */
|
240 | WHEN_NO_TEMPLATES = "WHEN_NO_TEMPLATES"
|
241 | }
|
242 | export declare enum ConnectionType {
|
243 | /**
|
244 | * For connections through the public routable internet
|
245 | */
|
246 | INTERNET = "INTERNET",
|
247 | /**
|
248 | * For private connections between API Gateway and a network load balancer in a VPC
|
249 | */
|
250 | VPC_LINK = "VPC_LINK"
|
251 | }
|
252 | export interface IntegrationResponse {
|
253 | /**
|
254 | * Specifies the regular expression (regex) pattern used to choose an integration response based on the response from
|
255 | * the back end. For example, if the success response returns nothing and the error response returns some string, you
|
256 | * could use the ``.+`` regex to match error response. However, make sure that the error response does not contain any
|
257 | * newline (``\n``) character in such cases. If the back end is an AWS Lambda function, the AWS Lambda function error
|
258 | * header is matched. For all other HTTP and AWS back ends, the HTTP status code is matched.
|
259 | *
|
260 | * @see https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-integration-settings-integration-response.html
|
261 | */
|
262 | readonly selectionPattern?: string;
|
263 | /**
|
264 | * The status code that API Gateway uses to map the integration response to
|
265 | * a MethodResponse status code.
|
266 | */
|
267 | readonly statusCode: string;
|
268 | /**
|
269 | * Specifies how to handle request payload content type conversions.
|
270 | *
|
271 | * @default none the request payload is passed through from the method
|
272 | * request to the integration request without modification.
|
273 | */
|
274 | readonly contentHandling?: ContentHandling;
|
275 | /**
|
276 | * The response parameters from the backend response that API Gateway sends
|
277 | * to the method response.
|
278 | *
|
279 | * Use the destination as the key and the source as the value:
|
280 | *
|
281 | * - The destination must be an existing response parameter in the
|
282 | * MethodResponse property.
|
283 | * - The source must be an existing method request parameter or a static
|
284 | * value. You must enclose static values in single quotation marks and
|
285 | * pre-encode these values based on the destination specified in the
|
286 | * request.
|
287 | *
|
288 | * @see http://docs.aws.amazon.com/apigateway/latest/developerguide/request-response-data-mappings.html
|
289 | */
|
290 | readonly responseParameters?: {
|
291 | [destination: string]: string;
|
292 | };
|
293 | /**
|
294 | * The templates that are used to transform the integration response body.
|
295 | * Specify templates as key-value pairs, with a content type as the key and
|
296 | * a template as the value.
|
297 | *
|
298 | * @see http://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-mapping-template-reference.html
|
299 | */
|
300 | readonly responseTemplates?: {
|
301 | [contentType: string]: string;
|
302 | };
|
303 | }
|