Chanonry
Chanonry

Reputation: 443

Terraform AWS API Gateway integration

I trying to replicate the build of an api gateway from an Udemy course in Terraform

On the course the tutor constructs a POST method integration on the console selecting "Lambda Function" as the "Integration Type" NOT selecting "Use Lambda Proxy Integration".

This works fine on the console but when I try to replicate this in Terraform the code:

resource "aws_api_gateway_integration" "build-table-post-integration" {
  rest_api_id = aws_api_gateway_rest_api.testAPI.id
  resource_id = aws_api_gateway_resource.build-table-resource.id
  http_method = aws_api_gateway_method.build-table-method-post.http_method
  type = "LAMBDA"
}

I get the following error:

Error: expected type to be one of [HTTP AWS MOCK HTTP_PROXY AWS_PROXY], got LAMBDA

Fair enough but is the logical conclusion of this that a non-proxy integration of Lambda is not supported by Terraform?

Or am I missing the point?

If it's not supported my options are a proxy integration (not really keen) or use the Serverless Framework which does appear to support it (not hugely keen on that either)?

Upvotes: 0

Views: 2758

Answers (1)

ydaetskcoR
ydaetskcoR

Reputation: 56997

The non proxied Lambda integration requires you to use a type of AWS. This type also allows you to use DynamoDB, SNS, SQS and other AWS services.

The AWS user guide also covers this:

The type of integration with the specified backend. The valid value is

  • http or http_proxy: for integration with an HTTP backend
  • aws_proxy: for integration with AWS Lambda functions;
  • aws: for integration with AWS Lambda functions or other AWS services, such as Amazon DynamoDB, Amazon Simple Notification Service or Amazon Simple Queue Service;
  • mock: for integration with API Gateway without invoking any backend.

For more information about the integration types, see integration:type.

Upvotes: 1

Related Questions