Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enumeration value for HttpMethod must be non-empty (Service: AmazonApiGateway; Status Code: 400; Error Code: BadRequestException #6404

Closed
joyofdata opened this issue Feb 22, 2020 · 1 comment
Labels
needs-triage This issue or PR still needs to be triaged.

Comments

@joyofdata
Copy link

joyofdata commented Feb 22, 2020

I'm deploying a REST API on API Gateway accessing a web service on Fargate via a VPC Link and an NLB. And this actually works.

[API Gateway] <-> [VPC Link] <-> { [NLB] <-> [Fargate] }

# { ... private subnet ... }

The only missing piece is deploying the method:resource ANY:test/. That part is described in below code snippet:

vpc_link = api.VpcLink(
    self,
    "VpcLinkRaffael",
    targets=[fg.load_balancer],
)


rest_api = api.RestApi(
    self,
    "RestApiRaffael",
)

test = rest_api.root.add_resource("test")
test.add_method(
    "ANY",
    # the following integration setting is causing the problem. for the previous deployment
    # I left this specific parameter out and it deployed fine. so my deployment at this point
    # is a rest API with a resource test and method ANY.
    api.Integration(
        type=api.IntegrationType.HTTP_PROXY,
        options=api.IntegrationOptions(
            vpc_link=vpc_link
        ),
        uri="http://example.org/",
    ),
)

This causes the error:

 0/5 | 4:57:57 PM | UPDATE_IN_PROGRESS   | AWS::ApiGateway::Method                   | RestApiRaffael/Default/test/ANY (RestApiRaffaeltestANY0602E478)
 1/5 | 4:57:58 PM | UPDATE_FAILED        | AWS::ApiGateway::Method                   | RestApiRaffael/Default/test/ANY (RestApiRaffaeltestANY0602E478) Enumeration value for HttpMethod must be non-empty (Service: AmazonApiGateway; Status Code: 400; Error Code: BadRequestException; Request ID: 0a6b9f7d-4501-41e0-8e4a-cbebd0fb1333)
        new Method (/tmp/jsii-kernel-g0iRHB/node_modules/@aws-cdk/aws-apigateway/lib/method.js:45:26)
        \_ Resource.addMethod (/tmp/jsii-kernel-g0iRHB/node_modules/@aws-cdk/aws-apigateway/lib/resource.js:17:16)
        \_ /home/raffael/gitrepos/test-api-elb-fargate/env/lib/python3.8/site-packages/jsii/_embedded/jsii/jsii-runtime.js:7665:51
        \_ Kernel._wrapSandboxCode (/home/raffael/gitrepos/test-api-elb-fargate/env/lib/python3.8/site-packages/jsii/_embedded/jsii/jsii-runtime.js:8298:20)
        \_ /home/raffael/gitrepos/test-api-elb-fargate/env/lib/python3.8/site-packages/jsii/_embedded/jsii/jsii-runtime.js:7665:25
        \_ Kernel._ensureSync (/home/raffael/gitrepos/test-api-elb-fargate/env/lib/python3.8/site-packages/jsii/_embedded/jsii/jsii-runtime.js:8274:20)
        \_ Kernel.invoke (/home/raffael/gitrepos/test-api-elb-fargate/env/lib/python3.8/site-packages/jsii/_embedded/jsii/jsii-runtime.js:7664:26)
        \_ KernelHost.processRequest (/home/raffael/gitrepos/test-api-elb-fargate/env/lib/python3.8/site-packages/jsii/_embedded/jsii/jsii-runtime.js:7372:28)
        \_ KernelHost.run (/home/raffael/gitrepos/test-api-elb-fargate/env/lib/python3.8/site-packages/jsii/_embedded/jsii/jsii-runtime.js:7312:14)
        \_ Immediate._onImmediate (/home/raffael/gitrepos/test-api-elb-fargate/env/lib/python3.8/site-packages/jsii/_embedded/jsii/jsii-runtime.js:7315:37)
        \_ processImmediate (internal/timers.js:456:21)

Before this erroneous deployment I just deployed the RESt API with ANY test/. No problem. So, I can actually go on API Gateway and manually configure:

https://imgur.com/mpSBm8B

  • Integration Type: VPC Link
  • Use Proxy Integration: Yes
  • Method: ANY
  • VPC Link: added
  • Endpoint URL: http://example.org/

That works. Now what I would like to do is reproduce this with CDK and I think that should be done by adding:

api.Integration(
    type=api.IntegrationType.HTTP_PROXY,
    options=api.IntegrationOptions(
        vpc_link=vpc_link
    ),
    uri="http://example.org/",
),

That's what I am doing above but causes the error. Any ideas what I'm doing wrong?

@joyofdata joyofdata added the needs-triage This issue or PR still needs to be triaged. label Feb 22, 2020
@joyofdata
Copy link
Author

joyofdata commented Feb 22, 2020

test = rest_api.root.add_resource("test")
test.add_method(
    "ANY",
    api.Integration(
        type=api.IntegrationType.HTTP_PROXY,
        integration_http_method="ANY", #A
        options=api.IntegrationOptions(
            vpc_link=vpc_link,
            connection_type=api.ConnectionType.VPC_LINK, #B
        ),
        uri="http://example.org/",
    ),
)

A and B were missing. That seems to solve it.

mergify bot pushed a commit that referenced this issue Dec 11, 2023
…28299)

As written in #6404, a VPC link integration fails to deploy unless we set `integrationHttpMethod` prop explicitly.

In this PR we fix the sample code accordingly.
 
----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
mergify bot pushed a commit that referenced this issue Dec 15, 2023
…ation types (#28316)

`integrationHttpMethod` must be specified for non-MOCK integration types.
This PR adds validation to prevent [build-time errors](#6404).

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-triage This issue or PR still needs to be triaged.
Projects
None yet
Development

No branches or pull requests

1 participant