Menu
AWS Cloud9
User Guide

Working with AWS Lambda Functions in the AWS Cloud9 Integrated Development Environment (IDE)

You can use the AWS Cloud9 IDE to work with AWS Lambda functions and their related Amazon API Gateway APIs in an AWS Cloud9 development environment. For example, you can:

  • Create a new function from within your environment, uploading the local version of the function to Lambda, and optionally creating additional AWS resources to support the new function at the same time.

  • Run and debug a function and its related API in your environment, running the function and API completely within the environment.

  • Run the remote version of a function and its related API within your environment, running the remote version completely within Lambda and API Gateway.

  • Import an existing function in Lambda into your environment, so that you can run and debug the function and its related API, edit the code, or both.

  • Upload changes you make to the local version of the function code to the remote version in Lambda.

This topic assumes you already know about Lambda. For more information, see the AWS Lambda Developer Guide.

Prepare to Work with Lambda Functions

Before you can work with Lambda functions in the AWS Cloud9 IDE, you must complete the following steps:

Step 1: Set Up Your IAM Group with Required Access Permissions

If your AWS access credentials are associated with an IAM administrator user in your AWS account, and you want to use that user to work with Lambda functions, skip ahead to Step 2: Set Up Your Environment with Your AWS Access Credentials.

Otherwise, complete the following instructions to:

  • Use the IAM console to attach the AWS managed policies named AWSLambdaFullAccess, AmazonAPIGatewayAdministrator, and AmazonAPIGatewayInvokeFullAccess to an IAM group to which your user belongs.

  • Use the AWS CloudFormation console to attach an additional inline policy to that group.

  1. Sign in to the AWS Management Console, if you're not already signed in.

    For this step, we recommend you sign in using credentials for an IAM administrator in your AWS account. If you can't do this, check with your AWS account administrator.

  2. Open the IAM console. To do this, in the console's navigation bar, choose Services. Then choose IAM.

  3. Choose Groups.

  4. Choose the group's name.

  5. On the Permissions tab, for Managed Policies, choose Attach Policy.

  6. In the list of policy names, choose the boxes next to AWSLambdaFullAccess, AmazonAPIGatewayAdministrator, and AmazonAPIGatewayInvokeFullAccess. (If you don't see any of these policy names in the list, type the policy name in the Search box to display it.)

  7. Choose Attach Policy.

  8. Open the AWS CloudFormation console. To do this, in the console's navigation bar, choose Services. Then choose CloudFormation.

  9. Choose Create Stack.

  10. On the Select Template page, for Choose a template, choose Specify an Amazon S3 template URL. In the box, type or paste one of the following URL to the AWS CloudFormation template.

    https://s3.amazonaws.com/cloud9-cfn-templates/Cloud9LambdaAccessGroup.yaml
  11. Choose Next.

  12. On the Specify Details page, for Stack name, type a name for the stack, for example AWSCloud9LambdaAccessStack. If you type a different name, replace it throughout this procedure.

  13. For Parameters, for GroupName, type the name of the existing group in your AWS account you want to attach the access policy to.

  14. Choose Next.

  15. On the Options page, choose Next. (Do not change any of the default settings on the Options page.)

  16. On the Review page, choose I acknowledge that AWS CloudFormation might create IAM resources.

  17. Choose Create.

Wait until the AWSCloud9LambdaAccessStack stack shows CREATE_COMPLETE. This may take a few moments. Please be patient.

Note

The access policy that AWS CloudFormation attaches to the group is named AWSCloud9LambdaGroupAccess and has the following definition, where ACCOUNT_ID is your AWS account ID.

{ "Version": "2012-10-17", "Statement": [ { "Action": [ "cloudformation:CreateChangeSet", "cloudformation:CreateStack", "cloudformation:DescribeChangeSet", "cloudformation:DescribeStackEvents", "cloudformation:DescribeStacks", "cloudformation:ExecuteChangeSet", "cloudformation:ListStackResources", "cloudformation:UpdateStack", "iam:AttachRolePolicy", "iam:DetachRolePolicy", "iam:GetRole", "iam:GetUser", "iam:PassRole" ], "Resource": "*", "Effect": "Allow" }, { "Action": [ "iam:CreateRole", "iam:DeleteRole" ], "Resource": "arn:aws:iam::ACCOUNT_ID:role/cloud9-*", "Effect": "Allow" } ] }

Step 2: Set Up Your Environment with Your AWS Access Credentials

The AWS Cloud9 IDE uses the AWS Command Line Interface (AWS CLI) in your AWS Cloud9 development environment to interact with Lambda and other supporting AWS services. Therefore, the AWS CLI in your environment needs access to your AWS access credentials.

Do one of the following to set up the AWS CLI in your environment:

Step 3: Create an Execution Role for Your Lambda Functions

If you want your Lambda functions to do things usings AWS resources, you must specify an IAM role (execution role) that contains the necessary access permissions for your functions to use.

When you create a Lambda function, AWS Cloud9 can create an execution role for you. This execution role contains the permissions as described in Basic Lambda Permissions in the AWS Lambda Developer Guide.

If this execution role doesn't meet your needs, you must create an execution role on your own before you create your Lambda function. For more information, see the following:

Step 4: Set Your Environment to the Correct AWS Region

You must set your AWS Cloud9 development environment to use the AWS Region where you want to create new Lambda functions in your AWS account, or where you want to import existing Lambda functions from your AWS account into your AWS Cloud9 development environment.

To do this:

  1. In the AWS Cloud9 IDE, on the menu bar, choose AWS Cloud9, Preferences.

  2. In the navigation pane of the Preferences tab, choose AWS Settings.

  3. For AWS Region, select the AWS Region you want to use.

Step 5: Open the Lambda Section of the AWS Resources Window

Now you're ready to begin using the AWS Cloud9 IDE to work with Lambda functions. To do this, expand the Lambda section of the AWS Resources window, if it isn't already expanded.


               AWS Resources window showing the Lambda section

If the AWS Resources window isn't visible, choose the AWS Resources button.

If you don't see the AWS Resources button, choose Window, AWS Resources on the menu bar to show it.

Create a Lambda Function

You can use the AWS Cloud9 IDE to create a new Lambda function. If you already have a Lambda function in your AWS account for the AWS Region you set earlier, skip ahead to Import a Lambda Function.

  1. In the Lambda section of the AWS Resources window, choose where you want to create the function:

    • To create a single function by itself, choose the Local Functions heading.

    • To create a function and then add it to an existing group of one or more functions and related AWS resources (referred to as a serverless application), in the Local Functions list, choose the serverless application for the group (represented by the Lambda icon inside of a folder).

  2. Do one of the following:

    • Choose Create a new Lambda function (the button with the Lambda icon).

    • Right-click the Local Functions heading or the serverless application folder you chose earlier, and then choose Create Here.

    
                  Creating a new Lambda function using the Lambda section of the AWS Resources window
  3. In the Create Serverless Application dialog box, specify the following settings for the function:

    • Function Name: A name for the function.

    • Application Name: The name of the new serverless application to be associated with the new function.

  4. Choose Next.

  5. Choose the function blueprint you want to start with. (Currently, only Node.js and Python function blueprints are available.)

    To show blueprints for a specific runtime, for Select Runtime, choose the runtime. For example, to use the hello-world function blueprint for Node.js 6.10, choose Node.js 6.10 for Select Runtime, and then choose the hello-world blueprint for Select Blueprint.

  6. Choose Next.

  7. Do one of the following:

    • To skip having an AWS service automatically trigger this function, leave Function Trigger set to none, choose Next, and then skip ahead to step 9 in this procedure.

    • To have an AWS resource in your account automatically trigger your function, for Function Trigger, select the name of the AWS service that will contain the resource. (Currently, only API Gateway is available.)

  8. If you chose API Gateway for Function Trigger, specify the following for Trigger Settings:

    • For Resource Path, type the URL portion of the API to use to invoke the function. For example, type / to specify the resource root.

    • For Security, choose the security mechanism for the API endpoint:

  9. Choose Next.

  10. For Memory (MB), choose the amount of memory, in megabytes, that this function will use.

  11. Do one of the following:

    • To have AWS Cloud9 create a new, basic IAM role (execution role) for this function to use, for Role, choose Automatically generate role. Then choose Next.

    • To have Lambda use an existing IAM role (execution role) in your AWS account, for Role, choose Choose an existing role. For Existing Role, choose the name of the role, and then choose Next.

  12. Choose Next.

  13. Choose Finish.

In the Lambda section of the AWS Resources window, AWS Cloud9 does the following:

  • If you chose to create a single function by itself:

    1. AWS Cloud9 creates a serverless application with the name that you specified earlier. Then it adds a serverless application (represented by a Lambda icon inside of a folder) to the Local Functions list. Then it adds the Lambda function (represented by a Lambda icon by itself), to this serverless application.

    2. AWS Cloud9 creates a remote version of the function in Lambda and adds it to the Remote Functions list. AWS Cloud9 gives the remote version a different name. For example, if you named the serverless application myDemoServerlessApplication and the function myDemoFunction, the remote version name of your function would be cloud9-myDemoServerlessApplication-myDemoFunction-RANDOM_ID, where RANDOM_ID is a randomly determined ID.

    3. If you chose to have API Gateway automatically trigger the function, AWS Cloud9 creates an API in API Gateway with a name that corresponds to the function. For example, if you named the function myDemoFunction, the API name would be cloud9-myDemoFunction. AWS Cloud9 uses the value you specified in Resource Path to map the function to the API using the ANY method.

  • If you chose to create a single function and then add it to an existing serverless application:

    1. AWS Cloud9 adds the Lambda function (represented by a Lambda icon by itself), to the existing serverless application (represented by a Lambda icon inside of a folder).

    2. AWS Cloud9 creates a remote version of the function in Lambda and adds it to the Remote Functions list. AWS Cloud9 gives the remote version a different name. For example, if you named the function myDemoFunction and added it to a serverless application named myDemoServerlessApplication, the remote version name would be cloud9-myDemoServerlessApplication-myDemoFunction-RANDOM_ID, where RANDOM_ID is a randomly determined ID.

    3. If you chose to have API Gateway automatically trigger your function, AWS Cloud9 creates an API in API Gateway with a name that corresponds to the related serverless application, if it doesn't already exist. For example, if the serverless application is named myDemoServerlessApplication, the API name would be cloud9-myDemoServerlessApplication. AWS Cloud9 uses the value you specified in Resource Path to map the function to the API using the ANY method.

In the Environment window, AWS Cloud9 does the following:

  • If you chose to create a single function by itself, AWS Cloud9 creates a folder with the same name as the serverless application and puts this folder in the root of the AWS Cloud9 development environment. AWS Cloud9 then adds the following files to the folder:

    • .application.json: A hidden file that contains JSON-formatted settings specific to the serverless application. AWS Cloud9 uses these settings for its internal use. Do not edit this file.

    • .gitignore: A hidden file that contains a list of files Git ignores, if you want to use Git to manage your source code for this function.

    • template.yaml: An AWS SAM template file that contains information about the Lambda function and any other related supported AWS resources. Whenever you update the local version of your function and then upload it to Lambda, AWS Cloud9 calls AWS SAM to use this template file to do the upload. For more information, see the Using the AWS Serverless Application Model (AWS SAM) in the AWS Lambda Developer Guide.

      Note

      You can edit this file to create additional supporting AWS resources for your function. For more information, see the AWS Serverless Application Model (AWS SAM) repository on GitHub.

    • A subfolder with the same name as the function, containing a code file representing the function logic.

  • If you chose to create a single function and then add it to an existing serverless application, AWS Cloud9 does the following to the folder that represents the serverless application:

    • Updates the template.yaml file previously described to include information about the Lambda function and any other related supported AWS resources.

    • A subfolder with the same name as the function, containing a code file representing the function logic.

The .application.json and .gitignore files are hidden. To show hidden files or hide them if they're shown, in the Environment window, choose the gear icon, and then choose Show Hidden Files.

To invoke the function, see Invoke a Lambda Function.

Import a Lambda Function

If you have an existing Lambda function in your AWS account but not in your AWS Cloud9 development environment, you must import it before you can work with it in your environment.

  1. In the Environment window, choose where you want to import the function.

  2. In the Lambda section of the AWS Resources window, choose the function's name in the Remote Functions list.

    Note

    If you don't see your function in the Remote Functions list, choose the Refresh functions List button (the button with the circular arrow icon).

  3. Do one of the following:

    • Double-click the function you just chose.

    • On the menu bar in the Lambda section, choose the Import the selected Lambda function button (the button with the arrow that faces down).

    • Right-click the function you just chose, and then choose Import.

    
                  Importing a Lambda function to use in an AWS Cloud9 development environment

    Note

    You cannot import a Lambda function into a folder that represents either a serverless application or a Lambda function. If you try to do this, AWS Cloud9 will display a message that it will import the Lambda function into the environment's root location instead. To let AWS Cloud9 do this, choose Import. Otherwise, choose Cancel, choose a different folder to import the function (or create a new empty folder to import the function into), and then restart this procedure from the beginning.

  4. When prompted to finish importing the function, choose OK.

AWS Cloud9 imports your function into a new folder in the root of your environment. (AWS Cloud9 also adds the function to the Local Functions list in the Lambda section of the AWS Resources window.) This folder has the same name as the function. AWS Cloud9 adds the following files to this folder:

  • .application.json: A hidden file that contains JSON-formatted settings specific to the function. AWS Cloud9 uses these settings for its internal use.

  • .gitignore: A hidden file that contains a list of files Git ignores, if you want to use Git to manage your source code for this function.

  • template.yaml: A file for AWS Cloud9 internal use.

    Note

    Although the template.yaml file is expressed in AWS SAM format, it isn't used by AWS SAM. Therefore, you cannot edit this file to create additional supporting AWS resources for your function. Do not modify this file.

  • One or more code files containing the function logic.

The .application.json and .gitignore files are hidden. To display or hide hidden files, in the Environment window, choose the gear icon, and then choose Show Hidden Files.

To invoke the function, see Invoke a Lambda Function.

Invoke a Lambda Function

To invoke an existing Lambda function, you must first import the remote version of the function into your AWS Cloud9 development environment, if the function isn't already there. To do this, see Import a Lambda Function.

  1. In the Lambda section of the AWS Resources window, expand the Local Functions list, if it isn't already expanded.

  2. Expand the serverless application folder that contains the function that you want to invoke.

  3. Choose the function that you want to invoke, right-click it, and then choose Run.

  4. Do one of the following:

    • To run the local version of the function within your environment, choose Run Local.

    • To run the remote version of the function within Lambda, choose Run Remote.

    
                  Choose to run the local or remote version of your function

    Note

    If nothing appears to happen, an invoke tab might already be open for the function. If so, choose Lambda (local) or Lambda (remote) in the open invoke tab.

  5. In the Test payload pane of the invoke tab that is displayed, confirm any custom input data you want your function to use when you test it. For information about the input data format, see Step 2.2: Invoke the Lambda Function Manually and Verify Results, Logs, and Metrics in the AWS Lambda Developer Guide.

  6. In the invoke tab, choose the Run button.

    
                  Choose to run the function locally within your environment or remotely within Lambda

    Note

    After you run the function for the first time, a lambda-payloads.json: file is added to the function's related serverless application folder in the Environment window. This file contains the contents of the custom input data.

    If you invoke an existing Lambda function and then try to invoke the same function code for its related API in API Gateway, you might get an error or the code might not run as expected. For more information, see Coding Differences When Invoking a Lambda Function and Its Related API Gateway API.

The invoke tab contains two panes:

  • The Test payload pane displays any custom input data that was supplied for the function.

  • The Execution results pane displays any output from the function and some information from the related Amazon CloudWatch Logs for the function.

For more information, see Step 2.2: Invoke the Lambda Function Manually and Verify Results, Logs, and Metrics in the AWS Lambda Developer Guide.

To upload the local version of any changed function code to the related remote version in Lambda, see Upload Code for a Lambda Function.

Invoke an API Gateway API for a Related Lambda Function

To invoke an API in API Gateway that is related to an existing Lambda function, you must first import the remote version of the function into your AWS Cloud9 development environment, if the function isn't already there. To do this, see Import a Lambda Function.

Note

You cannot debug the remote version of the API Gateway API in your environment. You can only invoke it. To debug the local version, see Debug the Local Version of a Lambda Function or Its Related API Gateway API.

  1. In the Lambda section of the AWS Resources window, expand the Local Functions list, if it isn't already expanded.

  2. Expand the serverless application folder that contains the function whose API you want to invoke.

  3. Choose the function, right-click it, and then choose Run.

  4. Do one of the following:

    • To run the local version of the API within your environment, choose Run API Gateway Local.

    • To run the remote version of the function within Lambda, choose Run API Gateway Remote.

    Note

    If nothing appears to happen, an invoke tab may already be open for the function. If so, choose API Gateway (local) or API Gateway (remote) in the open invoke tab.

  5. In the Test payload pane of the invoke tab that is displayed, confirm the Function, Path, Method, Query String, and Body you want the API to use when you test it.

    Note

    Some APIs might not support settings such as Body. For more information, consult the owner of the API.

  6. On the invoke tab, choose the Run button.

    
                  Choose run on the invoke tab

    Note

    If the API isn't connected to the function, a message appears that says an API Gateway trigger can't be found in the function's AWS SAM file. To use this AWS SAM file to connect an API in API Gateway to the function, see the AWS Serverless Application Model (AWS SAM) repository on GitHub.

    If you invoke an API in API Gateway and then try to invoke the same code for its related function in Lambda, you might get an error or the code might not run as expected. For more information, see Coding Differences When Invoking a Lambda Function and Its Related API Gateway API.

The invoke tab contains two panes:

  • The Test payload pane displays settings and any custom input data that was supplied for the API.

  • The Execution results pane displays information such as the body, headers, and logs of the API response.

Coding Differences When Invoking a Lambda Function and Its Related API Gateway API

When you invoke a Lambda function and then try to invoke the same code for a related API in API Gateway, you might get an error or the code might not run as expected. Likewise, when you invoke an API Gateway API and then try to invoke the same code for a related Lambda function, you might get an error or the code might not run as expected. This is because Lambda and API Gateway use different event data formats. Therefore, you may not be able to successfully invoke the same code in both Lambda and API Gateway.

For example, the following Node.js code invoked with API Gateway returns output in the expected JSON format:

'use strict'; /* Assume the following payload is input: { "fruit": "apple", "vegetable": "carrot" } The expected response is: { "statusCode": 200, "headers": { "Content-type": "application/json" }, "body": { "message": "Your favorite fruit is apple. Your favorite vegetable is carrot." } } */ exports.handler = function(event, context, callback) { var body = JSON.parse(event.body); const message = "Your favorite fruit is " + body.fruit + ". " + "Your favorite vegetable is " + body.vegetable + "."; const response = { statusCode: 200, headers: { "Content-type": "application/json" }, body: JSON.stringify( { "message": message } ) }; callback(null, response); };

To invoke the preceding Node.js code with Lambda, you must remove the line var body = JSON.parse(event.body) as well as substitute body.fruit and body.vegetable with event.fruit and event.vegetable.

As another example, the following Python code invoked with API Gateway returns output in the expected JSON format:

''' Assume the following payload is input: { "fruit": "apple", "vegetable": "carrot" } The expected response is: { "statusCode": 200, "headers": { "Content-type": "application/json" }, "body": { "message": "Your favorite fruit is apple. Your favorite vegetable is carrot." } } ''' import json def lambda_handler(event, context): body = json.loads(event["body"]) message = ("Your favorite fruit is " + body["fruit"] + ". " + "Your favorite vegetable is " + body["vegetable"] + ".") response = { "statusCode": "200", "headers": { "Content-type": "application/json" }, "body": json.dumps({"message": message}) } return response

To invoke the preceding Python code with Lambda, you must remove the line body = json.loads(event["body"]) as well as substitute body["fruit"] and body["vegetable"] with event["fruit"] and event["vegetable"].

Debug the Local Version of a Lambda Function or Its Related API Gateway API

You can debug local Lambda function code or its related API Gateway API in your environment using common debugging aids such as breakpoints, stepping through code, and setting watch expressions.

Note

You cannot debug the remote version of a Lambda function or its related API Gateway API in your environment. You can only invoke it.

You cannot debug local Lambda function code that uses Python.

To debug the local version of an existing Lambda function or its related API Gateway API, you must first import the remote version of the function into your AWS Cloud9 development environment, if the function isn't already there. See Import a Lambda Function.

  1. In the Environment window, open the file that contains the Lambda function's code you want to debug.

  2. Set any breakpoints and watch expressions for your code. See Debug Your Code.

  3. In the Lambda section of the AWS Resources window, expand the Local Functions list, if it isn't already expanded.

  4. Expand the serverless application folder that contains the function you want to debug.

  5. Choose the function to debug, right-click it, and then choose Run, Run Local or Run, Run API Gateway Local.

    Note

    If nothing appears to happen, an invoke tab may already be open for the function. If so, go to the open invoke tab and choose Lambda (local) or API Gateway (local).

  6. For a Lambda function, in the Test payload pane of the invoke tab that is displayed, confirm any custom input data you want your function to use when you test it. For information about the input data format, see Step 2.2: Invoke the Lambda Function Manually and Verify Results, Logs, and Metrics in the AWS Lambda Developer Guide.

  7. For an API Gateway API, in the Test payload pane of the invoke tab that is displayed, confirm the Path, Method, Query String, and Body you want the API to use when you test it.

    Note

    Some APIs might not support settings such as Body. For more information, consult the owner of the API.

  8. Next to the Run button, choose Run in Debug Mode (the bug icon).

  9. Choose the Run button.

  10. Decide what to do whenever function execution pauses at a breakpoint. See Debug Your Code.


            Choose what happens when your function execution pauses at a breakpoint

Change Code in a Lambda Function

To use the AWS Cloud9 IDE to change the code in a function, you must first import the related remote version of the function into your AWS Cloud9 development environment, if the function isn't already there. To do this, see Import a Lambda Function. Then do the following:

  1. In the Lambda section of the AWS Resources window, expand the Local Functions list, if it isn't already expanded.

  2. Expand the serverless application folder that contains the function whose code you want to change.

  3. Right-click the function, and then choose Edit Function.

    
                  Lambda section of the AWS Resources window
  4. Make the changes you want to the code, and then save the file.

To upload the local version of the changed function code to the related remote version in Lambda, see Upload Code for a Lambda Function.

Upload Code for a Lambda Function

To upload the local version of a Lambda function in your environment to the related remote version of the function in Lambda, do the following.

  1. In the Lambda section of the AWS Resources window, expand the Local Functions list, if it isn't already expanded.

  2. Expand the serverless application folder that contains the function you want to upload.

  3. Do one of the following:

    • Right-click the serverless application folder that you just chose, and then choose Deploy.

    • Right-click the function you want to upload, and then choose Deploy.

    • Choose the function you want to upload, and then choose Deploy the selected Lambda function (the button with the arrow that faces up).

    
                  Upload command in the Lambda section of the AWS Resources window

Convert a Lambda Function to a Serverless Application

If the local version of an existing Lambda function in your AWS Cloud9 development environment isn't already part of a serverless application, you can use the AWS Cloud9 IDE to convert that function into a serverless application. You can then use the AWS SAM template file for that serverless application to create additional supporting AWS resources for your function. For more information, see the AWS Serverless Application Model (AWS SAM) repository on GitHub.

To convert the local version of an existing Lambda function into a serverless application, you must first import the remote version of the function into your AWS Cloud9 development environment, if the function isn't already there. See Import a Lambda Function.

  1. In the Lambda section of the AWS Resources window, expand the Local Functions list, if it isn't already expanded.

  2. Right-click the function you want to convert, and then choose Convert to SAM.

    
                  Convert to SAM command in the Lambda section of the AWS Resources window

AWS Cloud9 does the following:

  • In the function's folder in the Environment window, the DeploymentMethod setting in the .application.json file changes from lambda to cloudformation. This means that now AWS Cloud9 will instruct AWS SAM to use AWS CloudFormation whenever you use the IDE to upload the function's code as part of the serverless application. (lambda means that AWS Cloud9 will instruct Lambda to deploy the function instead.) To upload the function code, see Upload Code for a Lambda Function.

  • In the Lambda section of the AWS Resources window, in the Local Functions list, AWS Cloud9 adds the existing Lambda function to a new serverless application (represented by a Lambda icon inside of a folder). The serverless application has the same name as the function.

When you upload the function's code as described in Upload Code for a Lambda Function, because the function upload method is no longer Lambda but now AWS SAM using AWS CloudFormation, AWS Cloud9 creates a new remote version of the function in Lambda and adds it to the Remote Functions list. AWS Cloud9 gives the remote version a name that is different from the original Lambda function. For example, if the serverless application and the function are both named myDemoFunction, the remote version name of your function would be cloud9-myDemoFunction-myDemoFunction-RANDOM_ID, where RANDOM_ID is a randomly determined ID.

Important

After you do the conversion, if you then use the IDE to make any changes to the function code and then upload that code to Lambda, only the remote version of the new function (for example, cloud9-myDemoFunction-myDemoFunction-RANDOM_ID) will contain the change. The remote version of the original function (for example, myDemoFunction) will not change.

If you change your mind and want to enable the IDE to go back to uploading your code changes to the remote version of the original function (for example, myDemoFunction), do the following:

  1. In the function's folder in the Environment window, change the DeploymentMethod setting in the .application.json file from cloudformation back to lambda, and then save the file. This removes the serverless application folder from the Local Functions list and causes AWS Cloud9 to go back to instructing Lambda to deploy the function.

  2. Upload the function code as described in Upload Code for a Lambda Function. Now, only the remote version of the original function (for example, myDemoFunction) will contain the change. The remote version of the new function (for example, cloud9-myDemoFunction-myDemoFunction-RANDOM_ID) will not change.

  3. Because AWS Cloud9 will no longer upload code changes to the remote version of the new function (for example, cloud9-myDemoFunction-myDemoFunction-RANDOM_ID), if you want you can use the Lambda console to delete the new function (for example, cloud9-myDemoFunction-myDemoFunction-RANDOM_ID).

Update Configuration Settings for a Lambda Function

You can use the AWS Cloud9 IDE to change function settings such as the description, handler identifier, amount of memory the function will use, and existing execution role the function will use.

To change configuration settings, you must first import the related remote version of the function into your AWS Cloud9 development environment, if the function isn't already there. To do this, see Import a Lambda Function. Then do the following.

  1. In the Lambda section of the AWS Resources window, expand the Local Functions list, if it isn't already expanded.

  2. Expand the serverless application folder that contains the function whose setting you want to change.

  3. Right-click the function, and then choose Edit Config.

    
                  Update configuration settings for a Lambda function in the Lambda section of the AWS Resources
window
  4. Make changes to the configuration settings, and then save the file.

    Note

    By default, configuration settings are displayed in plain text. To change this behavior to display configuration settings in a visual editor by default, choose AWS Cloud9, Preferences on the menu bar. Choose AWS Settings, and then turn on Use AWS SAM visual editor. To use the visual editor, close the function's template.yaml file, and then right-click the function and choose Edit Config again. To switch back to using plain text by default, turn off the Use AWS SAM visual editor setting. To temporarily edit plain text, choose View with text editor (Ace) in the visual editor, and then choose View, Editors, Ace on the menu bar.

  5. Do one of the following:

    • On the configuration settings tab, in the simplified settings view, choose the Upload Settings to Lambda button.

    • Follow the instructions in Upload Code for a Lambda Function.

    
                  Upload settings to Lambda or upload code for a Lambda function using the configuration settings
tab