No integration defined for method - Choose a stage where your API will be deployed

Amazon Web-ServicesAws LambdaAws Api-Gateway

Amazon Web-Services Problem Overview


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.

Amazon Web-Services Solutions


Solution 1 - Amazon Web-Services

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.

Solution 2 - Amazon Web-Services

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.

Solution 3 - Amazon Web-Services

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.

Solution 4 - Amazon Web-Services

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.

Solution 5 - Amazon Web-Services

Just integrate Lambda function in every method you created.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionHasan AbdullahView Question on Stackoverflow
Solution 1 - Amazon Web-ServicesHasan AbdullahView Answer on Stackoverflow
Solution 2 - Amazon Web-ServicesMarcinView Answer on Stackoverflow
Solution 3 - Amazon Web-ServicesJustin HerreraView Answer on Stackoverflow
Solution 4 - Amazon Web-ServicesJoFoxView Answer on Stackoverflow
Solution 5 - Amazon Web-ServicesFaisal IlyasView Answer on Stackoverflow