Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Terraform & Serverless: our perfect "functions-as-a-service" CI.
const execSync = require('child_process').execSync;
module.exports = () => {
const configuration = {};
const terraformFolder = process.env.SERVERLESS_ENVIRONMENT == 'production' ? 'production' : 'staging';
const cwd = __dirname + '/' + terraformFolder;
const output = execSync('terraform output -json', {
cwd,
encoding: 'utf-8',
});
const parsedTerraform = JSON.parse(output);
Object.keys(parsedTerraform).forEach(key => {
configuration[key] = parsedTerraform[key].value;
});
return configuration;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment