Skip to content
| Marketplace
Sign in
Visual Studio Code>Snippets>AWS Serverless SnippetsNew to Visual Studio Code? Get it now.
AWS Serverless Snippets

AWS Serverless Snippets

None Group

|
25 installs
| (0) | Free
Code snippets for AWS serverless development with Express, DynamoDB, and S3
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

AWS Serverless Snippets

A collection of code snippets for AWS serverless development with Express, DynamoDB, and S3. This extension provides ready-to-use code snippets to accelerate your serverless application development using AWS services.

Features

  • Express Setup: Quickly set up an Express application with AWS SDK v3 configuration
  • DynamoDB Operations: Create, read, update, and delete items in DynamoDB tables
  • S3 File Management: Upload and delete files from S3 buckets
  • Express Routes: Ready-to-use route handlers for CRUD operations
  • EJS Templates: HTML templates for creating forms and displaying data

Installation

  1. Open VS Code
  2. Go to Extensions (Ctrl+Shift+X)
  3. Search for "AWS Serverless Snippets"
  4. Click Install

Usage

Type the prefix in a JavaScript file and press Tab to insert the snippet.

AWS Configuration Snippets

Prefix Description
aws-express Express app setup with AWS SDK v3 configuration
aws-env Environment variables template for AWS serverless app

S3 Snippets

Prefix Description
aws-multer Multer configuration for S3 image upload
aws-s3-upload Upload file to AWS S3 bucket with SDK v3
aws-s3-delete Delete file from AWS S3 bucket with SDK v3

DynamoDB Snippets

Prefix Description
aws-dynamo-create Create item in DynamoDB with SDK v3
aws-dynamo-scan Scan all items from DynamoDB with SDK v3
aws-dynamo-get Get item by ID from DynamoDB with SDK v3
aws-dynamo-update Update item in DynamoDB with SDK v3
aws-dynamo-delete Delete items from DynamoDB with S3 cleanup

Express Route Snippets

Prefix Description
aws-route-create Express route to create item with S3 image upload
aws-route-getall Express route to get all items from DynamoDB
aws-route-getone Express route to get item by ID from DynamoDB
aws-route-update Express route to update item with S3 image handling
aws-route-delete Express route to delete items from DynamoDB and S3
aws-route-editform Express route to render edit form for DynamoDB item

EJS Template Snippets

Prefix Description
aws-ejs-layout Basic EJS layout template with CSS and JS links
aws-ejs-create EJS form for creating items with file upload
aws-ejs-edit EJS form for updating items with current image display
aws-ejs-list EJS table for displaying and managing items list
aws-create-ejs-option Form for creating items with category dropdown
aws-edit-ejs-option EJS form for editing items with selected category

Requirements

  • Visual Studio Code 1.98.0 or higher
  • For using the snippets in your project, you'll need:
    • Node.js and npm
    • AWS account with appropriate permissions
    • AWS SDK v3 for JavaScript

Example

To create a basic Express app with AWS configuration:

  1. Create a new JavaScript file
  2. Type aws-express and press Tab
  3. The boilerplate code will be inserted

Dependencies

The snippets assume you have the following npm packages installed in your project:

npm install express dotenv path multer uuid
npm install @aws-sdk/client-dynamodb @aws-sdk/lib-dynamodb @aws-sdk/client-s3

Initial release of AWS Serverless Snippets with support for:

  • Express setup with AWS SDK v3
  • DynamoDB CRUD operations
  • S3 file upload and deletion
  • Express routes for CRUD operations
  • EJS templates for forms and data display

Enjoy!

Sample code snippets for AWS serverless development with Express, DynamoDB, and S3. This extension provides ready-to-use code snippets to accelerate your serverless application development using AWS services.

🧩 Snippet: aws-dynamo-update

Update item in DynamoDB using AWS SDK v3 with UpdateExpression and ExpressionAttributeValues.

Prefix: aws-dynamo-update

async function updateItem(id, updateExpression, expressionValues) {
  const command = new UpdateCommand({
    TableName: process.env.DYNAMO_TABLE_NAME,
    Key: { id },
    UpdateExpression: updateExpression,
    ExpressionAttributeValues: expressionValues,
    ReturnValues: "ALL_NEW",
  });

  const result = await documentClient.send(command);
  return result.Attributes;
}

await updateItem("user123", "SET name = :name, description = :desc", {
  ":name": "Name",
  ":desc": "Description",
});

Guide to Deploy a Node.js Project on EC2

1. Configure Security Group

After launching the EC2 instance, make sure to configure the Security Group:

  • For SSH, open the appropriate IP (e.g., your local IP) to allow access.

2. Copy Code Directory from Local to EC2

  • Remove the node_modules and .git folders from your code directory before uploading.
scp -i ./path/key.pem -r code_folder ubuntu@public_ip:/home/ubuntu/

Note: You must have the .pem key file to perform this copy operation.

3. Set Up Environment on Ubuntu EC2

After successfully transferring the code files to your EC2 Ubuntu instance, follow these steps:

sudo apt update -y
sudo apt install nodejs npm -y

4. Run the Project

cd path/to/your/code_folder
npm install
npm start

Tip: Make sure your application listens on 0.0.0.0 or your public IP so it can be accessed externally.


  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft