Skip to content

Commit

Permalink
Merge pull request #252 from awslabs/staging
Browse files Browse the repository at this point in the history
v3.0.0
  • Loading branch information
echo-bravo-yahoo authored Mar 27, 2019
2 parents 1c5bc0a + c450eed commit 7d09ef1
Show file tree
Hide file tree
Showing 193 changed files with 31,114 additions and 8,250 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
dev-portal/node_modules/*
!dev-portal/node_modules/swagger-ui/
dev-portal/node_modules/swagger-ui/*
!dev-portal/node_modules/swagger-ui/package.json
!dev-portal/node_modules/swagger-ui/dist/

# built artifacts
Expand All @@ -27,7 +28,8 @@ dev-portal/node_modules/swagger-ui/*
# misc
npm-debug.log
.DS_Store
packaged.yaml
packaged*.yaml
cognito.js
.idea
.vscode
*.iml
7 changes: 6 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
language: node_js
node_js:
- "node"
# we can't use latest because 11.11 breaks jest's env variable mock
- "11.10.1"

cache: npm

before_install:
# install clis in parallel
# - pip install --user awscli
# pip install --user aws-sam-cli
# https://github.com/travis-ci/travis-ci/issues/3139
- cd dev-portal
# install everything in dev portal
- npm install
Expand Down
164 changes: 25 additions & 139 deletions README.md

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions README_SAR.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ The Serverless Developer Portal is an application that you use for developer eng
#### To deploy
1. Enter a name for ArtifactsS3BucketName: this will create an Amazon S3 bucket with that name for storing the catalog metadata.
1. Enter a name for DevPortalSiteS3BucketName: this will create an Amazon S3 bucket with that name for the web application code.
1. Enter a unique prefix for CognitoDomainNameOrPrefix; this will be used in the sign in page's URL.
1. You should leave all the other settings as-is unless you need to change them. For example, you can optionally enter a custom domain name in the CustomDomainName field.
1. Acknowledge that the app uses custom roles by checking the box "I acknowledge that this app creates custom IAM roles."
1. Choose Deploy.
Expand All @@ -16,14 +17,14 @@ The Serverless Developer Portal is an application that you use for developer eng
1. Open the Outputs section. The URL for the developer portal is specified in the WebSiteURL property.

#### 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.
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).

To update:
1. When deploying follow the same steps as previous and use the same values for the parameters. The only difference is passing in a new value for "-StaticAssetRebuildToken". You can use any string for this as long as it is different than previously used (default value is "defaultRebuildToken").
1. When deploying follow the same steps as previous and use the same values for the parameters. The only difference is passing in a new value for the stack parameter StaticAssetRebuildToken. You can use any string for this as long as it is different than the previously used string.

#### Next steps
1. Publish an API on it for your customer to look at. Learn how to do that [here](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-developer-portal.html#apigateway-developer-portal-publish).
1. Customize, own, and brand the portal. Learn how to do that [here](https://github.com/awslabs/aws-api-gateway-developer-portal#customization).
1. Customize, own, and brand the portal. Learn how to do that [here](https://github.com/awslabs/aws-api-gateway-developer-portal/wiki/Customization).
1. Setup a custom domain on it your customers recognize your brand and the associated APIs. Learn how to do that [here](https://github.com/awslabs/aws-api-gateway-developer-portal#before-going-to-production).

To learn more about the API Gateway Serverless Developer Portal, read the [documentation](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-developer-portal.html) or visit the [GitHub repository](https://github.com/awslabs/aws-api-gateway-developer-portal). For more information about Amazon API Gateway, visit the API Gateway [product page](https://aws.amazon.com/api-gateway/).
112 changes: 112 additions & 0 deletions __tests__/cfn-integration-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
const fs = require('fs')
const rp = require('request-promise')

describe('template.yaml', () => {
// NOTE: These tests all assume that the CFN template has already been packaged *PER REGION*!
const cfnTimeout = 75,
// run the test with a timeout of slightly longer than double the CFN stack timeout
testTimeout = 1000*60*cfnTimeout*2 + 1
const _console = console.log

async function commonTest(region, stackMiddlefix) {
let unixTimestamp = Math.floor(new Date() / 1000),
stackName = `cfn-integ-${ stackMiddlefix }-${ unixTimestamp }`,
s3Params = {
// CFN, when reading the template from S3, requires the S3 bucket to be in the same region as the CFN stack...
Bucket: `dev-portal-integ-${ region }`,
Body: fs.readFileSync(`./cloudformation/packaged-${region}.yaml`),
Key: stackName
},
cfnParams = {
StackName: stackName,
Capabilities: ['CAPABILITY_NAMED_IAM', 'CAPABILITY_AUTO_EXPAND'],
Parameters: [
{
ParameterKey: 'DevPortalSiteS3BucketName',
ParameterValue: `integ-${ stackMiddlefix }-${ unixTimestamp }-dev-portal-test`
},
{
ParameterKey: 'ArtifactsS3BucketName',
ParameterValue: `integ-${ stackMiddlefix }-${ unixTimestamp }-artifact-bucket`
},
{
ParameterKey: 'DevPortalCustomersTableName',
ParameterValue: `Customers${ unixTimestamp }`
},
{
ParameterKey: 'CognitoDomainNameOrPrefix',
ParameterValue: `integ-${ stackMiddlefix }-${ unixTimestamp }`
}
],
// RoleARN: 'STRING_VALUE',
TimeoutInMinutes: cfnTimeout
}

console.log('commonTest', region)

const AWS = require('aws-sdk')
AWS.config.update({ region: region })

// pin versions of SDKs
const cfn = new AWS.CloudFormation({ region: region }),
s3 = new AWS.S3({ region: region }),
logger = function (input) {
_console(`${region}:${stackName}:${input}`)
}

// Upload the packaged template to S3, then use the resulting URL in the CFN createStack call
// This is necessary because the file is too large to deliver in-line to CFN
cfnParams.TemplateURL =(await s3.upload(s3Params).promise()).Location

logger('createStack call starting.')
await cfn.createStack(cfnParams).promise()
logger('createStack call succeeded.')

logger('stackExists waiter starting.')
await cfn.waitFor('stackExists', { StackName: stackName }).promise()
logger('stackExists waiter succeeded.')

logger('stackCreateComplete waiter starting.')
let devPortalUrl =
(await cfn.waitFor('stackCreateComplete', { StackName: stackName }).promise()).Stacks[0].Outputs
.find((output) => output.OutputKey === 'WebsiteURL').OutputValue
logger('stackCreateComplete waiter succeeded.')

logger(`verifying that stack is available at ${devPortalUrl} .`)
let staticIndex = await rp(devPortalUrl)

expect(staticIndex.includes('<title>Developer Portal</title>')).toBeTruthy()
logger(`verified that stack is available at ${devPortalUrl} .`)

// add RoleArn: ... later
logger('deleteStack call starting.')
await cfn.deleteStack({ StackName: stackName }).promise()
logger('deleteStack call succeeded.')

logger('stackDeleteComplete waiter starting.')
await cfn.waitFor('stackDeleteComplete', { StackName: stackName }).promise()
logger('stackDeleteComplete waiter succeeded.')

// pass the test; we successfully stood the stack up and tore it down
expect(true).toBe(true)

return true
}

test.concurrent('should stand up and tear down the stack in IAD', async () => {
return commonTest('us-east-1', 'us-east-1')
}, testTimeout)

test.concurrent('should stand up and tear down the stack in a non-IAD region', async () => {
return commonTest('us-west-2', 'us-west-2')
}, testTimeout)

// Implement these! Hardest part will be having test ACM certs in the account
// test('should stand up and tear down a custom domain stack in IAD', async () => {
// return commonTest('us-east-1', 'domain-us-east-1')
// }, testTimeout)
//
// test('should stand up and tear down a custom domain stack in a non-IAD region', async () => {
// return commonTest('us-west-2', 'domain-us-west-2')
// }, testTimeout)
})
Loading

0 comments on commit 7d09ef1

Please sign in to comment.