-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from symphoniacloud/use-bare-bones-standards
Standardize with cdk-bare-bones
- Loading branch information
Showing
10 changed files
with
101 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
cdk.out | ||
node_modules | ||
node_modules | ||
build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
16 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2022 Symphonia LLC | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
{ | ||
"app": "npx ts-node --prefer-ts-exts src/cdk/cdkApp.ts" | ||
"app": "npx ts-node --prefer-ts-exts src/cdk/App.ts" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,13 @@ | ||
{ | ||
"name": "cdk-website-basic-example", | ||
"version": "2022.1.0", | ||
"private": true, | ||
"name": "coffee-store-web-demo", | ||
"version": "2022.1.1", | ||
"homepage": "https://github.com/symphoniacloud/coffee-store-web-demo", | ||
"license": "MIT", | ||
"author": { | ||
"email": "[email protected]", | ||
"name": "Mike Roberts", | ||
"url": "https://symphonia.io" | ||
}, | ||
"devDependencies": { | ||
"@tsconfig/node16": "1.x", | ||
"@types/node": "^16.x", | ||
|
@@ -13,6 +19,10 @@ | |
"typescript": "4.x" | ||
}, | ||
"scripts": { | ||
"deploy": "npx cdk deploy --require-approval never" | ||
"deploy": "npx cdk deploy --output build/cdk.out --require-approval never", | ||
"cdk-diff" : "npx cdk diff --output build/cdk.out --require-approval never", | ||
"cdk-destroy" : "npx cdk destroy --output build/cdk.out --require-approval never", | ||
"precdk-command": "echo \"Running CDK with command: $npm_config_command\"", | ||
"cdk-command": "npx cdk $npm_config_command --output build/cdk.out --require-approval never" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import {App, Environment, StackProps} from "aws-cdk-lib"; | ||
|
||
// Generic functions to help with stack initialization | ||
|
||
interface StackPropsWithAccountRegionAndStackName extends StackProps { | ||
env: Required<Environment> | ||
stackName: string | ||
} | ||
|
||
/** | ||
* Generates stack properties based on a default stack name and current AWS environment | ||
* @param app The CDK app instance | ||
* @param defaultStackName Will be used as stackName, unless a stackName property is specified in the app context | ||
* @return valid StackProps, with env and stackName specified | ||
*/ | ||
export function createStackProps(app: App, defaultStackName: string): StackPropsWithAccountRegionAndStackName { | ||
return {env: calcEnvironment(), stackName: calcStackName(app, defaultStackName)} | ||
} | ||
|
||
/** | ||
* @param app The CDK app instance | ||
* @param defaultStackName default stack name | ||
* @return defaultStackName, unless stackName is specified in app context, in which case that is returned instead | ||
*/ | ||
export function calcStackName(app: App, defaultStackName: string) { | ||
return app.node.tryGetContext('stackName') || defaultStackName | ||
} | ||
|
||
/** | ||
* @return An Environment with both account and region set according to the current AWS environment (see https://docs.aws.amazon.com/cdk/v2/guide/environments.html) | ||
*/ | ||
export function calcEnvironment(): Required<Environment> { | ||
const account = process.env.CDK_DEFAULT_ACCOUNT | ||
const region = process.env.CDK_DEFAULT_REGION | ||
|
||
if (account && region) | ||
return {account, region} | ||
|
||
throw new Error('Unable to read CDK_DEFAULT_ACCOUNT or CDK_DEFAULT_REGION') | ||
} |