How to export serverless cloudformation output variables to a file or a task runner?

I’m using serverless.yml to create a couple services in AWS cloudformation, specifically: cognitoUserPool and UserPoolClient.

Both of these creations will return IDs that I will use on my flat html files with the cognito library to connect to amazon cognito, so, since I am serving flat files from S3, I need these values to be coded inside the files.

Now I’m looking for a way of automating this, perhaps leaving a placeholder in the files and then running them through a preprocessor that changes the placeholders with the output values before uploading them to S3, or putting these placeholders in a .js configuration file.

Any ideas how this can be achieved? My first guess would be to export the output variables from serverless deploy and then use these values on a task runner.