The serverless framework lacks native support for outputting the endpoint url for a deployment:
serverless info --stage prod --region us-east-2
Outputs
DOTENV: Loading environment variables from .env, .env.prod:
- SOME_VAR
service: my-service
stage: prod
region: us-east-2
stack: my-service-prod
endpoint: ANY - https://some-endoint.execute-api.some-region.amazonaws.com
functions:
api: my-service-prod-api
The point of this script is to extract https://some-endoint.execute-api.some-region.amazonaws.com
from this output.
Here's how it works:
npm install --save-dev tsx js-yaml
Copy the script (parseEndpoint.js
) locally and run it with a |
suc as:
export ENDPOINT_URL=$(serverless info --stage prod --region us-east-2 | npx tsx parseEndpoint.js
echo $ENDPOINT_URL
There you go. A simple way to automate extracting this endpoint.