From f1806d4bbd9fa83deee302fe509dabc19e5a90b8 Mon Sep 17 00:00:00 2001 From: Ashton Eby Date: Wed, 22 May 2019 16:02:15 -0700 Subject: [PATCH 1/4] Update description of overwrite-content Should be overwrite-content, not overwrite_content: https://github.com/awslabs/aws-api-gateway-developer-portal/issues/263#issuecomment-494753756 --- cloudformation/template.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cloudformation/template.yaml b/cloudformation/template.yaml index b925350a9..551cafc15 100644 --- a/cloudformation/template.yaml +++ b/cloudformation/template.yaml @@ -72,7 +72,7 @@ Parameters: StaticAssetRebuildMode: Type: String - Description: By default, a static asset rebuild doesn't overwrite custom-content. Provide the value `overwrite_content` to replace the custom-content with your local version. Don't do this unless you know what you're doing -- all custom changes in your s3 bucket will be lost. + Description: By default, a static asset rebuild doesn't overwrite custom-content. Provide the value `overwrite-content` to replace the custom-content with your local version. Don't do this unless you know what you're doing -- all custom changes in your s3 bucket will be lost. Default: '' MarketplaceSubscriptionTopicProductCode: From c5353f5e958f2137244d4c1e3b3ffd1d17fafec9 Mon Sep 17 00:00:00 2001 From: Daniele Salvatore Date: Wed, 29 May 2019 12:00:46 +0200 Subject: [PATCH 2/4] Add optional AWS SAM CLI profile option to be used to interact with AWS API. --- dev-portal/README.md | 3 +++ dev-portal/scripts/deploy-stack.js | 18 +++++++++++------- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/dev-portal/README.md b/dev-portal/README.md index bf0191eb8..bb2b58b2f 100644 --- a/dev-portal/README.md +++ b/dev-portal/README.md @@ -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 diff --git a/dev-portal/scripts/deploy-stack.js b/dev-portal/scripts/deploy-stack.js index 20155c4e3..90220df84 100644 --- a/dev-portal/scripts/deploy-stack.js +++ b/dev-portal/scripts/deploy-stack.js @@ -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) { From 44b4dc7e44ae163b07111a5567bad61a24398cb4 Mon Sep 17 00:00:00 2001 From: Daniele Salvatore Date: Wed, 29 May 2019 12:41:08 +0200 Subject: [PATCH 3/4] Optinally include AWS SAM CLI profile option also in the write-config.js --- dev-portal/scripts/write-config.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/dev-portal/scripts/write-config.js b/dev-portal/scripts/write-config.js index fdc5f90c5..30f2db858 100644 --- a/dev-portal/scripts/write-config.js +++ b/dev-portal/scripts/write-config.js @@ -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 \ No newline at end of file From 5c1b9784e52ee44d54f3205ebf8e18ebbd2df611 Mon Sep 17 00:00:00 2001 From: Alan Tan Date: Tue, 4 Jun 2019 12:33:53 -0700 Subject: [PATCH 4/4] Fixing deadlink --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4f452ea78..f1a544115 100644 --- a/README.md +++ b/README.md @@ -97,7 +97,7 @@ If you chose `UseRoute53Nameservers=false`, instead point your nameservers at th See [this page on customization](https://github.com/awslabs/aws-api-gateway-developer-portal/wiki/Customization) ## Updating to a new version -The Developer Portal follows the semantic versioning scheme (major.minor.patch). Changes to the minor or patch version are backwards compatible so you should feel safe to get the latest version. For changes to major versions, please see [this page on updating](https://github.com/awslabs/aws-api-gateway-developer-portal/wiki/Upgrading/_edit). +The Developer Portal follows the semantic versioning scheme (major.minor.patch). Changes to the minor or patch version are backwards compatible so you should feel safe to get the latest version. For changes to major versions, please see [this page on updating](https://github.com/awslabs/aws-api-gateway-developer-portal/wiki/Updating/). ### To update a SAM deployment: 1. Get the latest version from GitHub (Clone/Pull/Download).