IntegrationResponse class

Provides an HTTP Method Integration Response for an API Gateway Resource.

> Note: Depends on having aws.apigateway.Integration inside your rest api. To ensure this you might need to add an explicit dependsOn for clean runs.

Example Usage

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",
});
const response200 = new aws.apigateway.MethodResponse("response_200", {
    restApi: myDemoAPI.id,
    resourceId: myDemoResource.id,
    httpMethod: myDemoMethod.httpMethod,
    statusCode: "200",
});
const myDemoIntegrationResponse = new aws.apigateway.IntegrationResponse("MyDemoIntegrationResponse", {
    restApi: myDemoAPI.id,
    resourceId: myDemoResource.id,
    httpMethod: myDemoMethod.httpMethod,
    statusCode: response200.statusCode,
    responseTemplates: {
        "application/xml": `#set(inputRoot = input.path(''))
<?xml version=\\"1.0\\" encoding=\\"UTF-8\\"?>
<message>
    inputRoot.body
</message>
`,
    },
});
import pulumi
import pulumi_aws as aws

my_demo_api = aws.apigateway.RestApi("MyDemoAPI",
    name="MyDemoAPI",
    description="This is my API for demonstration purposes")
my_demo_resource = aws.apigateway.Resource("MyDemoResource",
    rest_api=my_demo_api.id,
    parent_id=my_demo_api.root_resource_id,
    path_part="mydemoresource")
my_demo_method = aws.apigateway.Method("MyDemoMethod",
    rest_api=my_demo_api.id,
    resource_id=my_demo_resource.id,
    http_method="GET",
    authorization="NONE")
my_demo_integration = aws.apigateway.Integration("MyDemoIntegration",
    rest_api=my_demo_api.id,
    resource_id=my_demo_resource.id,
    http_method=my_demo_method.http_method,
    type="MOCK")
response200 = aws.apigateway.MethodResponse("response_200",
    rest_api=my_demo_api.id,
    resource_id=my_demo_resource.id,
    http_method=my_demo_method.http_method,
    status_code="200")
my_demo_integration_response = aws.apigateway.IntegrationResponse("MyDemoIntegrationResponse",
    rest_api=my_demo_api.id,
    resource_id=my_demo_resource.id,
    http_method=my_demo_method.http_method,
    status_code=response200.status_code,
    response_templates={
        "application/xml": """#set($inputRoot = $input.path('$'))
<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<message>
    $inputRoot.body
</message>
""",
    })
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;

return await Deployment.RunAsync(() =>
{
    var myDemoAPI = new Aws.ApiGateway.RestApi("MyDemoAPI", new()
    {
        Name = "MyDemoAPI",
        Description = "This is my API for demonstration purposes",
    });

    var myDemoResource = new Aws.ApiGateway.Resource("MyDemoResource", new()
    {
        RestApi = myDemoAPI.Id,
        ParentId = myDemoAPI.RootResourceId,
        PathPart = "mydemoresource",
    });

    var myDemoMethod = new Aws.ApiGateway.Method("MyDemoMethod", new()
    {
        RestApi = myDemoAPI.Id,
        ResourceId = myDemoResource.Id,
        HttpMethod = "GET",
        Authorization = "NONE",
    });

    var myDemoIntegration = new Aws.ApiGateway.Integration("MyDemoIntegration", new()
    {
        RestApi = myDemoAPI.Id,
        ResourceId = myDemoResource.Id,
        HttpMethod = myDemoMethod.HttpMethod,
        Type = "MOCK",
    });

    var response200 = new Aws.ApiGateway.MethodResponse("response_200", new()
    {
        RestApi = myDemoAPI.Id,
        ResourceId = myDemoResource.Id,
        HttpMethod = myDemoMethod.HttpMethod,
        StatusCode = "200",
    });

    var myDemoIntegrationResponse = new Aws.ApiGateway.IntegrationResponse("MyDemoIntegrationResponse", new()
    {
        RestApi = myDemoAPI.Id,
        ResourceId = myDemoResource.Id,
        HttpMethod = myDemoMethod.HttpMethod,
        StatusCode = response200.StatusCode,
        ResponseTemplates =
        {
            { "application/xml", @"#set($inputRoot = $input.path('$'))
<?xml version=\""1.0\"" encoding=\""UTF-8\""?>
<message>
    $inputRoot.body
</message>
" },
        },
    });

});
package main

import (
	"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/apigateway"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		myDemoAPI, err := apigateway.NewRestApi(ctx, "MyDemoAPI", &apigateway.RestApiArgs{
			Name:        pulumi.String("MyDemoAPI"),
			Description: pulumi.String("This is my API for demonstration purposes"),
		})
		if err != nil {
			return err
		}
		myDemoResource, err := apigateway.NewResource(ctx, "MyDemoResource", &apigateway.ResourceArgs{
			RestApi:  myDemoAPI.ID().ToIDOutput().ToStringOutput(),
			ParentId: myDemoAPI.RootResourceId,
			PathPart: pulumi.String("mydemoresource"),
		})
		if err != nil {
			return err
		}
		myDemoMethod, err := apigateway.NewMethod(ctx, "MyDemoMethod", &apigateway.MethodArgs{
			RestApi:       myDemoAPI.ID().ToIDOutput().ToStringOutput(),
			ResourceId:    myDemoResource.ID().ToIDOutput().ToStringOutput(),
			HttpMethod:    pulumi.String("GET"),
			Authorization: pulumi.String("NONE"),
		})
		if err != nil {
			return err
		}
		_, err = apigateway.NewIntegration(ctx, "MyDemoIntegration", &apigateway.IntegrationArgs{
			RestApi:    myDemoAPI.ID().ToIDOutput().ToStringOutput(),
			ResourceId: myDemoResource.ID().ToIDOutput().ToStringOutput(),
			HttpMethod: myDemoMethod.HttpMethod,
			Type:       pulumi.String("MOCK"),
		})
		if err != nil {
			return err
		}
		response200, err := apigateway.NewMethodResponse(ctx, "response_200", &apigateway.MethodResponseArgs{
			RestApi:    myDemoAPI.ID().ToIDOutput().ToStringOutput(),
			ResourceId: myDemoResource.ID().ToIDOutput().ToStringOutput(),
			HttpMethod: myDemoMethod.HttpMethod,
			StatusCode: pulumi.String("200"),
		})
		if err != nil {
			return err
		}
		_, err = apigateway.NewIntegrationResponse(ctx, "MyDemoIntegrationResponse", &apigateway.IntegrationResponseArgs{
			RestApi:    myDemoAPI.ID().ToIDOutput().ToStringOutput(),
			ResourceId: myDemoResource.ID().ToIDOutput().ToStringOutput(),
			HttpMethod: myDemoMethod.HttpMethod,
			StatusCode: response200.StatusCode,
			ResponseTemplates: pulumi.StringMap{
				"application/xml": pulumi.String(`#set($inputRoot = $input.path('$'))
<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<message>
    $inputRoot.body
</message>
`),
			},
		})
		if err != nil {
			return err
		}
		return nil
	})
}
pulumi {
  required_providers {
    aws = {
      source = "pulumi/aws"
    }
  }
}

resource "aws_apigateway_restapi" "MyDemoAPI" {
  name        = "MyDemoAPI"
  description = "This is my API for demonstration purposes"
}
resource "aws_apigateway_resource" "MyDemoResource" {
  rest_api  = aws_apigateway_restapi.MyDemoAPI.id
  parent_id = aws_apigateway_restapi.MyDemoAPI.root_resource_id
  path_part = "mydemoresource"
}
resource "aws_apigateway_method" "MyDemoMethod" {
  rest_api      = aws_apigateway_restapi.MyDemoAPI.id
  resource_id   = aws_apigateway_resource.MyDemoResource.id
  http_method   = "GET"
  authorization = "NONE"
}
resource "aws_apigateway_integration" "MyDemoIntegration" {
  rest_api    = aws_apigateway_restapi.MyDemoAPI.id
  resource_id = aws_apigateway_resource.MyDemoResource.id
  http_method = aws_apigateway_method.MyDemoMethod.http_method
  type        = "MOCK"
}
resource "aws_apigateway_methodresponse" "response_200" {
  rest_api    = aws_apigateway_restapi.MyDemoAPI.id
  resource_id = aws_apigateway_resource.MyDemoResource.id
  http_method = aws_apigateway_method.MyDemoMethod.http_method
  status_code = "200"
}
resource "aws_apigateway_integrationresponse" "MyDemoIntegrationResponse" {
  rest_api    = aws_apigateway_restapi.MyDemoAPI.id
  resource_id = aws_apigateway_resource.MyDemoResource.id
  http_method = aws_apigateway_method.MyDemoMethod.http_method
  status_code = aws_apigateway_methodresponse.response_200.status_code
  response_templates = {
    "application/xml" = "#set($inputRoot = $input.path('$'))\n<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?>\n<message>\n    $inputRoot.body\n</message>\n"
  }
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.apigateway.RestApi;
import com.pulumi.aws.apigateway.RestApiArgs;
import com.pulumi.aws.apigateway.Resource;
import com.pulumi.aws.apigateway.ResourceArgs;
import com.pulumi.aws.apigateway.Method;
import com.pulumi.aws.apigateway.MethodArgs;
import com.pulumi.aws.apigateway.Integration;
import com.pulumi.aws.apigateway.IntegrationArgs;
import com.pulumi.aws.apigateway.MethodResponse;
import com.pulumi.aws.apigateway.MethodResponseArgs;
import com.pulumi.aws.apigateway.IntegrationResponse;
import com.pulumi.aws.apigateway.IntegrationResponseArgs;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        var myDemoAPI = new RestApi("myDemoAPI", RestApiArgs.builder()
            .name("MyDemoAPI")
            .description("This is my API for demonstration purposes")
            .build());

        var myDemoResource = new Resource("myDemoResource", ResourceArgs.builder()
            .restApi(myDemoAPI.id())
            .parentId(myDemoAPI.rootResourceId())
            .pathPart("mydemoresource")
            .build());

        var myDemoMethod = new Method("myDemoMethod", MethodArgs.builder()
            .restApi(myDemoAPI.id())
            .resourceId(myDemoResource.id())
            .httpMethod("GET")
            .authorization("NONE")
            .build());

        var myDemoIntegration = new Integration("myDemoIntegration", IntegrationArgs.builder()
            .restApi(myDemoAPI.id())
            .resourceId(myDemoResource.id())
            .httpMethod(myDemoMethod.httpMethod())
            .type("MOCK")
            .build());

        var response200 = new MethodResponse("response200", MethodResponseArgs.builder()
            .restApi(myDemoAPI.id())
            .resourceId(myDemoResource.id())
            .httpMethod(myDemoMethod.httpMethod())
            .statusCode("200")
            .build());

        var myDemoIntegrationResponse = new IntegrationResponse("myDemoIntegrationResponse", IntegrationResponseArgs.builder()
            .restApi(myDemoAPI.id())
            .resourceId(myDemoResource.id())
            .httpMethod(myDemoMethod.httpMethod())
            .statusCode(response200.statusCode())
            .responseTemplates(Map.of("application/xml", """
#set($inputRoot = $input.path('$'))
<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<message>
    $inputRoot.body
</message>
            """))
            .build());

    }
}
resources:
  myDemoAPI:
    type: aws:apigateway:RestApi
    name: MyDemoAPI
    properties:
      name: MyDemoAPI
      description: This is my API for demonstration purposes
  myDemoResource:
    type: aws:apigateway:Resource
    name: MyDemoResource
    properties:
      restApi: ${myDemoAPI.id}
      parentId: ${myDemoAPI.rootResourceId}
      pathPart: mydemoresource
  myDemoMethod:
    type: aws:apigateway:Method
    name: MyDemoMethod
    properties:
      restApi: ${myDemoAPI.id}
      resourceId: ${myDemoResource.id}
      httpMethod: GET
      authorization: NONE
  myDemoIntegration:
    type: aws:apigateway:Integration
    name: MyDemoIntegration
    properties:
      restApi: ${myDemoAPI.id}
      resourceId: ${myDemoResource.id}
      httpMethod: ${myDemoMethod.httpMethod}
      type: MOCK
  response200:
    type: aws:apigateway:MethodResponse
    name: response_200
    properties:
      restApi: ${myDemoAPI.id}
      resourceId: ${myDemoResource.id}
      httpMethod: ${myDemoMethod.httpMethod}
      statusCode: '200'
  myDemoIntegrationResponse:
    type: aws:apigateway:IntegrationResponse
    name: MyDemoIntegrationResponse
    properties:
      restApi: ${myDemoAPI.id}
      resourceId: ${myDemoResource.id}
      httpMethod: ${myDemoMethod.httpMethod}
      statusCode: ${response200.statusCode}
      responseTemplates:
        application/xml: |
          #set($inputRoot = $input.path('$'))
          <?xml version=\"1.0\" encoding=\"UTF-8\"?>
          <message>
              $inputRoot.body
          </message>

Import

Identity Schema

Required

  • restApiId (String) ID of the associated REST API.
  • resourceId (String) API resource ID.
  • httpMethod (String) HTTP Method.
  • statusCode (String) HTTP status code.

Optional

  • accountId (String) AWS Account where this resource is managed.
  • region (String) Region where this resource is managed.

Using pulumi import, import aws.apigateway.IntegrationResponse using REST-API-ID/RESOURCE-ID/HTTP-METHOD/STATUS-CODE. For example:

$ pulumi import aws:apigateway/integrationResponse:IntegrationResponse example 12345abcde/67890fghij/GET/200

Constructors

IntegrationResponse(String name, {IntegrationResponseArgs? args, CustomResourceOptions? options})
Creates a new IntegrationResponse. name The Pulumi resource name. args Arguments used to configure this IntegrationResponse. The set of arguments for IntegrationResponse. options Resource options controlling this resource's behavior.
IntegrationResponse.reference(String urn)
Creates a typed reference to an existing IntegrationResponse resource.

Properties

childResources → Set<Resource>
finalinherited
completionSources ↔ Map<String, IOutputCompletionSource>
latefinalinherited
contentHandling ↔ Output<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 response payload will be passed through from the integration response to the method response without modification.
latefinal
hashCode → int
The hash code for this object.
no setterinherited
httpMethod ↔ Output<String>
HTTP method (GET, POST, PUT, DELETE, HEAD, OPTIONS, ANY).
latefinal
id ↔ Output<String>
getter/setter pairinherited
isCustom → bool
Returns whether this resource is provider-managed.
no setterinherited
isProtected → bool
Returns whether this resource is protected from deletion.
no setterinherited
isRemote → bool
Whether this resource is registered as remote.
no setterinherited
isResourceReference → bool
Whether this instance represents a resource value returned over RPC.
finalinherited
region ↔ Output<String>
Region where this resource will be managed. Defaults to the Region set in the provider configuration.
latefinal
resourceId ↔ Output<String>
API resource ID.
latefinal
resourceTransforms → List<ResourceTransform>
Inherited/explicit async transforms.
no setterinherited
responseParameters ↔ Output<Map<String, String>?>
Map of response parameters that can be read from the backend response. For example: responseParameters = { "method.response.header.X-Some-Header" = "integration.response.header.X-Some-Other-Header" }.
latefinal
responseTemplates ↔ Output<Map<String, String>?>
Map of templates used to transform the integration response body.
latefinal
restApi ↔ Output<String>
ID of the associated REST API.
latefinal
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
selectionPattern ↔ Output<String?>
Regular expression pattern used to choose an integration response based on the response from the backend. Omit configuring this to make the integration the default one. If the backend is an AWS Lambda function, the AWS Lambda function error header is matched. For all other HTTP and AWS backends, the HTTP status code is matched.
latefinal
statusCode ↔ Output<String>
HTTP status code.
latefinal
transformations → List<ResourceTransformation>
Inherited/explicit legacy transformations.
no setterinherited
urn ↔ Output<String>
latefinalinherited

Methods

failId(Object error) → void
Completes this resource ID with an error when registration fails.
inherited
failOutputs(Object error) → void
Completes all output properties with error.
inherited
failUrn(Object error) → void
Completes this resource URN with an error when registration fails.
inherited
getProvider(String moduleMember) → ProviderResource?
Returns provider for moduleMember's package, if configured.
inherited
getResourceName() → String
Returns this resource's logical name.
inherited
getResourceType() → String
Returns this resource's Pulumi type token.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
registerOutput<T>(String propertyName, {Object? decoder(Object?)?, bool isSecret = false}) → Output<T>
Registers a dynamic output property for this resource.
inherited
resolveId(String? value, {required bool isKnown}) → void
Resolves the provider-assigned ID for this resource.
inherited
resolveOutputs(Struct outputs) → void
Resolves all output properties from a monitor response payload.
inherited
resolveUrn(String value) → void
Resolves this resource's URN once assigned by the engine.
inherited
serializeProperties(Map<String, dynamic> properties) → Future<Struct>
Serializes resource properties for RPC transmission.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

get(String name, Input<String> id, {IntegrationResponseState? state, CustomResourceOptions? options}) → IntegrationResponse
Gets an existing IntegrationResponse resource's state with the given name and id.