174
175const app = new App();
176
177new SchedulerStack(app, 'scheduler-v1', {178 env: {179 account: process.env.CDK_DEFAULT_ACCOUNT,180 region: process.env.CDK_DEFAULT_REGION181 },182 name: 'scheduler',183 version: 'v1'184});185
186app.synth();
142
143 schedulerTable.grantReadWriteData(collectorLambda);
144
145 new Rule(this, 'SchedulerRule', {146 schedule: Schedule.rate(Duration.minutes(1)),147 targets: [new LambdaFunction(148 collectorLambda, {149 event: RuleTargetInput.fromObject({ })150 })]151 });152
153 const workerLambda = new Function(this, 'WorkerFunction', {
154 functionName: `${props.name}-worker-${props.version}`,
Class constructors being invoked and then dropped immediately is an anti-pattern and should be avoided.
Objects instantiated with new
should always be useful in some way (passed as a function argument, stored in a variable for later use, etc).
If the object is instantiated only to invoke some side effect in the constructor, then the side effect should be refactored out into it's own function.
new Foo()
const myFoo = new Foo()