Output sls info to JSON

Is there a way to get the output of sls info --verbose in a more JavaScript friendly way, for example in JSON?

Related topic: Testing the endpoints after deployment

1 Like

You can output the sls info with this plugin https://github.com/sbstjn/serverless-stack-output

Here is an example service using it https://github.com/sbstjn/serverless-analytics/blob/master/serverless.yml#L6 where you specify the output file https://github.com/sbstjn/serverless-analytics/blob/master/serverless.yml#L31-L32

Then you can grab the live API endpoints, resource info, etc programmatically from that file.

1 Like

Thanks for the link @DavidWells, this plugin is a good start, but unfortunately it does not output the custom domain set up by the serverless-domain-manager plugin: https://serverless.com/blog/serverless-api-gateway-domain/


Do you have the customDomain set in serverless.yml?

    domainName: <registered_domain_name>

You might need to setup a custom function to construct the correct url values. https://github.com/sbstjn/serverless-stack-output#configuration see the handler.js

I feel the pain here… It should be easier.

Yes, I have the custom domain set up and working correctly, it appears both in sls info and sls info --verbose.

I’ve just created a Github issue to track the response from the plugin author: https://github.com/sbstjn/serverless-stack-output/issues/6

I created an updated version of the plugin to fit my needs.

Outputs manifest data from all deployed stages including custom domains

1 Like

can you help me on exporting the stack output to json file
I am stuck from 2 days

can you tell me how did you export the stack output to the json files?
please help me

Take a look at serverless-stack-output

Install the serverless-stack-output package with:
$ npm i -D serverless-stack-output

Include the following in your serverless.yml:

  - serverless-stack-output

    file: ${self:provider.stage}-stack-output.json

This will create a {stage}-stack-output.json file with your stack outputs whenever you deploy.

Hope it helps.

1 Like

thank you @bfieber for your help.

1 Like