AWS Toolkit for JetBrains
User Guide

Creating an AWS Lambda Function by Using the AWS Toolkit for JetBrains

You can use the AWS Toolkit for JetBrains to create an AWS Lambda function that is part of an AWS serverless application. Or you can create a standalone Lambda function.

To create a Lambda function that is part of an AWS serverless application, skip the rest of this topic and see Creating an Application instead.

To create a standalone Lambda function, you must first install the AWS Toolkit for JetBrains and, if you haven't yet, connect to an AWS account for the first time. Then, with IntelliJ IDEA, PyCharm, WebStorm, or JetBrains Rider already running, do one of the following:

  • Open AWS Explorer, if it isn't already open. If you need to switch to a different AWS Region to create the function in, do that now. Then right-click Lambda, and choose Create new AWS Lambda.

    
        Creating an AWS Lambda function by starting from AWS Explorer

    Complete the Create Function dialog box, and then choose Create Function. The AWS Toolkit for JetBrains creates a corresponding AWS CloudFormation stack for the deployment, and adds the function name to the Lambda list in AWS Explorer. If the deployment fails, you can try to figure out why by viewing event logs for the stack.

  • Create a code file that implements a function handler for Java, Python, Node.js, or C#.

    To enable running (invoking) the remote version of the function, if you need to switch to a different AWS Region to create the function in, do that now. Then in the code file, choose the Lambda icon in the gutter next to the function handler, and then choose Create new AWS Lambda. Complete the Create Function dialog box, and then choose Create Function.

    
        Creating an AWS Lambda function by starting from an existing function handler in a
          code file

    Note

    If the Lambda icon isn't displayed in the gutter next to the function handler, you can try displaying it for the current project by selecting the following box in Settings / Preferences: Tools , AWS, Project settings, Show gutter icons for all potential AWS Lambda handlers. Also, if the function handler is already defined in the corresponding AWS SAM template, the Create new AWS Lambda command won't appear.

    After you choose Create Function, the AWS Toolkit for JetBrains creates a corresponding function in the Lambda service for the connected AWS account. If the operation succeeds, after you refresh AWS Explorer, the Lambda list displays the name of the new function.

  • If you already have a project that contains an AWS Lambda function, and if you need to first switch to a different AWS Region to create the function in, do that now. Then in the code file that contains the function handler for Java, Python, Node.js, or C#, choose the Lambda icon in the gutter next to the function handler. Choose Create new AWS Lambda, complete the Create Function dialog box, and then choose Create Function.

    
        Creating an AWS Lambda function by starting from an existing function handler in a
          code file

    Note

    If the Lambda icon isn't displayed in the gutter next to the function handler, you can try displaying it for the current project by selecting the following box in Settings/Preferences: Tools, AWS, Project settings, Show gutter icons for all potential AWS Lambda handlers. Also, the Create new AWS Lambda command won't display if the function handler is already defined in the corresponding AWS SAM template.

    After you choose Create Function, the AWS Toolkit for JetBrains creates a corresponding function in the Lambda service for the connected AWS account. If the operation succeeds, after you refresh AWS Explorer, the new function's name appears in the Lambda list.

After you create the function, you can run (invoke) or debug the local version of the function or run (invoke) the remote version.