Created
          March 20, 2022 14:31 
        
      - 
      
- 
        Save josefaidt/f2d9384b5705b1690d12120e100ebd2c to your computer and use it in GitHub Desktop. 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | import { LambdaClient, InvokeCommand } from '@aws-sdk/client-lambda' | |
| /** | |
| * Invoke our Lambda function with a payload | |
| * @param {Object.<string, any>} payload | |
| * @returns {Promise<import('@aws-sdk/client-lambda').InvokeCommandOutput>} | |
| */ | |
| async function invoke(payload) { | |
| /** @type {import('@aws-sdk/client-lambda').LambdaClient} */ | |
| const client = new LambdaClient({ region: process.env.REGION }) | |
| /** @type {import('@aws-sdk/client-lambda').InvokeCommandInput} */ | |
| const input = { | |
| FunctionName: process.env.FUNCTION_MYAMPLIFY_FUNCTION_NAME, | |
| Payload: JSON.stringify(payload), | |
| InvocationType: 'Event', | |
| } | |
| /** @type {import('@aws-sdk/client-lambda').Command} */ | |
| const command = new InvokeCommand(input) | |
| /** @type {import('@aws-sdk/client-lambda').InvokeCommandOutput} */ | |
| const output = await client.send(command) | |
| return output | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment