Skip to content

Commit 7d09ef1

Browse files
Merge pull request #252 from awslabs/staging
v3.0.0
2 parents 1c5bc0a + c450eed commit 7d09ef1

File tree

193 files changed

+31114
-8250
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

193 files changed

+31114
-8250
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
dev-portal/node_modules/*
1313
!dev-portal/node_modules/swagger-ui/
1414
dev-portal/node_modules/swagger-ui/*
15+
!dev-portal/node_modules/swagger-ui/package.json
1516
!dev-portal/node_modules/swagger-ui/dist/
1617

1718
# built artifacts
@@ -27,7 +28,8 @@ dev-portal/node_modules/swagger-ui/*
2728
# misc
2829
npm-debug.log
2930
.DS_Store
30-
packaged.yaml
31+
packaged*.yaml
3132
cognito.js
3233
.idea
3334
.vscode
35+
*.iml

.travis.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
language: node_js
22
node_js:
3-
- "node"
3+
# we can't use latest because 11.11 breaks jest's env variable mock
4+
- "11.10.1"
45

56
cache: npm
67

78
before_install:
9+
# install clis in parallel
10+
# - pip install --user awscli
11+
# pip install --user aws-sam-cli
12+
# https://github.com/travis-ci/travis-ci/issues/3139
813
- cd dev-portal
914
# install everything in dev portal
1015
- npm install

README.md

Lines changed: 25 additions & 139 deletions
Large diffs are not rendered by default.

README_SAR.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ The Serverless Developer Portal is an application that you use for developer eng
66
#### To deploy
77
1. Enter a name for ArtifactsS3BucketName: this will create an Amazon S3 bucket with that name for storing the catalog metadata.
88
1. Enter a name for DevPortalSiteS3BucketName: this will create an Amazon S3 bucket with that name for the web application code.
9+
1. Enter a unique prefix for CognitoDomainNameOrPrefix; this will be used in the sign in page's URL.
910
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.
1011
1. Acknowledge that the app uses custom roles by checking the box "I acknowledge that this app creates custom IAM roles."
1112
1. Choose Deploy.
@@ -16,14 +17,14 @@ The Serverless Developer Portal is an application that you use for developer eng
1617
1. Open the Outputs section. The URL for the developer portal is specified in the WebSiteURL property.
1718

1819
#### Updating to a new version
19-
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.
20+
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).
2021

2122
To update:
22-
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").
23+
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.
2324

2425
#### Next steps
2526
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).
26-
1. Customize, own, and brand the portal. Learn how to do that [here](https://github.com/awslabs/aws-api-gateway-developer-portal#customization).
27+
1. Customize, own, and brand the portal. Learn how to do that [here](https://github.com/awslabs/aws-api-gateway-developer-portal/wiki/Customization).
2728
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).
2829

2930
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/).

__tests__/cfn-integration-test.js

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
const fs = require('fs')
2+
const rp = require('request-promise')
3+
4+
describe('template.yaml', () => {
5+
// NOTE: These tests all assume that the CFN template has already been packaged *PER REGION*!
6+
const cfnTimeout = 75,
7+
// run the test with a timeout of slightly longer than double the CFN stack timeout
8+
testTimeout = 1000*60*cfnTimeout*2 + 1
9+
const _console = console.log
10+
11+
async function commonTest(region, stackMiddlefix) {
12+
let unixTimestamp = Math.floor(new Date() / 1000),
13+
stackName = `cfn-integ-${ stackMiddlefix }-${ unixTimestamp }`,
14+
s3Params = {
15+
// CFN, when reading the template from S3, requires the S3 bucket to be in the same region as the CFN stack...
16+
Bucket: `dev-portal-integ-${ region }`,
17+
Body: fs.readFileSync(`./cloudformation/packaged-${region}.yaml`),
18+
Key: stackName
19+
},
20+
cfnParams = {
21+
StackName: stackName,
22+
Capabilities: ['CAPABILITY_NAMED_IAM', 'CAPABILITY_AUTO_EXPAND'],
23+
Parameters: [
24+
{
25+
ParameterKey: 'DevPortalSiteS3BucketName',
26+
ParameterValue: `integ-${ stackMiddlefix }-${ unixTimestamp }-dev-portal-test`
27+
},
28+
{
29+
ParameterKey: 'ArtifactsS3BucketName',
30+
ParameterValue: `integ-${ stackMiddlefix }-${ unixTimestamp }-artifact-bucket`
31+
},
32+
{
33+
ParameterKey: 'DevPortalCustomersTableName',
34+
ParameterValue: `Customers${ unixTimestamp }`
35+
},
36+
{
37+
ParameterKey: 'CognitoDomainNameOrPrefix',
38+
ParameterValue: `integ-${ stackMiddlefix }-${ unixTimestamp }`
39+
}
40+
],
41+
// RoleARN: 'STRING_VALUE',
42+
TimeoutInMinutes: cfnTimeout
43+
}
44+
45+
console.log('commonTest', region)
46+
47+
const AWS = require('aws-sdk')
48+
AWS.config.update({ region: region })
49+
50+
// pin versions of SDKs
51+
const cfn = new AWS.CloudFormation({ region: region }),
52+
s3 = new AWS.S3({ region: region }),
53+
logger = function (input) {
54+
_console(`${region}:${stackName}:${input}`)
55+
}
56+
57+
// Upload the packaged template to S3, then use the resulting URL in the CFN createStack call
58+
// This is necessary because the file is too large to deliver in-line to CFN
59+
cfnParams.TemplateURL =(await s3.upload(s3Params).promise()).Location
60+
61+
logger('createStack call starting.')
62+
await cfn.createStack(cfnParams).promise()
63+
logger('createStack call succeeded.')
64+
65+
logger('stackExists waiter starting.')
66+
await cfn.waitFor('stackExists', { StackName: stackName }).promise()
67+
logger('stackExists waiter succeeded.')
68+
69+
logger('stackCreateComplete waiter starting.')
70+
let devPortalUrl =
71+
(await cfn.waitFor('stackCreateComplete', { StackName: stackName }).promise()).Stacks[0].Outputs
72+
.find((output) => output.OutputKey === 'WebsiteURL').OutputValue
73+
logger('stackCreateComplete waiter succeeded.')
74+
75+
logger(`verifying that stack is available at ${devPortalUrl} .`)
76+
let staticIndex = await rp(devPortalUrl)
77+
78+
expect(staticIndex.includes('<title>Developer Portal</title>')).toBeTruthy()
79+
logger(`verified that stack is available at ${devPortalUrl} .`)
80+
81+
// add RoleArn: ... later
82+
logger('deleteStack call starting.')
83+
await cfn.deleteStack({ StackName: stackName }).promise()
84+
logger('deleteStack call succeeded.')
85+
86+
logger('stackDeleteComplete waiter starting.')
87+
await cfn.waitFor('stackDeleteComplete', { StackName: stackName }).promise()
88+
logger('stackDeleteComplete waiter succeeded.')
89+
90+
// pass the test; we successfully stood the stack up and tore it down
91+
expect(true).toBe(true)
92+
93+
return true
94+
}
95+
96+
test.concurrent('should stand up and tear down the stack in IAD', async () => {
97+
return commonTest('us-east-1', 'us-east-1')
98+
}, testTimeout)
99+
100+
test.concurrent('should stand up and tear down the stack in a non-IAD region', async () => {
101+
return commonTest('us-west-2', 'us-west-2')
102+
}, testTimeout)
103+
104+
// Implement these! Hardest part will be having test ACM certs in the account
105+
// test('should stand up and tear down a custom domain stack in IAD', async () => {
106+
// return commonTest('us-east-1', 'domain-us-east-1')
107+
// }, testTimeout)
108+
//
109+
// test('should stand up and tear down a custom domain stack in a non-IAD region', async () => {
110+
// return commonTest('us-west-2', 'domain-us-west-2')
111+
// }, testTimeout)
112+
})

0 commit comments

Comments
 (0)