AWS toolkit-for-vscode documentation change
Summary
Expanded documentation for working with Lambda functions in VS Code, including new sections on prerequisites, invoking, deleting, downloading, deploying, and uploading functions. Added IAM permission requirements and warnings about code validation.
Security assessment
The changes add documentation about required IAM permissions and policies for Lambda access (security best practice) and warn users to validate code before uploading to production (security hygiene). However, there is no evidence these changes address a specific disclosed vulnerability or incident.
Diff
diff --git a/toolkit-for-vscode/latest/userguide/remote-lambda.md b/toolkit-for-vscode/latest/userguide/remote-lambda.md index b219ce3dc..939d4c15a 100644 --- a//toolkit-for-vscode/latest/userguide/remote-lambda.md +++ b//toolkit-for-vscode/latest/userguide/remote-lambda.md @@ -5 +5 @@ -PrerequisitesInvoke a Lambda FunctionDelete a Lambda FunctionImport a Lambda FunctionUpload a Lambda Function +PrerequisitesInvoking a Lambda FunctionDeleting a Lambda functionDownloading a Lambda functionDeploying updates for new Lambda functionsUploading updates for existing Lambda functionsConverting your Lambda function to an AWS SAM project @@ -7 +7 @@ PrerequisitesInvoke a Lambda FunctionDelete a Lambda FunctionImport a Lambda Fun -# Interacting with Remote Lambda Functions +# Working with AWS Lambda Functions @@ -9 +9 @@ PrerequisitesInvoke a Lambda FunctionDelete a Lambda FunctionImport a Lambda Fun -Using the Toolkit for VS Code, you can interact with [AWS Lambda](https://aws.amazon.com/lambda/) functions in various ways, as described later in this topic. +The AWS Toolkit for Visual Studio Code allows you to work with your AWS Lambda functions in your local VS Code environment. With the AWS Toolkit, you can create, edit, test, debug, and deploy your Lambda functions, without having to leave the IDE. For detailed information about the AWS Lambda service, see the [AWS Lambda](https://docs.aws.amazon.com/lambda/latest/dg/welcome.html) Developer Guide. @@ -11 +11 @@ Using the Toolkit for VS Code, you can interact with [AWS Lambda](https://aws.am -For more information about Lambda, see the [AWS Lambda Developer Guide](https://docs.aws.amazon.com/lambda/latest/dg/). +The following sections describe how to get started working with Lambda functions in the AWS Toolkit for Visual Studio Code. @@ -15 +15 @@ For more information about Lambda, see the [AWS Lambda Developer Guide](https:// -If you have already created Lambda functions by using the AWS Management Console or in some other way, you can invoke them from the Toolkit. To create a new function (using VS Code) that you can deploy to AWS Lambda, you must first [create a serverless application](./sam-get-started.html#serverless-apps-create). +If you have already created Lambda functions by using the AWS Management Console, then you can invoke them from the Toolkit. Additionally, you can open your Lambda functions into VS Code from the AWS Lambda console, for additional information, see the [AWS Lambda console to IDE](https://docs.aws.amazon.com/lambda-console-ide) topic in this user guide. To create a new Lambda function in VS Code, follow the steps outlined in the [Creating a new serverless application (local)](https://docs.aws.amazon.com/toolkit-for-vscode/latest/userguide/sam-get-started.html#serverless-apps-create) topic in this user guide. @@ -17 +17 @@ If you have already created Lambda functions by using the AWS Management Console -###### Topics +## Prerequisites @@ -19 +19 @@ If you have already created Lambda functions by using the AWS Management Console - * Prerequisites +The following conditions must be met to work with the AWS Lambda service in the AWS Toolkit. @@ -21 +21 @@ If you have already created Lambda functions by using the AWS Management Console - * Invoke a Lambda Function + * The latest version of the AWS Toolkit for Visual Studio Code is installed and set up with your AWS credentials. @@ -23 +23 @@ If you have already created Lambda functions by using the AWS Management Console - * Delete a Lambda Function + * Your AWS Identity and Access Management (IAM) managed permissions and policies are configured to work with the AWS Lambda service. For detailed information on how to configure your permissions and create a compatible AWS managed policy, see the [AWS Identity and Access Management for AWS Lambda](https://docs.aws.amazon.com/https://docs.aws.amazon.com/lambda/latest/dg/security-iam.html) topic in the _AWS Lambda Developer Guide_. @@ -25 +25 @@ If you have already created Lambda functions by using the AWS Management Console - * Import a Lambda Function + * You have existing AWS Lambda functions or are familiar with how to create one. For instructions on how to create a Lambda function, see the [Create your first Lambda function](https://docs.aws.amazon.com/https://docs.aws.amazon.com/lambda/latest/dg/getting-started.html) topic in the _AWS Lambda Developer Guide_. @@ -27 +26,0 @@ If you have already created Lambda functions by using the AWS Management Console - * Upload a Lambda Function @@ -30,0 +30 @@ If you have already created Lambda functions by using the AWS Management Console +## Invoking a Lambda Function @@ -32 +32 @@ If you have already created Lambda functions by using the AWS Management Console -## Prerequisites +To invoke a Lambda function from your AWS account into VS Code, complete the following steps. @@ -34 +34 @@ If you have already created Lambda functions by using the AWS Management Console - * Be sure your system meets the the prerequisites specified in [Installing the Toolkit for VS Code](./setup-toolkit.html#setup-prereq). + 1. From the AWS Toolkit for Visual Studio Code, expand the AWS explorer. @@ -36 +36 @@ If you have already created Lambda functions by using the AWS Management Console - * Ensure that the credentials you configured in [Authentication and access](./establish-credentials.html) include appropriate read/write access to the AWS Lambda service. If in the **AWS Explorer** , under **Lambda** , you see a message similar to "Error loading Lambda resources", check the permissions attached to those credentials. Changes that you make to permissions will take a few minutes to affect the **AWS Explorer** in VS Code. + 2. From the AWS explorer, expand **Lambda** to view your Lambda resources. @@ -37,0 +38 @@ If you have already created Lambda functions by using the AWS Management Console + 3. Open the context menu for (right-click) the Lambda function your want to invoke, then choose **Invoke in the cloud** or choose the **Invoke in the cloud** icon to open the **Remote invoke configuration** menu in VS Code. @@ -38,0 +40,3 @@ If you have already created Lambda functions by using the AWS Management Console + 4. From the **Remote invoke configuration** menu, specify your **Payload** settings and add any additional information that is required for the event. + +###### Note @@ -39,0 +44 @@ If you have already created Lambda functions by using the AWS Management Console +The first invoke process may start running as soon as you choose **Invoke in the cloud** in the AWS explorer. The output is displayed in the **OUTPUT** tab of the VS Code terminal. @@ -41 +46 @@ If you have already created Lambda functions by using the AWS Management Console -## Invoke a Lambda Function + 5. Choose the **Remote Invoke** button to invoke your function, The output is displayed in the **OUTPUT** tab of the VS Code terminal. @@ -43 +47,0 @@ If you have already created Lambda functions by using the AWS Management Console -You can invoke a Lambda function on AWS from the Toolkit for VS Code. @@ -45 +48,0 @@ You can invoke a Lambda function on AWS from the Toolkit for VS Code. -###### @@ -47 +49,0 @@ You can invoke a Lambda function on AWS from the Toolkit for VS Code. - 1. In the **AWS Explorer** , choose the name of the Lambda function you want to invoke, and then open its context menu. @@ -49 +51 @@ You can invoke a Lambda function on AWS from the Toolkit for VS Code. - +## Deleting a Lambda function @@ -51 +53 @@ You can invoke a Lambda function on AWS from the Toolkit for VS Code. - 2. Choose **Invoke on AWS**. +To delete a Lambda function, complete the following procedure. @@ -53 +55 @@ You can invoke a Lambda function on AWS from the Toolkit for VS Code. - 3. In the invoke window that opens, enter the input that your Lambda function needs. The Lambda function might, for example, require a string as an input, as shown in the text box. +###### Warning @@ -55 +57 @@ You can invoke a Lambda function on AWS from the Toolkit for VS Code. - +Do not use this procedure to delete Lambda functions that are associated with [AWS CloudFormation](https://docs.aws.amazon.com/cloudformation/). These functions must be deleted through your AWS CloudFormation stack. @@ -56,0 +59 @@ You can invoke a Lambda function on AWS from the Toolkit for VS Code. + 1. From the AWS Toolkit for Visual Studio Code, expand the AWS explorer. @@ -57,0 +61 @@ You can invoke a Lambda function on AWS from the Toolkit for VS Code. + 2. From the AWS explorer, expand **Lambda** to view your Lambda resources. @@ -58,0 +63 @@ You can invoke a Lambda function on AWS from the Toolkit for VS Code. + 3. Right-click the Lambda function your want to delete, then choose **Delete**. @@ -60 +65 @@ You can invoke a Lambda function on AWS from the Toolkit for VS Code. -You'll see the output of the Lambda function just like you would for any other project using VS Code. + 4. When prompted, confirm that you want to delete your function. @@ -62 +66,0 @@ You'll see the output of the Lambda function just like you would for any other p - @@ -64 +67,0 @@ You'll see the output of the Lambda function just like you would for any other p -## Delete a Lambda Function @@ -66 +68,0 @@ You'll see the output of the Lambda function just like you would for any other p -You can also delete a Lambda function using the same context menu. @@ -68 +70 @@ You can also delete a Lambda function using the same context menu. -###### Warning +After the function is deleted, it's no longer listed in the AWS explorer. @@ -70 +72 @@ You can also delete a Lambda function using the same context menu. -Do not use this procedure to delete Lambda functions that are associated with [AWS CloudFormation](https://docs.aws.amazon.com/cloudformation/) (for example, the Lambda function that was created when [creating a serverless application](./sam-get-started.html#serverless-apps-create) earlier in this guide). These functions must be deleted through the AWS CloudFormation stack. +## Downloading a Lambda function @@ -72 +74 @@ Do not use this procedure to delete Lambda functions that are associated with [A -###### +You can download code from a remote Lambda function into your VS Code workspace for editing and debugging. @@ -74 +76 @@ Do not use this procedure to delete Lambda functions that are associated with [A - 1. In the **AWS Explorer** , choose the name of the Lambda function you want to delete, and then open its context menu. +###### Note @@ -76 +78 @@ Do not use this procedure to delete Lambda functions that are associated with [A - +To download your Lambda function, you must be working in a VS Code workspace with an accessible folder and the AWS Toolkit only supports this feature with Lambda functions using Node.js and Python runtimes. @@ -78 +80 @@ Do not use this procedure to delete Lambda functions that are associated with [A - 2. Choose **Delete**. + 1. From the AWS Toolkit for Visual Studio Code, expand the AWS explorer. @@ -80 +82 @@ Do not use this procedure to delete Lambda functions that are associated with [A - 3. In the message that appears, choose **Yes** to confirm the delete. + 2. From the AWS explorer, expand **Lambda** to view your Lambda resources. @@ -82 +84 @@ Do not use this procedure to delete Lambda functions that are associated with [A - + 3. Right-click the Lambda function your want to download, then choose **Download**. @@ -83,0 +86 @@ Do not use this procedure to delete Lambda functions that are associated with [A + 4. Your Lambda function opens in the VS Code editor and displays in the AWS explorer when the download is complete. The AWS Toolkit also creates a _launch configuration_ in the VS Code run panel allowing you to run and debug the Lambda function locally with AWS Serverless Application Model. For more information about using AWS SAM, see [Running and debugging a serverless application from template (local)](./sam-get-started.html#serverless-apps-debug). @@ -87 +89,0 @@ Do not use this procedure to delete Lambda functions that are associated with [A -After the function is deleted, it's no longer listed in the **AWS Explorer**. @@ -89 +91 @@ After the function is deleted, it's no longer listed in the **AWS Explorer**. -## Import a Lambda Function +## Deploying updates for new Lambda functions @@ -91 +93 @@ After the function is deleted, it's no longer listed in the **AWS Explorer**. -You can import code from a remote Lambda funcion into your VS Code workspace for editing and debugging. +You can deploy updates to new Lambda functions from an unspecified, temporary location on your local machine. @@ -95 +97,14 @@ You can import code from a remote Lambda funcion into your VS Code workspace for -The toolkit only supports importing Lambda functions using supported Node.js and Python runtimes. +When there are un-deployed changes to your lambda files, you're notified by the **M** icon located next to the modified files in the VS Code editor and in the AWS explorer. + +###### Deploying from the VS Code editor + + 1. Open a file from your Lambda function in the VS Code editor, then make a change to the file. + + 2. Manually save from the VS Code main menu or pressing `option+s` (Mac) `ctrl+s` (Windows). + + 3. VS Code automatically prompts you about deploying your changes to the cloud, choose the **Deploy** button to confirm the deployment. + + 4. VS Code updates you on the status of your deployment and notifies you when the process is complete. + + + @@ -97 +112 @@ The toolkit only supports importing Lambda functions using supported Node.js and - 1. In the **AWS Explorer** , choose the name of the Lambda function you want to import, then open its context menu. +###### Deploying from the AWS Explorer @@ -99 +114 @@ The toolkit only supports importing Lambda functions using supported Node.js and - 2. Choose **Import...** + 1. Open a file from your Lambda function in the VS Code editor, then make a change to the file. @@ -101 +116 @@ The toolkit only supports importing Lambda functions using supported Node.js and - 3. Choose a folder to import the Lambda code to. Folders outside the current workspace will be added to your current workspace. + 2. From the AWS Toolkit, expand the AWS explorer. @@ -103 +118 @@ The toolkit only supports importing Lambda functions using supported Node.js and - 4. After download, the Toolkit adds the code to your workspace and opens the file containing the Lambda handler code. The Toolkit also creates a _launch configuration_ , which appears in the VS Code run panel so you can locally run and debug the Lambda function using AWS Serverless Application Model. For more information about using AWS SAM, see [Running and debugging a serverless application from template (local)](./sam-get-started.html#serverless-apps-debug). + 3. From the AWS explorer, expand the AWS region with the Lambda function that you want to deploy changes for. @@ -104,0 +120 @@ The toolkit only supports importing Lambda functions using supported Node.js and + 4. From the AWS region, expand Lambda and navigate the function that you want to deploy changes for. @@ -105,0 +122 @@ The toolkit only supports importing Lambda functions using supported Node.js and + 5. From the quick menu next to your function, choose the **Save and deploy your code** icon. @@ -106,0 +124 @@ The toolkit only supports importing Lambda functions using supported Node.js and + 6. VS Code updates you on the status of your deployment and notifies you when the process is complete. @@ -108 +125,0 @@ The toolkit only supports importing Lambda functions using supported Node.js and -## Upload a Lambda Function @@ -110 +127,5 @@ The toolkit only supports importing Lambda functions using supported Node.js and -You can update existing Lambda functions with local code. Updating code in this way does not use the AWS SAM CLI for deployment and does not create an AWS CloudFormation stack. This functionality can upload a Lambda function with any runtime supported by Lambda. + + +## Uploading updates for existing Lambda functions + +The following procedures describe how to upload local changes made to your existing Lambda functions. This feature supports uploads with any Lambda supported runtime. @@ -114 +135,22 @@ You can update existing Lambda functions with local code. Updating code in this -The toolkit can't check whether your code works. Make sure the code works before updating production Lambda functions. +Before uploading your lambda function, be aware of the following: + + * Updating code in this way doesn't use the AWS SAM CLI for deployment or create an AWS CloudFormation stack + + * The AWS Toolkit doesn't validate code. Validate your code and test your function(s) before uploading any changes to the cloud. + + + + +###### Uploading a Zip Archive + + 1. From the AWS Toolkit for Visual Studio Code, expand the AWS explorer. + + 2. From the AWS explorer, expand **Lambda** to view your Lambda resources. + + 3. Right-click the Lambda function your want to upload your changes to, then choose **Upload Lambda...** to open the **Select Upload Type** menu. + + 4. Choose **ZIP Archive** to locate the `ZIP Archive` in your local directory. + + 5. When prompted, confirm the upload to start the upload of the selected `ZIP Archive`. + + 6. The status of your upload is displayed in VS Code and you're notified when the upload process is complete. @@ -116 +157,0 @@ The toolkit can't check whether your code works. Make sure the code works before - 1. In the **AWS Explorer** , choose the name of the Lambda function you want to import, then open its context menu. @@ -118 +158,0 @@ The toolkit can't check whether your code works. Make sure the code works before - 2. Choose **Upload Lambda...** @@ -120 +159,0 @@ The toolkit can't check whether your code works. Make sure the code works before - 3. Choose from the three options for uploading your Lambda function. The options include: @@ -122 +161 @@ The toolkit can't check whether your code works. Make sure the code works before -###### Upload a premade .zip archive