IntegrationResponse
Provides an HTTP Method Integration Response for an API Gateway Resource.
Note: Depends on having
aws.apigateway.Integrationinside your rest api. To ensure this you might need to add an explicitdepends_onfor clean runs.
Example Usage
using Pulumi;
using Aws = Pulumi.Aws;
class MyStack : Stack
{
public MyStack()
{
var myDemoAPI = new Aws.ApiGateway.RestApi("myDemoAPI", new Aws.ApiGateway.RestApiArgs
{
Description = "This is my API for demonstration purposes",
});
var myDemoResource = new Aws.ApiGateway.Resource("myDemoResource", new Aws.ApiGateway.ResourceArgs
{
ParentId = myDemoAPI.RootResourceId,
PathPart = "mydemoresource",
RestApi = myDemoAPI.Id,
});
var myDemoMethod = new Aws.ApiGateway.Method("myDemoMethod", new Aws.ApiGateway.MethodArgs
{
Authorization = "NONE",
HttpMethod = "GET",
ResourceId = myDemoResource.Id,
RestApi = myDemoAPI.Id,
});
var myDemoIntegration = new Aws.ApiGateway.Integration("myDemoIntegration", new Aws.ApiGateway.IntegrationArgs
{
HttpMethod = myDemoMethod.HttpMethod,
ResourceId = myDemoResource.Id,
RestApi = myDemoAPI.Id,
Type = "MOCK",
});
var response200 = new Aws.ApiGateway.MethodResponse("response200", new Aws.ApiGateway.MethodResponseArgs
{
HttpMethod = myDemoMethod.HttpMethod,
ResourceId = myDemoResource.Id,
RestApi = myDemoAPI.Id,
StatusCode = "200",
});
var myDemoIntegrationResponse = new Aws.ApiGateway.IntegrationResponse("myDemoIntegrationResponse", new Aws.ApiGateway.IntegrationResponseArgs
{
HttpMethod = myDemoMethod.HttpMethod,
ResourceId = myDemoResource.Id,
ResponseTemplates =
{
{ "application/xml", @"#set($inputRoot = $input.path('$'))
<?xml version=""1.0"" encoding=""UTF-8""?>
<message>
$inputRoot.body
</message>
" },
},
RestApi = myDemoAPI.Id,
StatusCode = response200.StatusCode,
});
}
}
package main
import (
"fmt"
"github.com/pulumi/pulumi-aws/sdk/v2/go/aws/apigateway"
"github.com/pulumi/pulumi/sdk/v2/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
myDemoAPI, err := apigateway.NewRestApi(ctx, "myDemoAPI", &apigateway.RestApiArgs{
Description: pulumi.String("This is my API for demonstration purposes"),
})
if err != nil {
return err
}
myDemoResource, err := apigateway.NewResource(ctx, "myDemoResource", &apigateway.ResourceArgs{
ParentId: myDemoAPI.RootResourceId,
PathPart: pulumi.String("mydemoresource"),
RestApi: myDemoAPI.ID(),
})
if err != nil {
return err
}
myDemoMethod, err := apigateway.NewMethod(ctx, "myDemoMethod", &apigateway.MethodArgs{
Authorization: pulumi.String("NONE"),
HttpMethod: pulumi.String("GET"),
ResourceId: myDemoResource.ID(),
RestApi: myDemoAPI.ID(),
})
if err != nil {
return err
}
_, err = apigateway.NewIntegration(ctx, "myDemoIntegration", &apigateway.IntegrationArgs{
HttpMethod: myDemoMethod.HttpMethod,
ResourceId: myDemoResource.ID(),
RestApi: myDemoAPI.ID(),
Type: pulumi.String("MOCK"),
})
if err != nil {
return err
}
response200, err := apigateway.NewMethodResponse(ctx, "response200", &apigateway.MethodResponseArgs{
HttpMethod: myDemoMethod.HttpMethod,
ResourceId: myDemoResource.ID(),
RestApi: myDemoAPI.ID(),
StatusCode: pulumi.String("200"),
})
if err != nil {
return err
}
_, err = apigateway.NewIntegrationResponse(ctx, "myDemoIntegrationResponse", &apigateway.IntegrationResponseArgs{
HttpMethod: myDemoMethod.HttpMethod,
ResourceId: myDemoResource.ID(),
ResponseTemplates: pulumi.StringMap{
"application/xml": pulumi.String(fmt.Sprintf("%v%v%v%v%v%v%v%v%v%v%v%v%v%v", "#set(", "$", "inputRoot = ", "$", "input.path('", "$", "'))\n", "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n", "<message>\n", " ", "$", "inputRoot.body\n", "</message>\n", "\n")),
},
RestApi: myDemoAPI.ID(),
StatusCode: response200.StatusCode,
})
if err != nil {
return err
}
return nil
})
}import pulumi
import pulumi_aws as aws
my_demo_api = aws.apigateway.RestApi("myDemoAPI", description="This is my API for demonstration purposes")
my_demo_resource = aws.apigateway.Resource("myDemoResource",
parent_id=my_demo_api.root_resource_id,
path_part="mydemoresource",
rest_api=my_demo_api.id)
my_demo_method = aws.apigateway.Method("myDemoMethod",
authorization="NONE",
http_method="GET",
resource_id=my_demo_resource.id,
rest_api=my_demo_api.id)
my_demo_integration = aws.apigateway.Integration("myDemoIntegration",
http_method=my_demo_method.http_method,
resource_id=my_demo_resource.id,
rest_api=my_demo_api.id,
type="MOCK")
response200 = aws.apigateway.MethodResponse("response200",
http_method=my_demo_method.http_method,
resource_id=my_demo_resource.id,
rest_api=my_demo_api.id,
status_code="200")
my_demo_integration_response = aws.apigateway.IntegrationResponse("myDemoIntegrationResponse",
http_method=my_demo_method.http_method,
resource_id=my_demo_resource.id,
response_templates={
"application/xml": """#set($inputRoot = $input.path('$'))
<?xml version="1.0" encoding="UTF-8"?>
<message>
$inputRoot.body
</message>
""",
},
rest_api=my_demo_api.id,
status_code=response200.status_code)import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const myDemoAPI = new aws.apigateway.RestApi("MyDemoAPI", {
description: "This is my API for demonstration purposes",
});
const myDemoResource = new aws.apigateway.Resource("MyDemoResource", {
parentId: myDemoAPI.rootResourceId,
pathPart: "mydemoresource",
restApi: myDemoAPI.id,
});
const myDemoMethod = new aws.apigateway.Method("MyDemoMethod", {
authorization: "NONE",
httpMethod: "GET",
resourceId: myDemoResource.id,
restApi: myDemoAPI.id,
});
const myDemoIntegration = new aws.apigateway.Integration("MyDemoIntegration", {
httpMethod: myDemoMethod.httpMethod,
resourceId: myDemoResource.id,
restApi: myDemoAPI.id,
type: "MOCK",
});
const response200 = new aws.apigateway.MethodResponse("response_200", {
httpMethod: myDemoMethod.httpMethod,
resourceId: myDemoResource.id,
restApi: myDemoAPI.id,
statusCode: "200",
});
const myDemoIntegrationResponse = new aws.apigateway.IntegrationResponse("MyDemoIntegrationResponse", {
httpMethod: myDemoMethod.httpMethod,
resourceId: myDemoResource.id,
// Transforms the backend JSON response to XML
responseTemplates: {
"application/xml": `#set($inputRoot = $input.path('$'))
<?xml version="1.0" encoding="UTF-8"?>
<message>
$inputRoot.body
</message>
`,
},
restApi: myDemoAPI.id,
statusCode: response200.statusCode,
});Create a IntegrationResponse Resource
new IntegrationResponse(name: string, args: IntegrationResponseArgs, opts?: CustomResourceOptions);def IntegrationResponse(resource_name, opts=None, content_handling=None, http_method=None, resource_id=None, response_parameters=None, response_templates=None, rest_api=None, selection_pattern=None, status_code=None, __props__=None);func NewIntegrationResponse(ctx *Context, name string, args IntegrationResponseArgs, opts ...ResourceOption) (*IntegrationResponse, error)public IntegrationResponse(string name, IntegrationResponseArgs args, CustomResourceOptions? opts = null)- name string
- The unique name of the resource.
- args IntegrationResponseArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- resource_name str
- The unique name of the resource.
- opts ResourceOptions
- A bag of options that control this resource's behavior.
- ctx Context
- Context object for the current deployment.
- name string
- The unique name of the resource.
- args IntegrationResponseArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args IntegrationResponseArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
IntegrationResponse Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Programming Model docs.
Inputs
The IntegrationResponse resource accepts the following input properties:
- Http
Method string The HTTP method (
GET,POST,PUT,DELETE,HEAD,OPTIONS,ANY)- Resource
Id string The API resource ID
- Rest
Api string The ID of the associated REST API
- Status
Code string The HTTP status code
- Content
Handling string Specifies how to handle request payload content type conversions. Supported values are
CONVERT_TO_BINARYandCONVERT_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.- Response
Parameters Dictionary<string, string> A map of response parameters that can be read from the backend response. For example:
response_parameters = { "method.response.header.X-Some-Header" = "integration.response.header.X-Some-Other-Header" }- Response
Templates Dictionary<string, string> A map specifying the templates used to transform the integration response body
- Selection
Pattern string Specifies the regular expression pattern used to choose an integration response based on the response from the backend. Setting this to
-makes the integration the default one. If the backend is anAWSLambda function, the AWS Lambda function error header is matched. For all otherHTTPandAWSbackends, the HTTP status code is matched.
- Http
Method string The HTTP method (
GET,POST,PUT,DELETE,HEAD,OPTIONS,ANY)- Resource
Id string The API resource ID
- Rest
Api interface{} The ID of the associated REST API
- Status
Code string The HTTP status code
- Content
Handling string Specifies how to handle request payload content type conversions. Supported values are
CONVERT_TO_BINARYandCONVERT_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.- Response
Parameters map[string]string A map of response parameters that can be read from the backend response. For example:
response_parameters = { "method.response.header.X-Some-Header" = "integration.response.header.X-Some-Other-Header" }- Response
Templates map[string]string A map specifying the templates used to transform the integration response body
- Selection
Pattern string Specifies the regular expression pattern used to choose an integration response based on the response from the backend. Setting this to
-makes the integration the default one. If the backend is anAWSLambda function, the AWS Lambda function error header is matched. For all otherHTTPandAWSbackends, the HTTP status code is matched.
- http
Method string The HTTP method (
GET,POST,PUT,DELETE,HEAD,OPTIONS,ANY)- resource
Id string The API resource ID
- rest
Api string | RestApi The ID of the associated REST API
- status
Code string The HTTP status code
- content
Handling string Specifies how to handle request payload content type conversions. Supported values are
CONVERT_TO_BINARYandCONVERT_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.- response
Parameters {[key: string]: string} A map of response parameters that can be read from the backend response. For example:
response_parameters = { "method.response.header.X-Some-Header" = "integration.response.header.X-Some-Other-Header" }- response
Templates {[key: string]: string} A map specifying the templates used to transform the integration response body
- selection
Pattern string Specifies the regular expression pattern used to choose an integration response based on the response from the backend. Setting this to
-makes the integration the default one. If the backend is anAWSLambda function, the AWS Lambda function error header is matched. For all otherHTTPandAWSbackends, the HTTP status code is matched.
- http_
method str The HTTP method (
GET,POST,PUT,DELETE,HEAD,OPTIONS,ANY)- resource_
id str The API resource ID
- rest_
api string | str The ID of the associated REST API
- status_
code str The HTTP status code
- content_
handling str Specifies how to handle request payload content type conversions. Supported values are
CONVERT_TO_BINARYandCONVERT_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.- response_
parameters Dict[str, str] A map of response parameters that can be read from the backend response. For example:
response_parameters = { "method.response.header.X-Some-Header" = "integration.response.header.X-Some-Other-Header" }- response_
templates Dict[str, str] A map specifying the templates used to transform the integration response body
- selection_
pattern str Specifies the regular expression pattern used to choose an integration response based on the response from the backend. Setting this to
-makes the integration the default one. If the backend is anAWSLambda function, the AWS Lambda function error header is matched. For all otherHTTPandAWSbackends, the HTTP status code is matched.
Outputs
All input properties are implicitly available as output properties. Additionally, the IntegrationResponse resource produces the following output properties:
Look up an Existing IntegrationResponse Resource
Get an existing IntegrationResponse resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.
public static get(name: string, id: Input<ID>, state?: IntegrationResponseState, opts?: CustomResourceOptions): IntegrationResponsestatic get(resource_name, id, opts=None, content_handling=None, http_method=None, resource_id=None, response_parameters=None, response_templates=None, rest_api=None, selection_pattern=None, status_code=None, __props__=None);func GetIntegrationResponse(ctx *Context, name string, id IDInput, state *IntegrationResponseState, opts ...ResourceOption) (*IntegrationResponse, error)public static IntegrationResponse Get(string name, Input<string> id, IntegrationResponseState? state, CustomResourceOptions? opts = null)- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- resource_name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
The following state arguments are supported:
- Content
Handling string Specifies how to handle request payload content type conversions. Supported values are
CONVERT_TO_BINARYandCONVERT_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.- Http
Method string The HTTP method (
GET,POST,PUT,DELETE,HEAD,OPTIONS,ANY)- Resource
Id string The API resource ID
- Response
Parameters Dictionary<string, string> A map of response parameters that can be read from the backend response. For example:
response_parameters = { "method.response.header.X-Some-Header" = "integration.response.header.X-Some-Other-Header" }- Response
Templates Dictionary<string, string> A map specifying the templates used to transform the integration response body
- Rest
Api string The ID of the associated REST API
- Selection
Pattern string Specifies the regular expression pattern used to choose an integration response based on the response from the backend. Setting this to
-makes the integration the default one. If the backend is anAWSLambda function, the AWS Lambda function error header is matched. For all otherHTTPandAWSbackends, the HTTP status code is matched.- Status
Code string The HTTP status code
- Content
Handling string Specifies how to handle request payload content type conversions. Supported values are
CONVERT_TO_BINARYandCONVERT_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.- Http
Method string The HTTP method (
GET,POST,PUT,DELETE,HEAD,OPTIONS,ANY)- Resource
Id string The API resource ID
- Response
Parameters map[string]string A map of response parameters that can be read from the backend response. For example:
response_parameters = { "method.response.header.X-Some-Header" = "integration.response.header.X-Some-Other-Header" }- Response
Templates map[string]string A map specifying the templates used to transform the integration response body
- Rest
Api interface{} The ID of the associated REST API
- Selection
Pattern string Specifies the regular expression pattern used to choose an integration response based on the response from the backend. Setting this to
-makes the integration the default one. If the backend is anAWSLambda function, the AWS Lambda function error header is matched. For all otherHTTPandAWSbackends, the HTTP status code is matched.- Status
Code string The HTTP status code
- content
Handling string Specifies how to handle request payload content type conversions. Supported values are
CONVERT_TO_BINARYandCONVERT_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.- http
Method string The HTTP method (
GET,POST,PUT,DELETE,HEAD,OPTIONS,ANY)- resource
Id string The API resource ID
- response
Parameters {[key: string]: string} A map of response parameters that can be read from the backend response. For example:
response_parameters = { "method.response.header.X-Some-Header" = "integration.response.header.X-Some-Other-Header" }- response
Templates {[key: string]: string} A map specifying the templates used to transform the integration response body
- rest
Api string | RestApi The ID of the associated REST API
- selection
Pattern string Specifies the regular expression pattern used to choose an integration response based on the response from the backend. Setting this to
-makes the integration the default one. If the backend is anAWSLambda function, the AWS Lambda function error header is matched. For all otherHTTPandAWSbackends, the HTTP status code is matched.- status
Code string The HTTP status code
- content_
handling str Specifies how to handle request payload content type conversions. Supported values are
CONVERT_TO_BINARYandCONVERT_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.- http_
method str The HTTP method (
GET,POST,PUT,DELETE,HEAD,OPTIONS,ANY)- resource_
id str The API resource ID
- response_
parameters Dict[str, str] A map of response parameters that can be read from the backend response. For example:
response_parameters = { "method.response.header.X-Some-Header" = "integration.response.header.X-Some-Other-Header" }- response_
templates Dict[str, str] A map specifying the templates used to transform the integration response body
- rest_
api string | str The ID of the associated REST API
- selection_
pattern str Specifies the regular expression pattern used to choose an integration response based on the response from the backend. Setting this to
-makes the integration the default one. If the backend is anAWSLambda function, the AWS Lambda function error header is matched. For all otherHTTPandAWSbackends, the HTTP status code is matched.- status_
code str The HTTP status code
Package Details
- Repository
- https://github.com/pulumi/pulumi-aws
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
awsTerraform Provider.