serverless framework
When using serverless framework to deploy aws api gateway, by default the api name will be stage-servicename, like sit-test-service or dev-test-service.
If you want to customise the api name, you can do it through resources configuration.
1 | serverless.yml |
I use a seperate resource file, it looks like this
1 | serverless.yml |
1 | resources.yml |
- When you deploy again after adding custom api name, serverless will call
aws cloudformation update-stackbased on the cloudformation json template. It won’t create a new api, just rename it by updating the existing api. The existing api id won’t change, so the existing cloudfront or custom dns won’t be affected.
CLI
if you want to do this via command line,
- first list APIS and IDs under your account:
1 | aws apigateway get-rest-apis |
- Use the Id to update name of API
1 | aws apigateway update-rest-api --rest-api-id IDOfTheAPIThatNeedsTobeUpdated --patch-operations op=replace,path=/name,value=NewName |