Skip to content

Commit

Permalink
Optinally include AWS SAM CLI profile option also in the write-config.js
Browse files Browse the repository at this point in the history
  • Loading branch information
danielesalvatore committed May 29, 2019
1 parent c5353f5 commit 44b4dc7
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions dev-portal/scripts/write-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,20 @@ const { execute, r } = require('./utils.js')
const buildConfig = require('../deployer.config.js')
const stackName = buildConfig.stackName

// AWS SAM CLI configuration
const awsSamCliProfile = buildConfig.awsSamCliProfile;
const profileOption = awsSamCliProfile ? `--profile ${awsSamCliProfile}` : ''

function writeConfig (swallowOutput) {
return execute(`aws cloudformation describe-stacks --stack-name ${stackName}`, swallowOutput)
.then((result) => {
return execute(`aws cloudformation describe-stacks --stack-name ${stackName} ${profileOption}`, swallowOutput)
.then((result) => {
const websiteUrl = (JSON.parse(result.stdout).Stacks[0].Outputs)
.find(output => output.OutputKey === "WebsiteURL").OutputValue
.find(output => output.OutputKey === "WebsiteURL").OutputValue

return fetch(`${websiteUrl}/config.js`).then(response => response.text())
})
.then(output => writeFile(r(`../public/config.js`), output))
.catch(console.error)
return fetch(`${websiteUrl}/config.js`).then(response => response.text())
})
.then(output => writeFile(r(`../public/config.js`), output))
.catch(console.error)
}

module.exports = writeConfig

0 comments on commit 44b4dc7

Please sign in to comment.