Skip to content

Commit

Permalink
Add optional AWS SAM CLI profile option to be used to interact with A…
Browse files Browse the repository at this point in the history
…WS API.
  • Loading branch information
danielesalvatore committed May 29, 2019
1 parent d362bab commit c5353f5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
3 changes: 3 additions & 0 deletions dev-portal/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ module.exports = {

// Set this to overwrite-content if you want to reset your custom content back to the defaults. Defaults to ``
// staticAssetRebuildMode: `overwrite-content` // ONLY SET

// AWS SAM CLI profile option: optional specific profile from your AWS credential file. Not used by default
//awsSamCliProfile: "my-profile"
}
```
4. Run `npm run release`. This will build the static assets, deploy them, and generate the `dev-portal/public/config.js` file needed for local development. Take note of the bucket names you use
Expand Down
18 changes: 11 additions & 7 deletions dev-portal/scripts/deploy-stack.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,19 @@ const customersTableName = deployerConfig.customersTableName || 'DevPortalCustom
const cognitoDomainName = deployerConfig.cognitoDomainName || ''
const staticAssetRebuildMode = deployerConfig.staticAssetRebuildMode || ''

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

function main() {
Promise.resolve()
.then(() => execute(`sam package --template-file ${samTemplate} --output-template-file ${packageConfig} --s3-bucket ${buildAssetsBucket}`, true))
.then(() => execute(`sam deploy --template-file ${packageConfig} --stack-name ${stackName} --capabilities CAPABILITY_NAMED_IAM --parameter-overrides StaticAssetRebuildToken="${Date.now()}" StaticAssetRebuildMode="${staticAssetRebuildMode}" DevPortalSiteS3BucketName="${siteAssetsBucket}" ArtifactsS3BucketName="${apiAssetsBucket}" DevPortalCustomersTableName="${customersTableName}" CognitoDomainNameOrPrefix="${cognitoDomainName}" --s3-bucket ${buildAssetsBucket}`, true))
.then(() => writeConfig(true))
.then(() => console.log('\n' + 'Process Complete! Run `npm run start` to launch run the dev portal locally.\n'.green()))
.catch(err => {
console.log(("" + err).red())
})
.then(() => execute(`sam package --template-file ${samTemplate} --output-template-file ${packageConfig} --s3-bucket ${buildAssetsBucket} ${profileOption}`, true))
.then(() => execute(`sam deploy --template-file ${packageConfig} --stack-name ${stackName} --capabilities CAPABILITY_NAMED_IAM --parameter-overrides StaticAssetRebuildToken="${Date.now()}" StaticAssetRebuildMode="${staticAssetRebuildMode}" DevPortalSiteS3BucketName="${siteAssetsBucket}" ArtifactsS3BucketName="${apiAssetsBucket}" DevPortalCustomersTableName="${customersTableName}" CognitoDomainNameOrPrefix="${cognitoDomainName}" --s3-bucket ${buildAssetsBucket} ${profileOption}`, true))
.then(() => writeConfig(true))
.then(() => console.log('\n' + 'Process Complete! Run `npm run start` to launch run the dev portal locally.\n'.green()))
.catch(err => {
console.log(("" + err).red())
})
}

if (samTemplate && packageConfig && stackName && buildAssetsBucket && siteAssetsBucket && apiAssetsBucket && customersTableName) {
Expand Down

0 comments on commit c5353f5

Please sign in to comment.