aws-cdk-lib.aws_apigateway.GatewayResponse

class GatewayResponse (construct)

LanguageType name
.NETAmazon.CDK.AWS.APIGateway.GatewayResponse
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awsapigateway#GatewayResponse
Javasoftware.amazon.awscdk.services.apigateway.GatewayResponse
Pythonaws_cdk.aws_apigateway.GatewayResponse
TypeScript (source)aws-cdk-lib » aws_apigateway » GatewayResponse

Implements IConstruct, IDependable, IResource, IGatewayResponse

Configure the response received by clients, produced from the API Gateway backend.

Example

// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import { aws_apigateway as apigateway } from 'aws-cdk-lib';

declare const responseType: apigateway.ResponseType;
declare const restApi: apigateway.RestApi;
const gatewayResponse = new apigateway.GatewayResponse(this, 'MyGatewayResponse', {
  restApi: restApi,
  type: responseType,

  // the properties below are optional
  responseHeaders: {
    responseHeadersKey: 'responseHeaders',
  },
  statusCode: 'statusCode',
  templates: {
    templatesKey: 'templates',
  },
});

Initializer

new GatewayResponse(scope: Construct, id: string, props: GatewayResponseProps)

Parameters

  • scope Construct
  • id string
  • props GatewayResponseProps

Construct Props

NameTypeDescription
restApiIRestApiRest api resource to target.
typeResponseTypeResponse type to associate with gateway response.
responseHeaders?{ [string]: string }Custom headers parameters for response.
statusCode?stringHttp status code for response.
templates?{ [string]: string }Custom templates to get mapped as response.

restApi

Type: IRestApi

Rest api resource to target.


type

Type: ResponseType

Response type to associate with gateway response.

See also: https://docs.aws.amazon.com/apigateway/latest/developerguide/supported-gateway-response-types.html


responseHeaders?

Type: { [string]: string } (optional, default: no headers)

Custom headers parameters for response.


statusCode?

Type: string (optional, default: standard http status code for the response type.)

Http status code for response.


templates?

Type: { [string]: string } (optional, default: Response from api will be returned without applying any transformation.)

Custom templates to get mapped as response.

Properties

NameTypeDescription
envResourceEnvironmentThe environment this resource belongs to.
nodeNodeThe tree node.
stackStackThe stack in which this resource is defined.

env

Type: ResourceEnvironment

The environment this resource belongs to.

For resources that are created and managed by the CDK (generally, those created by creating new class instances like Role, Bucket, etc.), this is always the same as the environment of the stack they belong to; however, for imported resources (those obtained from static methods like fromRoleArn, fromBucketName, etc.), that might be different than the stack they were imported into.


node

Type: Node

The tree node.


stack

Type: Stack

The stack in which this resource is defined.

Methods

NameDescription
applyRemovalPolicy(policy)Apply the given removal policy to this resource.
toString()Returns a string representation of this construct.

applyRemovalPolicy(policy)

public applyRemovalPolicy(policy: RemovalPolicy): void

Parameters

  • policy RemovalPolicy

Apply the given removal policy to this resource.

The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you've removed it from the CDK application or because you've made a change that requires the resource to be replaced.

The resource can be deleted (RemovalPolicy.DESTROY), or left in your AWS account for data recovery and cleanup later (RemovalPolicy.RETAIN).


toString()

public toString(): string

Returns

  • string

Returns a string representation of this construct.