'How to deploy API into API Gateway stage using AWS CLI?
I am trying to deploy lambda function into API Gateway using AWS CLI. I am using aws apigateway put-integration
and aws apigateway put-integration-response
to update the integration part. I am able to do till this part. Next step is I want to deploy this API into stage. I am using aws apigateway create-deployment --rest-api-id 1234123412 --stage-name dev
. But when I test API after I deploy, I am getting error message Internal server error
. API works fine when I go to API Gateway console and on Integration Request and click on edit button of Lambda Function and don't modify function name, then go back and deploy manually. But I am not able get it work using AWS CLI. Is there any work around for this problem?
Solution 1:[1]
I believe you need to do an updateStage api call and patch the stage with the new deploymentId. https://docs.aws.amazon.com/cli/latest/reference/apigateway/update-stage.html
patch operation:
op: replace
path: /deploymentId
value: <id from create-deployment>.
https://docs.aws.amazon.com/apigateway/latest/developerguide/set-up-deployments.html
Solution 2:[2]
Use create-deployment
.
aws apigateway create-deployment --region $REGION --rest-api-id $REST_API_ID --stage-name $STAGE_NAME
This will create deployment and deploy it.
You can find $REST_API_ID here : https://ap-northeast-2.console.aws.amazon.com/apigateway/main/apis
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Max Schenkelberg |
Solution 2 | MyounghoonKim |