Skip to content

Commit

Permalink
Merge pull request #290 from awslabs/staging
Browse files Browse the repository at this point in the history
Merge v3.0.2 to master
  • Loading branch information
echo-bravo-yahoo authored Jul 2, 2019
2 parents c447bfc + 84bd22c commit bf3d87f
Show file tree
Hide file tree
Showing 56 changed files with 11,021 additions and 14,852 deletions.
22 changes: 18 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,37 @@ If you have previously set up a v1 developer portal (non-SAM deployed), you will
#### Deploy

Run:

>In the command below, replace the `your-lambda-artifacts-bucket-name` with the name of a bucket that you manage and that already exists. Then, run:
```bash
sam package --template-file ./cloudformation/template.yaml --output-template-file ./cloudformation/packaged.yaml --s3-bucket your-lambda-artifacts-bucket-name
sam package --template-file ./cloudformation/template.yaml \
--output-template-file ./cloudformation/packaged.yaml \
--s3-bucket your-lambda-artifacts-bucket-name
```

Then run:
Then run:

>In the command below, replace the `your-lambda-artifacts-bucket-name` with the name of a bucket that you manage and that already exists, and replace `custom-prefix` with some prefix that is globally unique, like your org name or username. Then, run:
```bash
sam deploy --template-file ./cloudformation/packaged.yaml --stack-name "dev-portal" --s3-bucket your-lambda-artifacts-bucket-name --capabilities CAPABILITY_NAMED_IAM --parameter-overrides DevPortalSiteS3BucketName="custom-prefix-dev-portal-static-assets" ArtifactsS3BucketName="custom-prefix-dev-portal-artifacts" CognitoDomainNameOrPrefix="custom-prefix"
sam deploy --template-file ./cloudformation/packaged.yaml \
--stack-name "dev-portal" \
--s3-bucket your-lambda-artifacts-bucket-name \
--capabilities CAPABILITY_NAMED_IAM \
--parameter-overrides \
DevPortalSiteS3BucketName="custom-prefix-dev-portal-static-assets" \
ArtifactsS3BucketName="custom-prefix-dev-portal-artifacts" \
CognitoDomainNameOrPrefix="custom-prefix"
```

The command will exit when the stack creation is successful. If you'd like to watch it create in real-time, you can log into the cloudformation console.

To get the URL for the newly created developer portal instance, find the websiteURL field in the cloudformation console's outputs or run this command:

```bash
aws cloudformation describe-stacks --query "Stacks[?StackName=='dev-portal'][Outputs[?OutputKey=='WebsiteURL']][][].OutputValue"
aws cloudformation describe-stacks --query \
"Stacks[?StackName=='dev-portal'][Outputs[?OutputKey=='WebsiteURL']][][].OutputValue"
```

You can override any of the parameters in the template using the `--parameter-overrides key="value"` format. This will be necessary if you intend to deploy several instances of the developer portal or customize some of the features. You can see a full list of overridable parameters in `cloudformation/template.yaml` under the `Parameters` section.
Expand Down
28 changes: 20 additions & 8 deletions cloudformation/template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,12 @@ 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: ''
AllowedValues:
- 'overwrite-content'
- ''
ConstraintDescription: Malformed input - Parameter StaticAssetRebuildMode value must be either 'overwrite-content' or left blank.

MarketplaceSubscriptionTopicProductCode:
Type: String
Expand Down Expand Up @@ -108,11 +112,19 @@ Parameters:
Type: String
Description: Only applicable if creating a custom domain name for your dev portal. Defaults to false, and you'll need to provide your own nameserver hosting. If set to true, a Route53 HostedZone and RecordSet are created for you.
Default: 'false'
AllowedValues:
- 'false'
- 'true'
ConstraintDescription: Malformed input - Parameter UseRoute53Nameservers value must be either 'true' or 'false'

DevelopmentMode:
Type: String
Description: Enabling this weakens security features (OAI, SSL, site S3 bucket with public read ACLs, Cognito callback verification, CORS, etc.) for easier development. Do not enable this in production! Additionally, do not update a stack that was previously in development mode to be a production stack; instead, make a new stack that has never been in development mode.
Description: Enabling this weakens security features (OAI, SSL, site S3 bucket with public read ACLs, Cognito callback verification, CORS, etc.) for easier development. It also breaks frontend routing (except to /index.html), including deep linking and page refresh. Do not enable this in production! Additionally, do not update a stack that was previously in development mode to be a production stack; instead, make a new stack that has never been in development mode.
Default: 'false'
AllowedValues:
- 'false'
- 'true'
ConstraintDescription: Malformed input - Parameter DevelopmentMode value must be either 'true' or 'false'

Conditions:
UseCustomDomainName: !And [!And [!Not [!Equals [!Ref CustomDomainName, '']], !Not [!Equals [!Ref CustomDomainNameAcmCertArn, '']]], !Condition NotDevelopmentMode]
Expand Down Expand Up @@ -1109,20 +1121,20 @@ Resources:
SupportedIdentityProviders: [ "COGNITO" ] # should (eventually) allow people to add values
CallbackURL: !If [ DevelopmentMode,
[
'http://localhost:3000/login',
!Join [ '', [ 'https://', !GetAtt DevPortalSiteS3Bucket.RegionalDomainName ]]
'http://localhost:3000/index.html?action=login',
!Join [ '', [ 'https://', !GetAtt DevPortalSiteS3Bucket.RegionalDomainName, '/index.html?action=login' ]]
],
[
!Join [ '', [ 'https://', !If [ UseCustomDomainName, !Ref CustomDomainName, !GetAtt DefaultCloudfrontDistribution.DomainName ], '/login' ]]
!Join [ '', [ 'https://', !If [ UseCustomDomainName, !Ref CustomDomainName, !GetAtt DefaultCloudfrontDistribution.DomainName ], '/index.html?action=login' ]]
]
]
LogoutURL: !If [ DevelopmentMode,
[
'http://localhost:3000',
!Join [ '', [ 'https://', !GetAtt DevPortalSiteS3Bucket.RegionalDomainName]]
'http://localhost:3000/index.html?action=logout',
!Join [ '', [ 'https://', !GetAtt DevPortalSiteS3Bucket.RegionalDomainName, '/index.html?action=logout' ]]
],
[
!Join [ '', [ 'https://', !If [ UseCustomDomainName, !Ref CustomDomainName, !GetAtt DefaultCloudfrontDistribution.DomainName ]]]
!Join [ '', [ 'https://', !If [ UseCustomDomainName, !Ref CustomDomainName, !GetAtt DefaultCloudfrontDistribution.DomainName ], '/index.html?action=logout' ]]
]
]
AllowedOAuthFlowsUserPoolClient: true
Expand Down
1 change: 0 additions & 1 deletion dev-portal/.env
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
NODE_PATH=src/
SKIP_PREFLIGHT_CHECK=true
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
7 changes: 2 additions & 5 deletions dev-portal/jsconfig.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
{
"compilerOptions": {
"baseUrl": ".",
"baseUrl": "src",
"moduleResolution": "node",
"jsx": "react",
"paths": {
"*": ["src/*"]
}
"jsx": "react"
},
"exclude": [
"node_modules",
Expand Down
Loading

0 comments on commit bf3d87f

Please sign in to comment.