Terraform: Enumeration value for HttpMethod must be non-empty

Created on 2 Dec 2016  ยท  8Comments  ยท  Source: hashicorp/terraform

Terraform Version

0.7.13

Affected Resource(s)

  • aws_api_gateway_integration

Terraform Configuration Files

(See https://github.com/hashicorp/terraform/issues/10494#issuecomment-264477291 for full manifest).

This manifest is taken almost word-by-word from https://www.terraform.io/docs/providers/aws/r/api_gateway_integration.html#uri and using type=AWS gives the same error.

resource "aws_api_gateway_integration" "slack-commands" {
  rest_api_id                 = "${aws_api_gateway_rest_api.slack-commands.id}"
  resource_id                 = "${aws_api_gateway_resource.slack-commands.id}"
  http_method                 = "${aws_api_gateway_method.slack-commands.http_method}"

  type                        = "AWS_PROXY"
  uri                         = "arn:aws:apigateway:${data.aws_region.current.name}:lambda:path/2015-03-31/functions/${aws_lambda_function.slack-slash-commands.arn}"
}

Expected Behavior

Create the resource, with a 'link' to the Lambda function.

Actual Behavior

Errors with:

* aws_api_gateway_integration.slack-commands: Error creating API Gateway Integration: BadRequestException: Enumeration value for HttpMethod must be non-empty

The resource TF wants to create:

module.core-main.aws_api_gateway_integration.slack-commands: Creating...
  http_method:          "" => "ANY"
  passthrough_behavior: "" => "<computed>"
  resource_id:          "" => "auxe1h"
  rest_api_id:          "" => "fzl261v6ra"
  type:                 "" => "AWS_PROXY"
  uri:                  "" => "arn:aws:apigateway:eu-west-1:lambda:path/2015-03-31/functions/arn:aws:lambda:eu-west-1:<my_account_id>:function:slack-slash-commands"

Steps to Reproduce

  1. terraform apply
bug provideaws

Most helpful comment

@FransUrbo Hi!
Could you try setting integration_http_method and tell us how it goes please?

I'm thinking that it may be required for AWS_PROXY too. Thanks!

All 8 comments

@FransUrbo Hi!
Could you try setting integration_http_method and tell us how it goes please?

I'm thinking that it may be required for AWS_PROXY too. Thanks!

That worked.

@FransUrbo Awesome it worked nicely. Did you check it with type set as AWS or AWS_PROXY please?

Will update the documentation accordingly. Thanks!

With AWS_PROXY.

This is the current, working resource:

resource "aws_api_gateway_integration" "slack-commands" {
  rest_api_id                 = "${aws_api_gateway_rest_api.slack-commands.id}"
  resource_id                 = "${aws_api_gateway_resource.slack-commands.id}"
  http_method                 = "${aws_api_gateway_method.slack-commands.http_method}"

  type                        = "AWS_PROXY"
  uri                         = "arn:aws:apigateway:${data.aws_region.current.name}:lambda:path/2015-03-31/functions/${aws_lambda_function.slack-slash-commands.arn}/invocations"
  integration_http_method     = "POST"
}

For some reason, that last part (/invocations) is important.. That and the uri entry wasn't well defined/documented either (as in 'working example'). Don't know where the date come from (I got the uri value from another example somewhere I think).

Also, now that I look at it again, I'm not sure if/why I need both http_method _and_ integration_http_method at the same time, but now I'm kind'a afraid to mess with it :)

@FransUrbo The date (2015-03-31) is the Lambda API version you want to use, so it is fine as is.

Regarding http_method & integration_http_method, here is the deal:

  • http_method is the method to use when calling the API Gateway endpoint
  • integration_http_method is the method used by API Gateway to call the backend, i.e. Lambda in this case (it should always be POST for Lambda)

We'll update the documentation accordingly, thanks!

@FransUrbo Improved the documentation in #10772 , tell me if it's clearer for you or not :)

Thanks!

Closed via #10772 - thanks @Ninir - @FransUrbo please let us know if this isn't the case

I'm going to lock this issue because it has been closed for _30 days_ โณ. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

larstobi picture larstobi  ยท  3Comments

franklinwise picture franklinwise  ยท  3Comments

rjinski picture rjinski  ยท  3Comments

rjinski picture rjinski  ยท  3Comments

carl-youngblood picture carl-youngblood  ยท  3Comments