UNPKG

@pulumi/aws

Version:

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

270 lines • 10.5 kB
"use strict"; // *** WARNING: this file was generated by pulumi-language-nodejs. *** // *** Do not edit by hand unless you're certain you know what you are doing! *** Object.defineProperty(exports, "__esModule", { value: true }); exports.Integration = void 0; const pulumi = require("@pulumi/pulumi"); const utilities = require("../utilities"); /** * 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 * ``` */ 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, id, state, opts) { return new Integration(name, state, { ...opts, id: id }); } /** * 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) { if (obj === undefined || obj === null) { return false; } return obj['__pulumiType'] === Integration.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["cacheKeyParameters"] = state?.cacheKeyParameters; resourceInputs["cacheNamespace"] = state?.cacheNamespace; resourceInputs["connectionId"] = state?.connectionId; resourceInputs["connectionType"] = state?.connectionType; resourceInputs["contentHandling"] = state?.contentHandling; resourceInputs["credentials"] = state?.credentials; resourceInputs["httpMethod"] = state?.httpMethod; resourceInputs["integrationHttpMethod"] = state?.integrationHttpMethod; resourceInputs["passthroughBehavior"] = state?.passthroughBehavior; resourceInputs["region"] = state?.region; resourceInputs["requestParameters"] = state?.requestParameters; resourceInputs["requestTemplates"] = state?.requestTemplates; resourceInputs["resourceId"] = state?.resourceId; resourceInputs["restApi"] = state?.restApi; resourceInputs["timeoutMilliseconds"] = state?.timeoutMilliseconds; resourceInputs["tlsConfig"] = state?.tlsConfig; resourceInputs["type"] = state?.type; resourceInputs["uri"] = state?.uri; } else { const args = argsOrState; if (args?.httpMethod === undefined && !opts.urn) { throw new Error("Missing required property 'httpMethod'"); } if (args?.resourceId === undefined && !opts.urn) { throw new Error("Missing required property 'resourceId'"); } if (args?.restApi === undefined && !opts.urn) { throw new Error("Missing required property 'restApi'"); } if (args?.type === undefined && !opts.urn) { throw new Error("Missing required property 'type'"); } resourceInputs["cacheKeyParameters"] = args?.cacheKeyParameters; resourceInputs["cacheNamespace"] = args?.cacheNamespace; resourceInputs["connectionId"] = args?.connectionId; resourceInputs["connectionType"] = args?.connectionType; resourceInputs["contentHandling"] = args?.contentHandling; resourceInputs["credentials"] = args?.credentials; resourceInputs["httpMethod"] = args?.httpMethod; resourceInputs["integrationHttpMethod"] = args?.integrationHttpMethod; resourceInputs["passthroughBehavior"] = args?.passthroughBehavior; resourceInputs["region"] = args?.region; resourceInputs["requestParameters"] = args?.requestParameters; resourceInputs["requestTemplates"] = args?.requestTemplates; resourceInputs["resourceId"] = args?.resourceId; resourceInputs["restApi"] = args?.restApi; resourceInputs["timeoutMilliseconds"] = args?.timeoutMilliseconds; resourceInputs["tlsConfig"] = args?.tlsConfig; resourceInputs["type"] = args?.type; resourceInputs["uri"] = args?.uri; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); super(Integration.__pulumiType, name, resourceInputs, opts); } } exports.Integration = Integration; /** @internal */ Integration.__pulumiType = 'aws:apigateway/integration:Integration'; //# sourceMappingURL=integration.js.map