Response
Provides an API Gateway Gateway Response for a REST API Gateway.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const main = new aws.apigateway.RestApi("main", {name: "MyDemoAPI"});
const test = new aws.apigateway.Response("test", {
restApiId: main.id,
statusCode: "401",
responseType: "UNAUTHORIZED",
responseTemplates: {
"application/json": "{\"message\":$context.error.messageString}",
},
responseParameters: {
"gatewayresponse.header.Authorization": "'Basic'",
},
});
Content copied to clipboard
import pulumi
import pulumi_aws as aws
main = aws.apigateway.RestApi("main", name="MyDemoAPI")
test = aws.apigateway.Response("test",
rest_api_id=main.id,
status_code="401",
response_type="UNAUTHORIZED",
response_templates={
"application/json": "{\"message\":$context.error.messageString}",
},
response_parameters={
"gatewayresponse.header.Authorization": "'Basic'",
})
Content copied to clipboard
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
return await Deployment.RunAsync(() =>
{
var main = new Aws.ApiGateway.RestApi("main", new()
{
Name = "MyDemoAPI",
});
var test = new Aws.ApiGateway.Response("test", new()
{
RestApiId = main.Id,
StatusCode = "401",
ResponseType = "UNAUTHORIZED",
ResponseTemplates =
{
{ "application/json", "{\"message\":$context.error.messageString}" },
},
ResponseParameters =
{
{ "gatewayresponse.header.Authorization", "'Basic'" },
},
});
});
Content copied to clipboard
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/apigateway"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
main, err := apigateway.NewRestApi(ctx, "main", &apigateway.RestApiArgs{
Name: pulumi.String("MyDemoAPI"),
})
if err != nil {
return err
}
_, err = apigateway.NewResponse(ctx, "test", &apigateway.ResponseArgs{
RestApiId: main.ID(),
StatusCode: pulumi.String("401"),
ResponseType: pulumi.String("UNAUTHORIZED"),
ResponseTemplates: pulumi.StringMap{
"application/json": pulumi.String("{\"message\":$context.error.messageString}"),
},
ResponseParameters: pulumi.StringMap{
"gatewayresponse.header.Authorization": pulumi.String("'Basic'"),
},
})
if err != nil {
return err
}
return nil
})
}
Content copied to clipboard
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.Response;
import com.pulumi.aws.apigateway.ResponseArgs;
import java.util.List;
import java.util.ArrayList;
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 main = new RestApi("main", RestApiArgs.builder()
.name("MyDemoAPI")
.build());
var test = new Response("test", ResponseArgs.builder()
.restApiId(main.id())
.statusCode("401")
.responseType("UNAUTHORIZED")
.responseTemplates(Map.of("application/json", "{\"message\":$context.error.messageString}"))
.responseParameters(Map.of("gatewayresponse.header.Authorization", "'Basic'"))
.build());
}
}
Content copied to clipboard
resources:
main:
type: aws:apigateway:RestApi
properties:
name: MyDemoAPI
test:
type: aws:apigateway:Response
properties:
restApiId: ${main.id}
statusCode: '401'
responseType: UNAUTHORIZED
responseTemplates:
application/json: '{"message":$context.error.messageString}'
responseParameters:
gatewayresponse.header.Authorization: '''Basic'''
Content copied to clipboard
Import
Using pulumi import
, import aws_api_gateway_gateway_response
using REST-API-ID/RESPONSE-TYPE
. For example:
$ pulumi import aws:apigateway/response:Response example 12345abcde/UNAUTHORIZED
Content copied to clipboard
Properties
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Map of parameters (paths, query strings and headers) of the Gateway Response.
Link copied to clipboard
Map of templates used to transform the response body.
Link copied to clipboard
Response type of the associated GatewayResponse.
Link copied to clipboard
HTTP status code of the Gateway Response.