-
Notifications
You must be signed in to change notification settings - Fork 10.2k
Closed
Labels
Description
Hi there,
I´m trying to create a method for a resource which uses a AWS Lambda function as a proxy but is not created like via AWS website.
I haven´t found any way to do this. I know this a new feature in AWS API Gateway and that is the reason why is not supported yet in Terraform.
Terraform Version
Terraform v0.7.10
Affected Resource(s)
- aws_api_gateway_integration
Terraform Configuration Files
##############################
# Variables
variable "access_key" {}
variable "secret_key" {}
variable "account_id" {}
variable "region" {}
variable "rest-api-name" {}
variable "rest-api-description" {}
variable "rest-api-resource-name" {}
variable "aws-lambda-function-name" {}
##############################
# Providers
provider "aws" {
access_key = "${var.access_key}"
secret_key = "${var.secret_key}"
region = "${var.region}"
}
##############################
# Create API
resource "aws_api_gateway_rest_api" "rest-api" {
name = "${var.rest-api-name}"
description = "${var.rest-api-description}"
}
##############################
# Create parent resource
resource "aws_api_gateway_resource" "parent-resource" {
rest_api_id = "${aws_api_gateway_rest_api.rest-api.id}"
parent_id = "${aws_api_gateway_rest_api.rest-api.root_resource_id}"
path_part = "${var.rest-api-resource-name}"
}
##############################
# /*/GET/parent-resource
resource "aws_api_gateway_method" "parent-resource-method-get" {
rest_api_id = "${aws_api_gateway_rest_api.rest-api.id}"
resource_id = "${aws_api_gateway_resource.parent-resource.id}"
http_method = "GET"
authorization = "NONE"
}
resource "aws_api_gateway_integration" "parent-resource-integration-method-get" {
rest_api_id = "${aws_api_gateway_rest_api.rest-api.id}"
resource_id = "${aws_api_gateway_resource.parent-resource.id}"
http_method = "${aws_api_gateway_method.parent-resource-method-get.http_method}"
type = "AWS_PROXY"
uri = "arn:aws:apigateway:${var.region}:lambda:path/2015-03-31/functions/arn:aws:lambda:${var.region}:${var.account_id}:function:${var.aws-lambda-function-name}/invocations"
integration_http_method = "POST"
}
resource "aws_lambda_permission" "allow-api-gateway-parent-resource-get" {
function_name = "${var.aws-lambda-function-name}"
statement_id = "allow-api-gateway-parent-resource-get"
action = "lambda:InvokeFunction"
principal = "apigateway.amazonaws.com"
source_arn = "arn:aws:execute-api:${var.region}:${var.account_id}:${aws_api_gateway_rest_api.rest-api.id}/*/${aws_api_gateway_method.parent-resource-method-get.http_method}${aws_api_gateway_resource.parent-resource.path}"
}Expected Behavior
The same than create this method via AWS website where the Method Response HTTP status is set as Proxy, like:
Actual Behavior
The Method Response HTTP status is not set:
Steps to Reproduce
terraform apply -var 'access_key=XXXX' -var 'secret_key=XXXX' -var 'account_id=XXXX' -var 'region=XXXX' -var 'rest-api-name=XXXX' -var 'rest-api-description=XXXX' -var 'rest-api-resource-name=XXXX' -var 'aws-lambda-function-name=XXXX'
Reactions are currently unavailable

