How to automate API Gateway deployment via SAM deploy?
Asked Answered
F

2

4

When I changed AWS::ApiGateway::Method properties by AWS SAM template and deployed it. but I noticed that change was not reflected until I deploy API manually from AWS management console. I think it is because I didn't change the resource of AWS::ApiGateway::Deployment and AWS::ApiGateway::Stage on the template.(The deployment history of AWS::ApiGateway::Stage was not updated.)

How can I reflect the change when I trigger sam deploy?

Figone answered 10/1, 2020 at 4:4 Comment(1)
Related to: #41423939 As suggested in one of the answers there, a possible workaround is to (manually or automatically) run aws apigateway create-deployment after sam deploy.Forster
P
1

No, you have to manually deploy the api from the console :) it's a limitation at the moment.

Petronel answered 10/1, 2020 at 5:5 Comment(6)
Thank you for your quick response and noted.Figone
I have not tried this approach, looks like if you change the logical name of the deployment resource, it will trigger the deployment it seems, have a crack at it if you want, medium.com/@ngchiwang/…Petronel
Thanks. I understand the approach to always recreate the stage resource by putting timestamp. wow. I'll try it.Figone
but I noticed I always need to put timestamp when I modify the setting related to API gateway. have to remember to change...Figone
Ya it's not the best solutionPetronel
@Figone Actually what I did is to create another task after sam-deploy which deploys my API base on a domain name. if it's still relevant I can post an answer.Meant
I
4

If you are still looking for a solution for this, SAM has recently(March 2023) introduced a property under AWS::Serverless::Api called AlwaysDeploy which forces API to be deployed even when there is no changes to API whenever there is sam deploy.

Reference:

  1. AWS::Serverless::Api Documentation
  2. PR to SAM on Github

Note that this will only work if you have your sam cli up to date (>v1.78.0) in your local machine or CI/CD where you will be running sam build.

Identity answered 7/4, 2023 at 18:15 Comment(0)
P
1

No, you have to manually deploy the api from the console :) it's a limitation at the moment.

Petronel answered 10/1, 2020 at 5:5 Comment(6)
Thank you for your quick response and noted.Figone
I have not tried this approach, looks like if you change the logical name of the deployment resource, it will trigger the deployment it seems, have a crack at it if you want, medium.com/@ngchiwang/…Petronel
Thanks. I understand the approach to always recreate the stage resource by putting timestamp. wow. I'll try it.Figone
but I noticed I always need to put timestamp when I modify the setting related to API gateway. have to remember to change...Figone
Ya it's not the best solutionPetronel
@Figone Actually what I did is to create another task after sam-deploy which deploys my API base on a domain name. if it's still relevant I can post an answer.Meant

© 2022 - 2024 — McMap. All rights reserved.