I would like to run tests after sls deploy, so I can verify that the deployment completed successfully, and all components on my backend are working perfectly. To do so, I want to call the endpoints deployed to https://{restApiId}.execute-api.{region}.amazonaws.com/{stage}/{path}.
What is the easiest way to pass those parameters, or at least the base URL to a post deployment npm script?
For example, is there a way to export them to a file during deployment? I am considering writing a plugin to do that, but before that I would like to know if there is an easier and recommended way.
I was considering the same problem yesterday, as far as I can tell nothing currently exists to output the stack outputs to a file. In bash I managed to come up with this:
serverless info --verbose | grep ServiceEndpoint | sed s/ServiceEndpoint\:\ //g | awk '{print $1"/your-path"}' | xargs -n1 curl
Not the prettiest, and I’m trying to work a way to make it into a plugin at the moment or at least aliasable in bash!
Thank you @redroot, sls info seems to be the good way to start. However, if you have a custom domain and use the serverless-domain-manager plugin, the name of the domain is not printed in the info output. But I guess that is something I should report to the plugin author.
I highly appreciate your efforts embedding this to a plugin.
Thanks to @jconstance-amplify the 1.1.16 version of the serverless-domain-manager package prints the name of the custom domain in the sls info --verbose output.