Created
May 3, 2016 18:53
-
-
Save JefStat/9cb343c0ee66366aa060e7db55fbcef6 to your computer and use it in GitHub Desktop.
cannot create a wildcard lambda function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
variable "function_hello" {} | |
resource "aws_api_gateway_rest_api" "Hello" { | |
name = "Hello World API" | |
description = "Terraform integration" | |
} | |
resource "aws_api_gateway_resource" "Hello" { | |
rest_api_id = "${aws_api_gateway_rest_api.Hello.id}" | |
parent_id = "${aws_api_gateway_rest_api.Hello.root_resource_id}" | |
path_part = "hello" | |
} | |
resource "aws_api_gateway_method" "HelloGet" { | |
rest_api_id = "${aws_api_gateway_rest_api.Hello.id}" | |
resource_id = "${aws_api_gateway_resource.Hello.id}" | |
http_method = "GET" | |
authorization = "NONE" | |
#TODO HTTP Request Headers cannot be added at this time | |
} | |
resource "aws_api_gateway_method_response" "200" { | |
rest_api_id = "${aws_api_gateway_rest_api.Hello.id}" | |
resource_id = "${aws_api_gateway_resource.Hello.id}" | |
http_method = "${aws_api_gateway_method.HelloGet.http_method}" | |
#TODO add header "Access-Control-Allow-Origin" | |
status_code = "200" | |
response_models = { | |
"application/json" = "Empty" | |
} | |
} | |
resource "aws_api_gateway_integration_response" "Hello_200" { | |
rest_api_id = "${aws_api_gateway_rest_api.Hello.id}" | |
resource_id = "${aws_api_gateway_resource.Hello.id}" | |
http_method = "${aws_api_gateway_method.HelloGet.http_method}" | |
status_code = "${aws_api_gateway_method_response.200.status_code}" | |
} | |
resource "aws_api_gateway_integration" "HelloGet" { | |
rest_api_id = "${aws_api_gateway_rest_api.Hello.id}" | |
resource_id = "${aws_api_gateway_resource.Hello.id}" | |
http_method = "${aws_api_gateway_method.HelloGet.http_method}" | |
type = "AWS" | |
integration_http_method = "POST" # Must be POST for invoking Lambda function | |
credentials = "${module.iam.api_gateway_role_arn}" | |
# http://docs.aws.amazon.com/apigateway/api-reference/resource/integration/#uri | |
uri = "arn:aws:apigateway:${var.aws_region}:lambda:path/2015-03-31/functions/$${stageVariables.lambdaFunction}/invocations" | |
request_templates = { | |
"application/json" = <<EOF | |
{ | |
"authorization": "$input.params('Authorization')", | |
"body": $input.json('$') | |
} | |
EOF | |
} | |
} | |
resource "aws_api_gateway_deployment" "dev" { | |
depends_on = ["aws_api_gateway_integration.HelloGet"] | |
rest_api_id = "${aws_api_gateway_rest_api.Hello.id}" | |
stage_name = "dev" | |
variables = { | |
"lambdaFunction" = "dev-hello" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment