-
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.
Add initial app infrastructure configuration
- Loading branch information
Showing
11 changed files
with
76 additions
and
9 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
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 |
---|---|---|
|
@@ -72,4 +72,4 @@ jobs: | |
run: npm run build | ||
|
||
- name: CDK Synth | ||
run: npm run synth | ||
run: npm run synth -- --context config=dev |
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,3 @@ | ||
{ | ||
"removalPolicy": "destroy" | ||
} |
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,3 @@ | ||
{ | ||
"removalPolicy": "destroy" | ||
} |
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,10 +1,13 @@ | ||
#!/usr/src/env node | ||
import 'source-map-support/register' | ||
import * as cdk from 'aws-cdk-lib' | ||
import { ReactAppStack } from './reactAppStack' | ||
import { ReactAppStack } from './stacks/reactAppStack' | ||
import { getAppConfig } from './config' | ||
|
||
const app = new cdk.App() | ||
|
||
new ReactAppStack(app, 'ReactAppStack', {}) | ||
const config = getAppConfig(app.node.getContext('config') as string) | ||
|
||
new ReactAppStack(app, 'ReactAppStack', config) | ||
|
||
app.synth() |
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 @@ | ||
import * as cdk from 'aws-cdk-lib' | ||
|
||
export interface AppConfig { | ||
readonly removalPolicy: cdk.RemovalPolicy | ||
} | ||
|
||
const defaultAppConfig: AppConfig = { | ||
removalPolicy: cdk.RemovalPolicy.RETAIN | ||
} | ||
|
||
/** | ||
* Reads the json configuration file for the given name and overrides the default configuration. | ||
* | ||
* @param name The name of the configuration file to read. | ||
*/ | ||
export function getAppConfig(name?: string): AppConfig { | ||
return { | ||
...defaultAppConfig, | ||
...require(`../../config/${name}.json`) | ||
} | ||
} |
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,16 @@ | ||
import { AppConfig, getAppConfig } from '../src/config' | ||
import * as cdk from 'aws-cdk-lib' | ||
|
||
let config: AppConfig | ||
|
||
beforeAll(() => { | ||
config = getAppConfig('test') | ||
}) | ||
|
||
describe('Config', () => { | ||
it('should equal test config', () => { | ||
expect(config).toEqual({ | ||
removalPolicy: cdk.RemovalPolicy.DESTROY | ||
}) | ||
}) | ||
}) |
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,6 @@ | ||
import { AppConfig } from '../src/config' | ||
import * as cdk from 'aws-cdk-lib' | ||
|
||
export const testConfig: AppConfig = { | ||
removalPolicy: cdk.RemovalPolicy.DESTROY | ||
} |
6 changes: 4 additions & 2 deletions
6
infrastructure/test/reactAppStack.test.ts → ...ructure/test/stacks/reactAppStack.test.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