Skip to content

Resource: awsApiGatewayMethodResponse

Provides an HTTP Method Response for an API Gateway Resource.

Example Usage

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as aws from "./.gen/providers/aws";
const awsApiGatewayRestApiMyDemoApi =
  new aws.apiGatewayRestApi.ApiGatewayRestApi(this, "MyDemoAPI", {
    description: "This is my API for demonstration purposes",
    name: "MyDemoAPI",
  });
const awsApiGatewayResourceMyDemoResource =
  new aws.apiGatewayResource.ApiGatewayResource(this, "MyDemoResource", {
    parentId: awsApiGatewayRestApiMyDemoApi.rootResourceId,
    pathPart: "mydemoresource",
    restApiId: awsApiGatewayRestApiMyDemoApi.id,
  });
const awsApiGatewayMethodMyDemoMethod =
  new aws.apiGatewayMethod.ApiGatewayMethod(this, "MyDemoMethod", {
    authorization: "NONE",
    httpMethod: "GET",
    resourceId: awsApiGatewayResourceMyDemoResource.id,
    restApiId: awsApiGatewayRestApiMyDemoApi.id,
  });
new aws.apiGatewayMethodResponse.ApiGatewayMethodResponse(
  this,
  "response_200",
  {
    httpMethod: awsApiGatewayMethodMyDemoMethod.httpMethod,
    resourceId: awsApiGatewayResourceMyDemoResource.id,
    restApiId: awsApiGatewayRestApiMyDemoApi.id,
    statusCode: "200",
  }
);
new aws.apiGatewayIntegration.ApiGatewayIntegration(this, "MyDemoIntegration", {
  httpMethod: awsApiGatewayMethodMyDemoMethod.httpMethod,
  resourceId: awsApiGatewayResourceMyDemoResource.id,
  restApiId: awsApiGatewayRestApiMyDemoApi.id,
  type: "MOCK",
});

Argument Reference

The following arguments are supported:

  • restApiId - (Required) ID of the associated REST API
  • resourceId - (Required) API resource ID
  • httpMethod - (Required) HTTP Method (get, post, put, delete, head, options, any)
  • statusCode - (Required) HTTP status code
  • responseModels - (Optional) Map of the API models used for the response's content type
  • responseParameters - (Optional) Map of response parameters that can be sent to the caller. For example: responseParameters = { "methodResponseHeaderXSomeHeader" =True } would define that the header xSomeHeader can be provided on the response.

Attributes Reference

No additional attributes are exported.

Import

awsApiGatewayMethodResponse can be imported using restApiId/resourceId/httpMethod/statusCode, e.g.,

$ terraform import aws_api_gateway_method_response.example 12345abcde/67890fghij/GET/200