UNPKG

@pulumi/aws

Version:

A Pulumi package for creating and managing Amazon Web Services (AWS) cloud resources.

467 lines (466 loc) • 23.1 kB
import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; import { RestApi } from "./index"; /** * Provides an HTTP Method Integration for an API Gateway Integration. * * ## Example Usage * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const myDemoAPI = new aws.apigateway.RestApi("MyDemoAPI", { * name: "MyDemoAPI", * description: "This is my API for demonstration purposes", * }); * const myDemoResource = new aws.apigateway.Resource("MyDemoResource", { * restApi: myDemoAPI.id, * parentId: myDemoAPI.rootResourceId, * pathPart: "mydemoresource", * }); * const myDemoMethod = new aws.apigateway.Method("MyDemoMethod", { * restApi: myDemoAPI.id, * resourceId: myDemoResource.id, * httpMethod: "GET", * authorization: "NONE", * }); * const myDemoIntegration = new aws.apigateway.Integration("MyDemoIntegration", { * restApi: myDemoAPI.id, * resourceId: myDemoResource.id, * httpMethod: myDemoMethod.httpMethod, * type: "MOCK", * cacheKeyParameters: ["method.request.path.param"], * cacheNamespace: "foobar", * timeoutMilliseconds: 29000, * requestParameters: { * "integration.request.header.X-Authorization": "'static'", * }, * requestTemplates: { * "application/xml": `{ * "body" : input.json('') * } * `, * }, * }); * ``` * * ## Lambda integration * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * import * as std from "@pulumi/std"; * * const config = new pulumi.Config(); * const myregion = config.requireObject<any>("myregion"); * const accountId = config.requireObject<any>("accountId"); * // API Gateway * const api = new aws.apigateway.RestApi("api", {name: "myapi"}); * const resource = new aws.apigateway.Resource("resource", { * pathPart: "resource", * parentId: api.rootResourceId, * restApi: api.id, * }); * const method = new aws.apigateway.Method("method", { * restApi: api.id, * resourceId: resource.id, * httpMethod: "GET", * authorization: "NONE", * }); * // IAM * const assumeRole = aws.iam.getPolicyDocument({ * statements: [{ * effect: "Allow", * principals: [{ * type: "Service", * identifiers: ["lambda.amazonaws.com"], * }], * actions: ["sts:AssumeRole"], * }], * }); * const role = new aws.iam.Role("role", { * name: "myrole", * assumeRolePolicy: assumeRole.then(assumeRole => assumeRole.json), * }); * const lambda = new aws.lambda.Function("lambda", { * code: new pulumi.asset.FileArchive("lambda.zip"), * name: "mylambda", * role: role.arn, * handler: "lambda.lambda_handler", * runtime: aws.lambda.Runtime.Python3d12, * sourceCodeHash: std.filebase64sha256({ * input: "lambda.zip", * }).then(invoke => invoke.result), * }); * const integration = new aws.apigateway.Integration("integration", { * restApi: api.id, * resourceId: resource.id, * httpMethod: method.httpMethod, * integrationHttpMethod: "POST", * type: "AWS_PROXY", * uri: lambda.invokeArn, * }); * // Lambda * const apigwLambda = new aws.lambda.Permission("apigw_lambda", { * statementId: "AllowExecutionFromAPIGateway", * action: "lambda:InvokeFunction", * "function": lambda.name, * principal: "apigateway.amazonaws.com", * sourceArn: pulumi.interpolate`arn:aws:execute-api:${myregion}:${accountId}:${api.id}/*&#47;${method.httpMethod}${resource.path}`, * }); * ``` * * ## VPC Link * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const config = new pulumi.Config(); * const name = config.requireObject<any>("name"); * const subnetId = config.requireObject<any>("subnetId"); * const test = new aws.lb.LoadBalancer("test", { * name: name, * internal: true, * loadBalancerType: "network", * subnets: [subnetId], * }); * const testVpcLink = new aws.apigateway.VpcLink("test", { * name: name, * targetArn: test.arn, * }); * const testRestApi = new aws.apigateway.RestApi("test", {name: name}); * const testResource = new aws.apigateway.Resource("test", { * restApi: testRestApi.id, * parentId: testRestApi.rootResourceId, * pathPart: "test", * }); * const testMethod = new aws.apigateway.Method("test", { * restApi: testRestApi.id, * resourceId: testResource.id, * httpMethod: "GET", * authorization: "NONE", * requestModels: { * "application/json": "Error", * }, * }); * const testIntegration = new aws.apigateway.Integration("test", { * restApi: testRestApi.id, * resourceId: testResource.id, * httpMethod: testMethod.httpMethod, * requestTemplates: { * "application/json": "", * "application/xml": `#set(inputRoot = input.path('')) * { }`, * }, * requestParameters: { * "integration.request.header.X-Authorization": "'static'", * "integration.request.header.X-Foo": "'Bar'", * }, * type: "HTTP", * uri: "https://www.google.de", * integrationHttpMethod: "GET", * passthroughBehavior: "WHEN_NO_MATCH", * contentHandling: "CONVERT_TO_TEXT", * connectionType: "VPC_LINK", * connectionId: testVpcLink.id, * }); * ``` * * ## Import * * Using `pulumi import`, import `aws_api_gateway_integration` using `REST-API-ID/RESOURCE-ID/HTTP-METHOD`. For example: * * ```sh * $ pulumi import aws:apigateway/integration:Integration example 12345abcde/67890fghij/GET * ``` */ export declare class Integration extends pulumi.CustomResource { /** * Get an existing Integration resource's state with the given name, ID, and optional extra * properties used to qualify the lookup. * * @param name The _unique_ name of the resulting resource. * @param id The _unique_ provider ID of the resource to lookup. * @param state Any extra arguments used during the lookup. * @param opts Optional settings to control the behavior of the CustomResource. */ static get(name: string, id: pulumi.Input<pulumi.ID>, state?: IntegrationState, opts?: pulumi.CustomResourceOptions): Integration; /** * Returns true if the given object is an instance of Integration. This is designed to work even * when multiple copies of the Pulumi SDK have been loaded into the same process. */ static isInstance(obj: any): obj is Integration; /** * List of cache key parameters for the integration. */ readonly cacheKeyParameters: pulumi.Output<string[] | undefined>; /** * Integration's cache namespace. */ readonly cacheNamespace: pulumi.Output<string>; /** * ID of the VpcLink used for the integration. **Required** if `connectionType` is `VPC_LINK` */ readonly connectionId: pulumi.Output<string | undefined>; /** * Integration input's [connectionType](https://docs.aws.amazon.com/apigateway/api-reference/resource/integration/#connectionType). Valid values are `INTERNET` (default for connections through the public routable internet), and `VPC_LINK` (for private connections between API Gateway and a network load balancer in a VPC). */ readonly connectionType: pulumi.Output<string | undefined>; /** * How to handle request payload content type conversions. Supported values are `CONVERT_TO_BINARY` and `CONVERT_TO_TEXT`. If this property is not defined, the request payload will be passed through from the method request to integration request without modification, provided that the passthroughBehaviors is configured to support payload pass-through. */ readonly contentHandling: pulumi.Output<string | undefined>; /** * Credentials required for the integration. For `AWS` integrations, 2 options are available. To specify an IAM Role for Amazon API Gateway to assume, use the role's ARN. To require that the caller's identity be passed through from the request, specify the string `arn:aws:iam::\*:user/\*`. */ readonly credentials: pulumi.Output<string | undefined>; /** * HTTP method (`GET`, `POST`, `PUT`, `DELETE`, `HEAD`, `OPTION`, `ANY`) * when calling the associated resource. */ readonly httpMethod: pulumi.Output<string>; /** * Integration HTTP method * (`GET`, `POST`, `PUT`, `DELETE`, `HEAD`, `OPTIONs`, `ANY`, `PATCH`) specifying how API Gateway will interact with the back end. * **Required** if `type` is `AWS`, `AWS_PROXY`, `HTTP` or `HTTP_PROXY`. * Not all methods are compatible with all `AWS` integrations. * e.g., Lambda function [can only be invoked](https://github.com/awslabs/aws-apigateway-importer/issues/9#issuecomment-129651005) via `POST`. */ readonly integrationHttpMethod: pulumi.Output<string | undefined>; /** * Integration passthrough behavior (`WHEN_NO_MATCH`, `WHEN_NO_TEMPLATES`, `NEVER`). **Required** if `requestTemplates` is used. */ readonly passthroughBehavior: pulumi.Output<string>; /** * Region where this resource will be [managed](https://docs.aws.amazon.com/general/latest/gr/rande.html#regional-endpoints). Defaults to the Region set in the provider configuration. */ readonly region: pulumi.Output<string>; /** * Map of request query string parameters and headers that should be passed to the backend responder. * For example: `requestParameters = { "integration.request.header.X-Some-Other-Header" = "method.request.header.X-Some-Header" }` */ readonly requestParameters: pulumi.Output<{ [key: string]: string; } | undefined>; /** * Map of the integration's request templates. */ readonly requestTemplates: pulumi.Output<{ [key: string]: string; } | undefined>; /** * API resource ID. */ readonly resourceId: pulumi.Output<string>; /** * ID of the associated REST API. */ readonly restApi: pulumi.Output<string>; /** * Custom timeout between 50 and 300,000 milliseconds. The default value is 29,000 milliseconds. You need to raise a [Service Quota Ticket](https://docs.aws.amazon.com/general/latest/gr/aws_service_limits.html) to increase time beyond 29,000 milliseconds. */ readonly timeoutMilliseconds: pulumi.Output<number | undefined>; /** * TLS configuration. See below. */ readonly tlsConfig: pulumi.Output<outputs.apigateway.IntegrationTlsConfig | undefined>; /** * Integration input's [type](https://docs.aws.amazon.com/apigateway/api-reference/resource/integration/). Valid values are `HTTP` (for HTTP backends), `MOCK` (not calling any real backend), `AWS` (for AWS services), `AWS_PROXY` (for Lambda proxy integration) and `HTTP_PROXY` (for HTTP proxy integration). An `HTTP` or `HTTP_PROXY` integration with a `connectionType` of `VPC_LINK` is referred to as a private integration and uses a VpcLink to connect API Gateway to a network load balancer of a VPC. */ readonly type: pulumi.Output<string>; /** * Input's URI. **Required** if `type` is `AWS`, `AWS_PROXY`, `HTTP` or `HTTP_PROXY`. * For HTTP integrations, the URI must be a fully formed, encoded HTTP(S) URL according to the RFC-3986 specification . For AWS integrations, the URI should be of the form `arn:aws:apigateway:{region}:{subdomain.service|service}:{path|action}/{service_api}`. `region`, `subdomain` and `service` are used to determine the right endpoint. * e.g., `arn:aws:apigateway:eu-west-1:lambda:path/2015-03-31/functions/arn:aws:lambda:eu-west-1:123456789012:function:my-func/invocations`. For private integrations, the URI parameter is not used for routing requests to your endpoint, but is used for setting the Host header and for certificate validation. */ readonly uri: pulumi.Output<string | undefined>; /** * Create a Integration resource with the given unique name, arguments, and options. * * @param name The _unique_ name of the resource. * @param args The arguments to use to populate this resource's properties. * @param opts A bag of options that control this resource's behavior. */ constructor(name: string, args: IntegrationArgs, opts?: pulumi.CustomResourceOptions); } /** * Input properties used for looking up and filtering Integration resources. */ export interface IntegrationState { /** * List of cache key parameters for the integration. */ cacheKeyParameters?: pulumi.Input<pulumi.Input<string>[]>; /** * Integration's cache namespace. */ cacheNamespace?: pulumi.Input<string>; /** * ID of the VpcLink used for the integration. **Required** if `connectionType` is `VPC_LINK` */ connectionId?: pulumi.Input<string>; /** * Integration input's [connectionType](https://docs.aws.amazon.com/apigateway/api-reference/resource/integration/#connectionType). Valid values are `INTERNET` (default for connections through the public routable internet), and `VPC_LINK` (for private connections between API Gateway and a network load balancer in a VPC). */ connectionType?: pulumi.Input<string>; /** * How to handle request payload content type conversions. Supported values are `CONVERT_TO_BINARY` and `CONVERT_TO_TEXT`. If this property is not defined, the request payload will be passed through from the method request to integration request without modification, provided that the passthroughBehaviors is configured to support payload pass-through. */ contentHandling?: pulumi.Input<string>; /** * Credentials required for the integration. For `AWS` integrations, 2 options are available. To specify an IAM Role for Amazon API Gateway to assume, use the role's ARN. To require that the caller's identity be passed through from the request, specify the string `arn:aws:iam::\*:user/\*`. */ credentials?: pulumi.Input<string>; /** * HTTP method (`GET`, `POST`, `PUT`, `DELETE`, `HEAD`, `OPTION`, `ANY`) * when calling the associated resource. */ httpMethod?: pulumi.Input<string>; /** * Integration HTTP method * (`GET`, `POST`, `PUT`, `DELETE`, `HEAD`, `OPTIONs`, `ANY`, `PATCH`) specifying how API Gateway will interact with the back end. * **Required** if `type` is `AWS`, `AWS_PROXY`, `HTTP` or `HTTP_PROXY`. * Not all methods are compatible with all `AWS` integrations. * e.g., Lambda function [can only be invoked](https://github.com/awslabs/aws-apigateway-importer/issues/9#issuecomment-129651005) via `POST`. */ integrationHttpMethod?: pulumi.Input<string>; /** * Integration passthrough behavior (`WHEN_NO_MATCH`, `WHEN_NO_TEMPLATES`, `NEVER`). **Required** if `requestTemplates` is used. */ passthroughBehavior?: pulumi.Input<string>; /** * Region where this resource will be [managed](https://docs.aws.amazon.com/general/latest/gr/rande.html#regional-endpoints). Defaults to the Region set in the provider configuration. */ region?: pulumi.Input<string>; /** * Map of request query string parameters and headers that should be passed to the backend responder. * For example: `requestParameters = { "integration.request.header.X-Some-Other-Header" = "method.request.header.X-Some-Header" }` */ requestParameters?: pulumi.Input<{ [key: string]: pulumi.Input<string>; }>; /** * Map of the integration's request templates. */ requestTemplates?: pulumi.Input<{ [key: string]: pulumi.Input<string>; }>; /** * API resource ID. */ resourceId?: pulumi.Input<string>; /** * ID of the associated REST API. */ restApi?: pulumi.Input<string | RestApi>; /** * Custom timeout between 50 and 300,000 milliseconds. The default value is 29,000 milliseconds. You need to raise a [Service Quota Ticket](https://docs.aws.amazon.com/general/latest/gr/aws_service_limits.html) to increase time beyond 29,000 milliseconds. */ timeoutMilliseconds?: pulumi.Input<number>; /** * TLS configuration. See below. */ tlsConfig?: pulumi.Input<inputs.apigateway.IntegrationTlsConfig>; /** * Integration input's [type](https://docs.aws.amazon.com/apigateway/api-reference/resource/integration/). Valid values are `HTTP` (for HTTP backends), `MOCK` (not calling any real backend), `AWS` (for AWS services), `AWS_PROXY` (for Lambda proxy integration) and `HTTP_PROXY` (for HTTP proxy integration). An `HTTP` or `HTTP_PROXY` integration with a `connectionType` of `VPC_LINK` is referred to as a private integration and uses a VpcLink to connect API Gateway to a network load balancer of a VPC. */ type?: pulumi.Input<string>; /** * Input's URI. **Required** if `type` is `AWS`, `AWS_PROXY`, `HTTP` or `HTTP_PROXY`. * For HTTP integrations, the URI must be a fully formed, encoded HTTP(S) URL according to the RFC-3986 specification . For AWS integrations, the URI should be of the form `arn:aws:apigateway:{region}:{subdomain.service|service}:{path|action}/{service_api}`. `region`, `subdomain` and `service` are used to determine the right endpoint. * e.g., `arn:aws:apigateway:eu-west-1:lambda:path/2015-03-31/functions/arn:aws:lambda:eu-west-1:123456789012:function:my-func/invocations`. For private integrations, the URI parameter is not used for routing requests to your endpoint, but is used for setting the Host header and for certificate validation. */ uri?: pulumi.Input<string>; } /** * The set of arguments for constructing a Integration resource. */ export interface IntegrationArgs { /** * List of cache key parameters for the integration. */ cacheKeyParameters?: pulumi.Input<pulumi.Input<string>[]>; /** * Integration's cache namespace. */ cacheNamespace?: pulumi.Input<string>; /** * ID of the VpcLink used for the integration. **Required** if `connectionType` is `VPC_LINK` */ connectionId?: pulumi.Input<string>; /** * Integration input's [connectionType](https://docs.aws.amazon.com/apigateway/api-reference/resource/integration/#connectionType). Valid values are `INTERNET` (default for connections through the public routable internet), and `VPC_LINK` (for private connections between API Gateway and a network load balancer in a VPC). */ connectionType?: pulumi.Input<string>; /** * How to handle request payload content type conversions. Supported values are `CONVERT_TO_BINARY` and `CONVERT_TO_TEXT`. If this property is not defined, the request payload will be passed through from the method request to integration request without modification, provided that the passthroughBehaviors is configured to support payload pass-through. */ contentHandling?: pulumi.Input<string>; /** * Credentials required for the integration. For `AWS` integrations, 2 options are available. To specify an IAM Role for Amazon API Gateway to assume, use the role's ARN. To require that the caller's identity be passed through from the request, specify the string `arn:aws:iam::\*:user/\*`. */ credentials?: pulumi.Input<string>; /** * HTTP method (`GET`, `POST`, `PUT`, `DELETE`, `HEAD`, `OPTION`, `ANY`) * when calling the associated resource. */ httpMethod: pulumi.Input<string>; /** * Integration HTTP method * (`GET`, `POST`, `PUT`, `DELETE`, `HEAD`, `OPTIONs`, `ANY`, `PATCH`) specifying how API Gateway will interact with the back end. * **Required** if `type` is `AWS`, `AWS_PROXY`, `HTTP` or `HTTP_PROXY`. * Not all methods are compatible with all `AWS` integrations. * e.g., Lambda function [can only be invoked](https://github.com/awslabs/aws-apigateway-importer/issues/9#issuecomment-129651005) via `POST`. */ integrationHttpMethod?: pulumi.Input<string>; /** * Integration passthrough behavior (`WHEN_NO_MATCH`, `WHEN_NO_TEMPLATES`, `NEVER`). **Required** if `requestTemplates` is used. */ passthroughBehavior?: pulumi.Input<string>; /** * Region where this resource will be [managed](https://docs.aws.amazon.com/general/latest/gr/rande.html#regional-endpoints). Defaults to the Region set in the provider configuration. */ region?: pulumi.Input<string>; /** * Map of request query string parameters and headers that should be passed to the backend responder. * For example: `requestParameters = { "integration.request.header.X-Some-Other-Header" = "method.request.header.X-Some-Header" }` */ requestParameters?: pulumi.Input<{ [key: string]: pulumi.Input<string>; }>; /** * Map of the integration's request templates. */ requestTemplates?: pulumi.Input<{ [key: string]: pulumi.Input<string>; }>; /** * API resource ID. */ resourceId: pulumi.Input<string>; /** * ID of the associated REST API. */ restApi: pulumi.Input<string | RestApi>; /** * Custom timeout between 50 and 300,000 milliseconds. The default value is 29,000 milliseconds. You need to raise a [Service Quota Ticket](https://docs.aws.amazon.com/general/latest/gr/aws_service_limits.html) to increase time beyond 29,000 milliseconds. */ timeoutMilliseconds?: pulumi.Input<number>; /** * TLS configuration. See below. */ tlsConfig?: pulumi.Input<inputs.apigateway.IntegrationTlsConfig>; /** * Integration input's [type](https://docs.aws.amazon.com/apigateway/api-reference/resource/integration/). Valid values are `HTTP` (for HTTP backends), `MOCK` (not calling any real backend), `AWS` (for AWS services), `AWS_PROXY` (for Lambda proxy integration) and `HTTP_PROXY` (for HTTP proxy integration). An `HTTP` or `HTTP_PROXY` integration with a `connectionType` of `VPC_LINK` is referred to as a private integration and uses a VpcLink to connect API Gateway to a network load balancer of a VPC. */ type: pulumi.Input<string>; /** * Input's URI. **Required** if `type` is `AWS`, `AWS_PROXY`, `HTTP` or `HTTP_PROXY`. * For HTTP integrations, the URI must be a fully formed, encoded HTTP(S) URL according to the RFC-3986 specification . For AWS integrations, the URI should be of the form `arn:aws:apigateway:{region}:{subdomain.service|service}:{path|action}/{service_api}`. `region`, `subdomain` and `service` are used to determine the right endpoint. * e.g., `arn:aws:apigateway:eu-west-1:lambda:path/2015-03-31/functions/arn:aws:lambda:eu-west-1:123456789012:function:my-func/invocations`. For private integrations, the URI parameter is not used for routing requests to your endpoint, but is used for setting the Host header and for certificate validation. */ uri?: pulumi.Input<string>; }