Created
January 2, 2019 09:35
-
-
Save sroze/849798342ef89eb3db04f7a6268b7255 to your computer and use it in GitHub Desktop.
Terraform & Serverless: our perfect "functions-as-a-service" CI.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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