File tree Expand file tree Collapse file tree 8 files changed +35
-44
lines changed
src/packages/app-framework/src
get-installation-access-token Expand file tree Collapse file tree 8 files changed +35
-44
lines changed Original file line number Diff line number Diff line change 77} from 'aws-cdk-lib/aws-lambda' ;
88import { NodejsFunction } from 'aws-cdk-lib/aws-lambda-nodejs' ;
99import { Construct } from 'constructs' ;
10- import { LAMBDA_DEFAULTS } from '../../lambdaDefaults' ;
10+ import { LAMBDA_DEFAULTS_WITH_RE2_WASM } from '../../lambdaDefaults' ;
1111import { EnvironmentVariables , TAG_KEYS , TAG_VALUES } from '../constants' ;
1212
1313export interface GitHubAppTokenProps {
@@ -22,13 +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
30- nodeModules : [ 're2-wasm' ] ,
31- } ,
25+ ...LAMBDA_DEFAULTS_WITH_RE2_WASM ,
3226 environment : {
3327 [ EnvironmentVariables . APP_TABLE_NAME ] : props . appTableName ,
3428 [ EnvironmentVariables . INSTALLATION_TABLE_NAME ] :
Original file line number Diff line number Diff line change 88} from 'aws-cdk-lib/aws-lambda' ;
99import { NodejsFunction } from 'aws-cdk-lib/aws-lambda-nodejs' ;
1010import { Construct } from 'constructs' ;
11- import { LAMBDA_DEFAULTS } from '../../lambdaDefaults' ;
11+ import { LAMBDA_DEFAULTS_WITH_RE2_WASM } from '../../lambdaDefaults' ;
1212import { EnvironmentVariables , TAG_KEYS , TAG_VALUES } from '../constants' ;
1313
1414export interface InstallationAcessTokenProps {
@@ -25,11 +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- nodeModules : [ 're2-wasm' ] ,
32- } ,
28+ ...LAMBDA_DEFAULTS_WITH_RE2_WASM ,
3329 environment : {
3430 [ EnvironmentVariables . APP_TABLE_NAME ] : props . AppTable . tableName ,
3531 [ EnvironmentVariables . INSTALLATION_TABLE_NAME ] :
Original file line number Diff line number Diff line change 77} from 'aws-cdk-lib/aws-lambda' ;
88import { NodejsFunction } from 'aws-cdk-lib/aws-lambda-nodejs' ;
99import { Construct } from 'constructs' ;
10- import { LAMBDA_DEFAULTS } from '../../lambdaDefaults' ;
10+ import { LAMBDA_DEFAULTS_WITH_RE2_WASM } from '../../lambdaDefaults' ;
1111import { EnvironmentVariables , TAG_KEYS , TAG_VALUES } from '../constants' ;
1212
1313export interface InstallationCachedDataProps {
@@ -32,11 +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- nodeModules : [ 're2-wasm' ] ,
39- } ,
35+ ...LAMBDA_DEFAULTS_WITH_RE2_WASM ,
4036 environment : {
4137 [ EnvironmentVariables . INSTALLATION_TABLE_NAME ] :
4238 props . InstallationTable . tableName ,
Original file line number Diff line number Diff line change 77} from 'aws-cdk-lib/aws-lambda' ;
88import { NodejsFunction } from 'aws-cdk-lib/aws-lambda-nodejs' ;
99import { Construct } from 'constructs' ;
10- import { LAMBDA_DEFAULTS } from '../../lambdaDefaults' ;
10+ import { LAMBDA_DEFAULTS_WITH_RE2_WASM } from '../../lambdaDefaults' ;
1111import { EnvironmentVariables , TAG_KEYS , TAG_VALUES } from '../constants' ;
1212
1313export interface InstallationCachedDataProps {
@@ -32,11 +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- nodeModules : [ 're2-wasm' ] ,
39- } ,
35+ ...LAMBDA_DEFAULTS_WITH_RE2_WASM ,
4036 environment : {
4137 [ EnvironmentVariables . INSTALLATION_TABLE_NAME ] :
4238 props . InstallationTable . tableName ,
Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ import { LambdaFunction } from 'aws-cdk-lib/aws-events-targets';
55import { Effect , PolicyStatement } from 'aws-cdk-lib/aws-iam' ;
66import { NodejsFunction } from 'aws-cdk-lib/aws-lambda-nodejs' ;
77import { Construct } from 'constructs' ;
8- import { LAMBDA_DEFAULTS } from '../../lambdaDefaults' ;
8+ import { LAMBDA_DEFAULTS_WITH_RE2_WASM } from '../../lambdaDefaults' ;
99import { EnvironmentVariables , TAG_KEYS , TAG_VALUES } from '../constants' ;
1010
1111export interface InstallationTrackerProps {
@@ -22,11 +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- nodeModules : [ 're2-wasm' ] ,
29- } ,
25+ ...LAMBDA_DEFAULTS_WITH_RE2_WASM ,
3026 environment : {
3127 [ EnvironmentVariables . APP_TABLE_NAME ] : props . AppTable . tableName ,
3228 [ EnvironmentVariables . INSTALLATION_TABLE_NAME ] :
Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ import { LambdaFunction } from 'aws-cdk-lib/aws-events-targets';
55import { Effect , PolicyStatement } from 'aws-cdk-lib/aws-iam' ;
66import { NodejsFunction } from 'aws-cdk-lib/aws-lambda-nodejs' ;
77import { Construct } from 'constructs' ;
8- import { LAMBDA_DEFAULTS } from '../../lambdaDefaults' ;
8+ import { LAMBDA_DEFAULTS_WITH_RE2_WASM } from '../../lambdaDefaults' ;
99import { EnvironmentVariables , TAG_KEYS , TAG_VALUES } from '../constants' ;
1010
1111export interface RateLimitTrackerProps {
@@ -20,11 +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- nodeModules : [ 're2-wasm' ] ,
27- } ,
23+ ...LAMBDA_DEFAULTS_WITH_RE2_WASM ,
2824 environment : {
2925 [ EnvironmentVariables . APP_TABLE_NAME ] : props . AppTable . tableName ,
3026 [ EnvironmentVariables . INSTALLATION_TABLE_NAME ] :
Original file line number Diff line number Diff line change 88} from 'aws-cdk-lib/aws-lambda' ;
99import { NodejsFunction } from 'aws-cdk-lib/aws-lambda-nodejs' ;
1010import { Construct } from 'constructs' ;
11- import { LAMBDA_DEFAULTS } from '../../lambdaDefaults' ;
11+ import { LAMBDA_DEFAULTS_WITH_RE2_WASM } from '../../lambdaDefaults' ;
1212import { EnvironmentVariables , TAG_KEYS , TAG_VALUES } from '../constants' ;
1313
1414export interface InstallationRefreshProps {
@@ -23,11 +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- nodeModules : [ 're2-wasm' ] ,
30- } ,
26+ ...LAMBDA_DEFAULTS_WITH_RE2_WASM ,
3127 environment : {
3228 [ EnvironmentVariables . APP_TABLE_NAME ] : props . AppTable . tableName ,
3329 [ EnvironmentVariables . INSTALLATION_TABLE_NAME ] :
Original file line number Diff line number Diff 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+ } ;
You can’t perform that action at this time.
0 commit comments