Skip to content

Commit

Permalink
reduce secondary cron lambda memory to 2G
Browse files Browse the repository at this point in the history
  • Loading branch information
its-felix committed Oct 22, 2024
1 parent 11125d9 commit 8d84e84
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions cdk/lib/constructs/cron-lambda-construct.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export interface CronLambdaConstructProps {

export class CronLambdaConstruct extends Construct {
readonly lambda_1G: IFunction;
readonly lambda_10G: IFunction;
readonly lambda_2G: IFunction;

constructor(scope: Construct, id: string, props: CronLambdaConstructProps) {
super(scope, id);
Expand All @@ -48,12 +48,12 @@ export class CronLambdaConstruct extends Construct {
memorySize: 1024,
});

this.lambda_10G = new Function(this, 'CronLambda_10G', {
this.lambda_2G = new Function(this, 'CronLambda_2G', {
...lambdaBaseProps,
memorySize: 1024 * 10,
memorySize: 1024 * 2,
});

for (const fn of [this.lambda_1G, this.lambda_10G]) {
for (const fn of [this.lambda_1G, this.lambda_2G]) {
props.dataBucket.grantRead(fn, 'raw/LH_Public_Data/flightschedules/*');
props.dataBucket.grantWrite(fn, 'raw/LH_Public_Data/*');
props.dataBucket.grantWrite(fn, 'raw/ourairports_data/*');
Expand Down
6 changes: 3 additions & 3 deletions cdk/lib/constructs/sfn-construct.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { LambdaInvoke } from 'aws-cdk-lib/aws-stepfunctions-tasks';
export interface SfnConstructProps {
dataBucket: IBucket;
cronLambda_1G: IFunction;
cronLambda_10G: IFunction;
cronLambda_2G: IFunction;
webhookUrl: cdk.SecretValue;
}

Expand Down Expand Up @@ -98,7 +98,7 @@ export class SfnConstruct extends Construct {
// region conversion
.otherwise(
new LambdaInvoke(this, 'ConvertSchedulesTask', {
lambdaFunction: props.cronLambda_10G,
lambdaFunction: props.cronLambda_2G,
payload: TaskInput.fromObject({
'action': 'convert_flight_schedules',
'params': {
Expand All @@ -114,7 +114,7 @@ export class SfnConstruct extends Construct {
retryOnServiceExceptions: true,
})
.next(new LambdaInvoke(this, 'ConvertFlightsTask', {
lambdaFunction: props.cronLambda_10G,
lambdaFunction: props.cronLambda_2G,
payload: TaskInput.fromObject({
'action': 'convert_flights',
'params': {
Expand Down
2 changes: 1 addition & 1 deletion cdk/lib/stacks/cron-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export class CronStack extends cdk.Stack {
const sfn = new SfnConstruct(this, 'SFN', {
dataBucket: props.dataBucket,
cronLambda_1G: cronLambda.lambda_1G,
cronLambda_10G: cronLambda.lambda_10G,
cronLambda_2G: cronLambda.lambda_2G,
webhookUrl: cdk.SecretValue.cfnParameter(new cdk.CfnParameter(this, 'webhookUrl', {
type: 'String',
noEcho: true,
Expand Down

0 comments on commit 8d84e84

Please sign in to comment.