Skip to content

Commit fe100ff

Browse files
committed
add to lambdaDefault
1 parent 9325789 commit fe100ff

File tree

8 files changed

+35
-102
lines changed

8 files changed

+35
-102
lines changed

src/packages/app-framework/src/credential-manager/get-app-token/appToken.ts

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
} from 'aws-cdk-lib/aws-lambda';
88
import { NodejsFunction } from 'aws-cdk-lib/aws-lambda-nodejs';
99
import { Construct } from 'constructs';
10-
import { LAMBDA_DEFAULTS } from '../../lambdaDefaults';
10+
import { LAMBDA_DEFAULTS_WITH_RE2_WASM } from '../../lambdaDefaults';
1111
import { EnvironmentVariables, TAG_KEYS, TAG_VALUES } from '../constants';
1212

1313
export interface GitHubAppTokenProps {
@@ -22,23 +22,7 @@ export class GitHubAppToken extends Construct {
2222
super(scope, id);
2323
// Create Lambda function for GetAppToken API
2424
this.lambdaHandler = new NodejsFunction(this, 'handler', {
25-
...LAMBDA_DEFAULTS,
26-
bundling: {
27-
...LAMBDA_DEFAULTS.bundling,
28-
// re2-wasm is used by the SSDK common library to do pattern validation, and uses
29-
// a WASM module, so it's excluded from the bundle and copied from local node_modules.
30-
// Change this method once we figure out a better way to interact
31-
// with the network-blocked builder system.
32-
externalModules: ['re2-wasm'],
33-
commandHooks: {
34-
beforeBundling: (): string[] => [],
35-
beforeInstall: (): string[] => [],
36-
afterBundling: (inputDir: string, outputDir: string): string[] => [
37-
`mkdir -p ${outputDir}/node_modules`,
38-
`cp -r ${inputDir}/node_modules/re2-wasm ${outputDir}/node_modules/`,
39-
],
40-
},
41-
},
25+
...LAMBDA_DEFAULTS_WITH_RE2_WASM,
4226
environment: {
4327
[EnvironmentVariables.APP_TABLE_NAME]: props.appTableName,
4428
[EnvironmentVariables.INSTALLATION_TABLE_NAME]:

src/packages/app-framework/src/credential-manager/get-installation-access-token/index.ts

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
} from 'aws-cdk-lib/aws-lambda';
99
import { NodejsFunction } from 'aws-cdk-lib/aws-lambda-nodejs';
1010
import { Construct } from 'constructs';
11-
import { LAMBDA_DEFAULTS } from '../../lambdaDefaults';
11+
import { LAMBDA_DEFAULTS_WITH_RE2_WASM } from '../../lambdaDefaults';
1212
import { EnvironmentVariables, TAG_KEYS, TAG_VALUES } from '../constants';
1313

1414
export interface InstallationAcessTokenProps {
@@ -25,19 +25,7 @@ export class InstallationAcessTokenGenerator extends Construct {
2525
) {
2626
super(scope, id);
2727
this.lambdaHandler = new NodejsFunction(this, 'handler', {
28-
...LAMBDA_DEFAULTS,
29-
bundling: {
30-
...LAMBDA_DEFAULTS.bundling,
31-
externalModules: ['re2-wasm'],
32-
commandHooks: {
33-
beforeBundling: (): string[] => [],
34-
beforeInstall: (): string[] => [],
35-
afterBundling: (inputDir: string, outputDir: string): string[] => [
36-
`mkdir -p ${outputDir}/node_modules`,
37-
`cp -r ${inputDir}/node_modules/re2-wasm ${outputDir}/node_modules/`,
38-
],
39-
},
40-
},
28+
...LAMBDA_DEFAULTS_WITH_RE2_WASM,
4129
environment: {
4230
[EnvironmentVariables.APP_TABLE_NAME]: props.AppTable.tableName,
4331
[EnvironmentVariables.INSTALLATION_TABLE_NAME]:

src/packages/app-framework/src/credential-manager/get-installation-data/index.ts

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
} from 'aws-cdk-lib/aws-lambda';
88
import { NodejsFunction } from 'aws-cdk-lib/aws-lambda-nodejs';
99
import { Construct } from 'constructs';
10-
import { LAMBDA_DEFAULTS } from '../../lambdaDefaults';
10+
import { LAMBDA_DEFAULTS_WITH_RE2_WASM } from '../../lambdaDefaults';
1111
import { EnvironmentVariables, TAG_KEYS, TAG_VALUES } from '../constants';
1212

1313
export interface InstallationCachedDataProps {
@@ -32,19 +32,7 @@ export class InstallationCachedData extends Construct {
3232
super(scope, id);
3333
// Create Lambda function for handling installation data requests
3434
this.lambdaHandler = new NodejsFunction(this, 'handler', {
35-
...LAMBDA_DEFAULTS,
36-
bundling: {
37-
...LAMBDA_DEFAULTS.bundling,
38-
externalModules: ['re2-wasm'],
39-
commandHooks: {
40-
beforeBundling: (): string[] => [],
41-
beforeInstall: (): string[] => [],
42-
afterBundling: (inputDir: string, outputDir: string): string[] => [
43-
`mkdir -p ${outputDir}/node_modules`,
44-
`cp -r ${inputDir}/node_modules/re2-wasm ${outputDir}/node_modules/`,
45-
],
46-
},
47-
},
35+
...LAMBDA_DEFAULTS_WITH_RE2_WASM,
4836
environment: {
4937
[EnvironmentVariables.INSTALLATION_TABLE_NAME]:
5038
props.InstallationTable.tableName,

src/packages/app-framework/src/credential-manager/get-installations/index.ts

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
} from 'aws-cdk-lib/aws-lambda';
88
import { NodejsFunction } from 'aws-cdk-lib/aws-lambda-nodejs';
99
import { Construct } from 'constructs';
10-
import { LAMBDA_DEFAULTS } from '../../lambdaDefaults';
10+
import { LAMBDA_DEFAULTS_WITH_RE2_WASM } from '../../lambdaDefaults';
1111
import { EnvironmentVariables, TAG_KEYS, TAG_VALUES } from '../constants';
1212

1313
export interface InstallationCachedDataProps {
@@ -32,19 +32,7 @@ export class GetInstallations extends Construct {
3232
super(scope, id);
3333
// Create Lambda function for handling installation data requests
3434
this.lambdaHandler = new NodejsFunction(this, 'handler', {
35-
...LAMBDA_DEFAULTS,
36-
bundling: {
37-
...LAMBDA_DEFAULTS.bundling,
38-
externalModules: ['re2-wasm'],
39-
commandHooks: {
40-
beforeBundling: (): string[] => [],
41-
beforeInstall: (): string[] => [],
42-
afterBundling: (inputDir: string, outputDir: string): string[] => [
43-
`mkdir -p ${outputDir}/node_modules`,
44-
`cp -r ${inputDir}/node_modules/re2-wasm ${outputDir}/node_modules/`,
45-
],
46-
},
47-
},
35+
...LAMBDA_DEFAULTS_WITH_RE2_WASM,
4836
environment: {
4937
[EnvironmentVariables.INSTALLATION_TABLE_NAME]:
5038
props.InstallationTable.tableName,

src/packages/app-framework/src/credential-manager/installation-tracker/index.ts

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { LambdaFunction } from 'aws-cdk-lib/aws-events-targets';
55
import { Effect, PolicyStatement } from 'aws-cdk-lib/aws-iam';
66
import { NodejsFunction } from 'aws-cdk-lib/aws-lambda-nodejs';
77
import { Construct } from 'constructs';
8-
import { LAMBDA_DEFAULTS } from '../../lambdaDefaults';
8+
import { LAMBDA_DEFAULTS_WITH_RE2_WASM } from '../../lambdaDefaults';
99
import { EnvironmentVariables, TAG_KEYS, TAG_VALUES } from '../constants';
1010

1111
export interface InstallationTrackerProps {
@@ -22,19 +22,7 @@ export class InstallationTracker extends Construct {
2222
});
2323

2424
const installationTrackerFunction = new NodejsFunction(this, 'handler', {
25-
...LAMBDA_DEFAULTS,
26-
bundling: {
27-
...LAMBDA_DEFAULTS.bundling,
28-
externalModules: ['re2-wasm'],
29-
commandHooks: {
30-
beforeBundling: (): string[] => [],
31-
beforeInstall: (): string[] => [],
32-
afterBundling: (inputDir: string, outputDir: string): string[] => [
33-
`mkdir -p ${outputDir}/node_modules`,
34-
`cp -r ${inputDir}/node_modules/re2-wasm ${outputDir}/node_modules/`,
35-
],
36-
},
37-
},
25+
...LAMBDA_DEFAULTS_WITH_RE2_WASM,
3826
environment: {
3927
[EnvironmentVariables.APP_TABLE_NAME]: props.AppTable.tableName,
4028
[EnvironmentVariables.INSTALLATION_TABLE_NAME]:

src/packages/app-framework/src/credential-manager/rate-limit-tracker/index.ts

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { LambdaFunction } from 'aws-cdk-lib/aws-events-targets';
55
import { Effect, PolicyStatement } from 'aws-cdk-lib/aws-iam';
66
import { NodejsFunction } from 'aws-cdk-lib/aws-lambda-nodejs';
77
import { Construct } from 'constructs';
8-
import { LAMBDA_DEFAULTS } from '../../lambdaDefaults';
8+
import { LAMBDA_DEFAULTS_WITH_RE2_WASM } from '../../lambdaDefaults';
99
import { EnvironmentVariables, TAG_KEYS, TAG_VALUES } from '../constants';
1010

1111
export interface RateLimitTrackerProps {
@@ -20,19 +20,7 @@ export class RateLimitTracker extends Construct {
2020
super(scope, id);
2121

2222
this.lambdaHandler = new NodejsFunction(this, 'handler', {
23-
...LAMBDA_DEFAULTS,
24-
bundling: {
25-
...LAMBDA_DEFAULTS.bundling,
26-
externalModules: ['re2-wasm'],
27-
commandHooks: {
28-
beforeBundling: (): string[] => [],
29-
beforeInstall: (): string[] => [],
30-
afterBundling: (inputDir: string, outputDir: string): string[] => [
31-
`mkdir -p ${outputDir}/node_modules`,
32-
`cp -r ${inputDir}/node_modules/re2-wasm ${outputDir}/node_modules/`,
33-
],
34-
},
35-
},
23+
...LAMBDA_DEFAULTS_WITH_RE2_WASM,
3624
environment: {
3725
[EnvironmentVariables.APP_TABLE_NAME]: props.AppTable.tableName,
3826
[EnvironmentVariables.INSTALLATION_TABLE_NAME]:

src/packages/app-framework/src/credential-manager/refresh/index.ts

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
} from 'aws-cdk-lib/aws-lambda';
99
import { NodejsFunction } from 'aws-cdk-lib/aws-lambda-nodejs';
1010
import { Construct } from 'constructs';
11-
import { LAMBDA_DEFAULTS } from '../../lambdaDefaults';
11+
import { LAMBDA_DEFAULTS_WITH_RE2_WASM } from '../../lambdaDefaults';
1212
import { EnvironmentVariables, TAG_KEYS, TAG_VALUES } from '../constants';
1313

1414
export interface InstallationRefreshProps {
@@ -23,19 +23,7 @@ export class InstallationRefresher extends Construct {
2323
super(scope, id);
2424

2525
this.lambdaHandler = new NodejsFunction(this, 'handler', {
26-
...LAMBDA_DEFAULTS,
27-
bundling: {
28-
...LAMBDA_DEFAULTS.bundling,
29-
externalModules: ['re2-wasm'],
30-
commandHooks: {
31-
beforeBundling: (): string[] => [],
32-
beforeInstall: (): string[] => [],
33-
afterBundling: (inputDir: string, outputDir: string): string[] => [
34-
`mkdir -p ${outputDir}/node_modules`,
35-
`cp -r ${inputDir}/node_modules/re2-wasm ${outputDir}/node_modules/`,
36-
],
37-
},
38-
},
26+
...LAMBDA_DEFAULTS_WITH_RE2_WASM,
3927
environment: {
4028
[EnvironmentVariables.APP_TABLE_NAME]: props.AppTable.tableName,
4129
[EnvironmentVariables.INSTALLATION_TABLE_NAME]:

src/packages/app-framework/src/lambdaDefaults.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,24 @@ export const LAMBDA_DEFAULTS = {
1515
externalModules: [],
1616
},
1717
};
18+
19+
// Bundling configuration for Lambdas that use re2-wasm
20+
// re2-wasm is used by the SSDK common library to do pattern validation, and uses
21+
// a WASM module, so it's excluded from the bundle and copied from local node_modules.
22+
// Change this method once we figure out a better way to interact
23+
// with the network-blocked builder system.
24+
export const LAMBDA_DEFAULTS_WITH_RE2_WASM = {
25+
...LAMBDA_DEFAULTS,
26+
bundling: {
27+
...LAMBDA_DEFAULTS.bundling,
28+
externalModules: ['re2-wasm'],
29+
commandHooks: {
30+
beforeBundling: (): string[] => [],
31+
beforeInstall: (): string[] => [],
32+
afterBundling: (inputDir: string, outputDir: string): string[] => [
33+
`mkdir -p ${outputDir}/node_modules`,
34+
`cp -r ${inputDir}/node_modules/re2-wasm ${outputDir}/node_modules/`,
35+
],
36+
},
37+
},
38+
};

0 commit comments

Comments
 (0)