1. Packages
  2. AWS Classic
  3. API Docs
  4. apigateway
  5. Response

Try AWS Native preview for resources not in the classic version.

AWS Classic v6.32.0 published on Friday, Apr 19, 2024 by Pulumi

aws.apigateway.Response

Explore with Pulumi AI

aws logo

Try AWS Native preview for resources not in the classic version.

AWS Classic v6.32.0 published on Friday, Apr 19, 2024 by Pulumi

    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'",
        },
    });
    
    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'",
        })
    
    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
    	})
    }
    
    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'" },
            },
        });
    
    });
    
    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());
    
        }
    }
    
    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'''
    

    Create Response Resource

    Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

    Constructor syntax

    new Response(name: string, args: ResponseArgs, opts?: CustomResourceOptions);
    @overload
    def Response(resource_name: str,
                 args: ResponseArgs,
                 opts: Optional[ResourceOptions] = None)
    
    @overload
    def Response(resource_name: str,
                 opts: Optional[ResourceOptions] = None,
                 response_type: Optional[str] = None,
                 rest_api_id: Optional[str] = None,
                 response_parameters: Optional[Mapping[str, str]] = None,
                 response_templates: Optional[Mapping[str, str]] = None,
                 status_code: Optional[str] = None)
    func NewResponse(ctx *Context, name string, args ResponseArgs, opts ...ResourceOption) (*Response, error)
    public Response(string name, ResponseArgs args, CustomResourceOptions? opts = null)
    public Response(String name, ResponseArgs args)
    public Response(String name, ResponseArgs args, CustomResourceOptions options)
    
    type: aws:apigateway:Response
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    

    Parameters

    name string
    The unique name of the resource.
    args ResponseArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    resource_name str
    The unique name of the resource.
    args ResponseArgs
    The arguments to resource properties.
    opts ResourceOptions
    Bag of options to control resource's behavior.
    ctx Context
    Context object for the current deployment.
    name string
    The unique name of the resource.
    args ResponseArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args ResponseArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args ResponseArgs
    The arguments to resource properties.
    options CustomResourceOptions
    Bag of options to control resource's behavior.

    Example

    The following reference example uses placeholder values for all input properties.

    var responseResource = new Aws.ApiGateway.Response("responseResource", new()
    {
        ResponseType = "string",
        RestApiId = "string",
        ResponseParameters = 
        {
            { "string", "string" },
        },
        ResponseTemplates = 
        {
            { "string", "string" },
        },
        StatusCode = "string",
    });
    
    example, err := apigateway.NewResponse(ctx, "responseResource", &apigateway.ResponseArgs{
    	ResponseType: pulumi.String("string"),
    	RestApiId:    pulumi.String("string"),
    	ResponseParameters: pulumi.StringMap{
    		"string": pulumi.String("string"),
    	},
    	ResponseTemplates: pulumi.StringMap{
    		"string": pulumi.String("string"),
    	},
    	StatusCode: pulumi.String("string"),
    })
    
    var responseResource = new Response("responseResource", ResponseArgs.builder()        
        .responseType("string")
        .restApiId("string")
        .responseParameters(Map.of("string", "string"))
        .responseTemplates(Map.of("string", "string"))
        .statusCode("string")
        .build());
    
    response_resource = aws.apigateway.Response("responseResource",
        response_type="string",
        rest_api_id="string",
        response_parameters={
            "string": "string",
        },
        response_templates={
            "string": "string",
        },
        status_code="string")
    
    const responseResource = new aws.apigateway.Response("responseResource", {
        responseType: "string",
        restApiId: "string",
        responseParameters: {
            string: "string",
        },
        responseTemplates: {
            string: "string",
        },
        statusCode: "string",
    });
    
    type: aws:apigateway:Response
    properties:
        responseParameters:
            string: string
        responseTemplates:
            string: string
        responseType: string
        restApiId: string
        statusCode: string
    

    Response Resource Properties

    To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

    Inputs

    The Response resource accepts the following input properties:

    ResponseType string
    Response type of the associated GatewayResponse.
    RestApiId string
    String identifier of the associated REST API.
    ResponseParameters Dictionary<string, string>
    Map of parameters (paths, query strings and headers) of the Gateway Response.
    ResponseTemplates Dictionary<string, string>
    Map of templates used to transform the response body.
    StatusCode string
    HTTP status code of the Gateway Response.
    ResponseType string
    Response type of the associated GatewayResponse.
    RestApiId string
    String identifier of the associated REST API.
    ResponseParameters map[string]string
    Map of parameters (paths, query strings and headers) of the Gateway Response.
    ResponseTemplates map[string]string
    Map of templates used to transform the response body.
    StatusCode string
    HTTP status code of the Gateway Response.
    responseType String
    Response type of the associated GatewayResponse.
    restApiId String
    String identifier of the associated REST API.
    responseParameters Map<String,String>
    Map of parameters (paths, query strings and headers) of the Gateway Response.
    responseTemplates Map<String,String>
    Map of templates used to transform the response body.
    statusCode String
    HTTP status code of the Gateway Response.
    responseType string
    Response type of the associated GatewayResponse.
    restApiId string
    String identifier of the associated REST API.
    responseParameters {[key: string]: string}
    Map of parameters (paths, query strings and headers) of the Gateway Response.
    responseTemplates {[key: string]: string}
    Map of templates used to transform the response body.
    statusCode string
    HTTP status code of the Gateway Response.
    response_type str
    Response type of the associated GatewayResponse.
    rest_api_id str
    String identifier of the associated REST API.
    response_parameters Mapping[str, str]
    Map of parameters (paths, query strings and headers) of the Gateway Response.
    response_templates Mapping[str, str]
    Map of templates used to transform the response body.
    status_code str
    HTTP status code of the Gateway Response.
    responseType String
    Response type of the associated GatewayResponse.
    restApiId String
    String identifier of the associated REST API.
    responseParameters Map<String>
    Map of parameters (paths, query strings and headers) of the Gateway Response.
    responseTemplates Map<String>
    Map of templates used to transform the response body.
    statusCode String
    HTTP status code of the Gateway Response.

    Outputs

    All input properties are implicitly available as output properties. Additionally, the Response resource produces the following output properties:

    Id string
    The provider-assigned unique ID for this managed resource.
    Id string
    The provider-assigned unique ID for this managed resource.
    id String
    The provider-assigned unique ID for this managed resource.
    id string
    The provider-assigned unique ID for this managed resource.
    id str
    The provider-assigned unique ID for this managed resource.
    id String
    The provider-assigned unique ID for this managed resource.

    Look up Existing Response Resource

    Get an existing Response 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?: ResponseState, opts?: CustomResourceOptions): Response
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            response_parameters: Optional[Mapping[str, str]] = None,
            response_templates: Optional[Mapping[str, str]] = None,
            response_type: Optional[str] = None,
            rest_api_id: Optional[str] = None,
            status_code: Optional[str] = None) -> Response
    func GetResponse(ctx *Context, name string, id IDInput, state *ResponseState, opts ...ResourceOption) (*Response, error)
    public static Response Get(string name, Input<string> id, ResponseState? state, CustomResourceOptions? opts = null)
    public static Response get(String name, Output<String> id, ResponseState state, CustomResourceOptions options)
    Resource lookup is not supported in YAML
    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.
    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:
    ResponseParameters Dictionary<string, string>
    Map of parameters (paths, query strings and headers) of the Gateway Response.
    ResponseTemplates Dictionary<string, string>
    Map of templates used to transform the response body.
    ResponseType string
    Response type of the associated GatewayResponse.
    RestApiId string
    String identifier of the associated REST API.
    StatusCode string
    HTTP status code of the Gateway Response.
    ResponseParameters map[string]string
    Map of parameters (paths, query strings and headers) of the Gateway Response.
    ResponseTemplates map[string]string
    Map of templates used to transform the response body.
    ResponseType string
    Response type of the associated GatewayResponse.
    RestApiId string
    String identifier of the associated REST API.
    StatusCode string
    HTTP status code of the Gateway Response.
    responseParameters Map<String,String>
    Map of parameters (paths, query strings and headers) of the Gateway Response.
    responseTemplates Map<String,String>
    Map of templates used to transform the response body.
    responseType String
    Response type of the associated GatewayResponse.
    restApiId String
    String identifier of the associated REST API.
    statusCode String
    HTTP status code of the Gateway Response.
    responseParameters {[key: string]: string}
    Map of parameters (paths, query strings and headers) of the Gateway Response.
    responseTemplates {[key: string]: string}
    Map of templates used to transform the response body.
    responseType string
    Response type of the associated GatewayResponse.
    restApiId string
    String identifier of the associated REST API.
    statusCode string
    HTTP status code of the Gateway Response.
    response_parameters Mapping[str, str]
    Map of parameters (paths, query strings and headers) of the Gateway Response.
    response_templates Mapping[str, str]
    Map of templates used to transform the response body.
    response_type str
    Response type of the associated GatewayResponse.
    rest_api_id str
    String identifier of the associated REST API.
    status_code str
    HTTP status code of the Gateway Response.
    responseParameters Map<String>
    Map of parameters (paths, query strings and headers) of the Gateway Response.
    responseTemplates Map<String>
    Map of templates used to transform the response body.
    responseType String
    Response type of the associated GatewayResponse.
    restApiId String
    String identifier of the associated REST API.
    statusCode String
    HTTP status code of the Gateway Response.

    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
    

    To learn more about importing existing cloud resources, see Importing resources.

    Package Details

    Repository
    AWS Classic pulumi/pulumi-aws
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the aws Terraform Provider.
    aws logo

    Try AWS Native preview for resources not in the classic version.

    AWS Classic v6.32.0 published on Friday, Apr 19, 2024 by Pulumi