Skip to content

Instantly share code, notes, and snippets.

@sroze
Created January 2, 2019 09:35
Show Gist options
  • Save sroze/849798342ef89eb3db04f7a6268b7255 to your computer and use it in GitHub Desktop.
Save sroze/849798342ef89eb3db04f7a6268b7255 to your computer and use it in GitHub Desktop.
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