| 79 | } |
| 80 | |
| 81 | private createOrderingFunction(orderTable: ITable) : NodejsFunction { |
| 82 | const nodeJsFunctionProps: NodejsFunctionProps = { |
| 83 | bundling: { |
| 84 | externalModules: [ |
| 85 | 'aws-sdk', // Use the 'aws-sdk' available in the Lambda runtime |
| 86 | ], |
| 87 | }, |
| 88 | environment: { |
| 89 | PRIMARY_KEY: 'userName', |
| 90 | SORT_KEY: 'orderDate', |
| 91 | DYNAMODB_TABLE_NAME: orderTable.tableName, |
| 92 | }, |
| 93 | runtime: Runtime.NODEJS_14_X, |
| 94 | } |
| 95 | |
| 96 | const orderFunction = new NodejsFunction(this, 'orderingLambdaFunction', { |
| 97 | entry: join(__dirname, `/../src/ordering/index.js`), |
| 98 | ...nodeJsFunctionProps, |
| 99 | }); |
| 100 | |
| 101 | orderTable.grantReadWriteData(orderFunction); |
| 102 | return orderFunction; |
| 103 | } |
| 104 | |
| 105 | } |