Closed bestickley closed 1 year ago
How would setGbDefaults
work? Something like:
gb-defaults.ts
interface GbDefaults { ... }
export const gbDefaults = {};
export function setGbDefaults(defaults: GbDefaults) {
deepmerge(gbDefaults, defaults);
}
function.ts
import { gbDefaults } from "./gb-defaults";
export class Function {
constructor(scope: Construct, id: string, props: FunctionProps) {
const newProps = deepmerge(gbDefaults, props);
...
}
}
Outstanding Questions:
${stageName}-${appName}-${stackName}
a good idea? Does it make resource names too long? For example, in DynamoDB your table name could be: stickb-gb-data-WidgetsTable9C270917-VXMGQWO7JNVS.
useConfig
hook or context system? Alternative is to only pass stageName
down and then have a stageConfigs: Record<StageName, StageConfig>
where we could reference correct stage config.
stageName
as a prop and retrieving the appropriate config on demand, but either way works. It would be worth exploring a solution to avoid "prop drilling" but I think that could be an enhancement.
gboost create
sets up an opinionated infra workspace (folder) which defines a CDK app. I'd like to propose a new alternative way based on this article which is based off CDK Best Practices. Please read those documents first before reading this proposal.For folder structure, currently GB has:
new App()
) for deploying locally and instantiatesBased off above resources I propose:
For configuration, currently GB assumes developers will have 3 stages: dev, test, and prod and that developers are ok with Green Boost deciding what configuration (within GB Constructs) is correct for these stages. This is an issue because developers often have more than 3 stages and they're often named differently. Even if we could use stage name as an abstraction point, we shouldn't because for developers to understand what the configuration is per GB construct, they'll have to hunt through source code. It's best to be explicit and let developers define configuration within their source code. We'll leverage the power of TypeScript intellisense to make this as easy as possible. Overall, this means stacks and constructs won't even need to know the stage name anymore because conditional infra config will be defined at the top level within a config/ folder. All configuration will be explicitly passed into stacks. This keeps in line with best practice
The purpose of local-app.ts is so that developers can quickly synth and deploy their apps locally. This CDK App will reference app-stage.ts which abstracts how stacks are instantiated so that it local-app.ts and pipeline-app.ts can use stacks in the same way. cdk.json#app value will reference local-app.ts so developer can more easily deploy app. When deploying pipeline-app, we will utilize "app" CLI parameter to reference correct entrypoint.
I propose we generate a src/config folder for each
gboost create
template. Within this folder we'll have:src/config/stage-config.ts
Note, above we're using
stageName
instead ofstage
to refer to stage name. This is more explicit and will hopefully be less confusing becauseStage
is abstract application modeling unit in CDK.src/config/local.ts
src/config/test.ts
src/app-stage.ts
src/local-app.ts
src/pipeline/pipeline-app.ts
src/pipeline/pipeline-stack.ts
The benefit of generating is that developers can change this to fit their needs.
Outstanding Questions:
${stageName}-${appName}-${stackName}
a good idea? Does it make resource names too long? For example, in DynamoDB your table name could be: stickb-gb-data-WidgetsTable9C270917-VXMGQWO7JNVS.useConfig
hook or context system? Alternative is to only passstageName
down and then have astageConfigs: Record<StageName, StageConfig>
where we could reference correct stage config.TODO: