64

I'm working with AWS API Gateway and AWS Lambda. Often I face this type of error message when attempt to deploy API. The error message says to select a deployment stage. But I still selecting and trying to deploy! but same error occur!

Screenshot of pop up error message

In this API I have multiple resources with multiple methods. Previously I succeed to deploy this same API with the same way. But now I can't deploy it.

Please anyone help me to fix it. For addition: I don't use AWS CLI tool, just use AWS web dashboard.

Hasan Abdullah
  • 2,498
  • 1
  • 19
  • 34

7 Answers7

93

I talked with customer service center of AWS. The problem was:

In this API there was an unintegrated method. Suppose there are a resource image and I create a POST method for this resource. But I forgot to integrate it to any AWS Lambda Function or HTTP. So the API cannot be deployed.

If the method is unnecessary then delete the method. OR you can integrate it as Mock endpoint. You can change this endpoint anytime.

Note: For this unintegration problem AWS gives this type of wrong error message. They should update their message to save developer's time.

Hasan Abdullah
  • 2,498
  • 1
  • 19
  • 34
  • 1
    thank you sir. To do so, I have to wait at least 2 days (as SO rules). :-) – Hasan Abdullah Sep 07 '17 at 09:43
  • 2
    "No integration defined for method" seems cryptic at first, but I don't understand why you consider it to be wrong if, as described, it means you created a method without defining an integration for it. – Michael - sqlbot Sep 07 '17 at 14:02
  • Sir, by mistake I added a method to my API a few days ago. When I add another resource and methods then I need to deploy. So the error occurred. If AWS gave me an error like "Unintegrated method found" it would be better to find the issue. – Hasan Abdullah Sep 07 '17 at 14:07
  • 7
    > why you consider it to be wrong I consider it incomplete. The message should be something like "Resource POST /image defined without endpoint handler", somehow pointing out WHICH method is referred to. – fiddur Feb 20 '19 at 15:30
  • Yes, if you try to create a deployment without setting up an integration for each method, you will get this error. Setting up an integration for each method created allowed for deployment/stage creation – mgrotheer May 13 '20 at 14:08
  • 4
    Is there any way to find out which exact method is failing? I have an API Gateway with a 100 methods and I'm unable to find out which ones are giving issues. – Vishwas M.R Mar 12 '21 at 10:20
15

I was getting same error but when creating API using CloudFormation.

It turned out that in my AWS::ApiGateway::Deployment resource, I needed to include DependsOn attribute that "depends" on all my API methods.

For example, when building API with two AWS::ApiGateway::Method resources, AWS::ApiGateway::Deployment needs to depend on both these methods:

  MyFirstApiMethod:
    Type: AWS::ApiGateway::Method
    Properties: 
       <your properties>

  MySecondApiMethod:
    Type: AWS::ApiGateway::Method
    Properties: 
       <your properties>

  MyDeployment:
    Type: AWS::ApiGateway::Deployment
    DependsOn: [MyFirstApiMethod, MySecondApiMethod] # <-- REQUIRED 
    Properties: 
      RestApiId: !Ref MyRestApi

Without the DependOn attribute on all the API methods, CloudFormation may be creating them after the deployment resource, resulting in No integration defined for method error.

Marcin
  • 215,873
  • 14
  • 235
  • 294
2

If you have another resource which is not completed to configuration it will read as well. In short, if you haven't given them a lambda function, the api itself is not allowed to be deployed until you finish the rest.

Justin Herrera
  • 526
  • 4
  • 11
2

I encountered the same error with deploying via Terraform. The reason was I defined an IAM role for my API and I didn't include the role resource to triggers when deploying the API. Just make sure all resources that are defined before deploying are included in triggers.

JoFox
  • 21
  • 1
0

Just integrate Lambda function in every method you created.

0

Make sure every resource and method is configured properly. Let's say your api-gateway is hierarchy is like:

/
   R1
    R2 
     M1 
     M2
    R3
     M3

so every resource(R1,R2,R3) and every method(M1,M2,M3) should be configured properly. enter image description here

0

I deployed using CDK with --no-rollback (this should work for any cloudformation though)

In my case, the API was created and I could inspect it in the AWS Console, and only the "AWS::ApiGateway::Deployment" failed to create. It turns out I had a bad value for service attribute (I was using StepFunctions, which was not working)

THEN I see that I have a dangling resouce/method that is broken - so my deployment was failing due to garbage in AWS, not my CDK/template.

Max Reeder
  • 159
  • 2
  • 6