
Aws Lambda Functions
- 571 installs
- 305 repo stars
- Updated March 4, 2026
- aj-geddes/useful-ai-prompts
aws-lambda-functions is a Claude Code skill that creates, configures, and invokes AWS Lambda functions with IAM roles, zip deploys, and Node.js handlers for developers who prototype serverless APIs via the AWS CLI.
About
aws-lambda-functions is a useful-ai-prompts skill documenting AWS CLI patterns to stand up Lambda from scratch. It covers creating a lambda-execution-role with sts:AssumeRole for lambda.amazonaws.com, attaching AWSLambdaBasicExecutionRole, zipping index.js into function.zip, and calling aws lambda create-function with a Node.js runtime. Developers reach for this skill when they need repeatable shell commands for IAM plus deployment instead of clicking through the console or writing one-off Terraform for a single function experiment. The excerpts focus on minimal viable Lambda creation and invocation workflows suitable for hack-day APIs or webhook handlers.
- IAM execution role creation with lambda.amazonaws.com trust and AWSLambdaBasicExecutionRole attach
- aws lambda create-function from ZIP with runtime, handler, timeout, memory, and environment Variables
- aws lambda invoke with JSON payload and response file capture
- Node.js handler template parsing API Gateway body JSON and S3 Records event branches
Aws Lambda Functions by the numbers
- 571 all-time installs (skills.sh)
- Ranked #355 of 1,039 Cloud & Infrastructure skills by installs in the Skillselion catalog
- Security screen: LOW risk (skills.sh audit)
- Data as of Aug 5, 2026 (Skillselion catalog sync)
npx skills add https://github.com/aj-geddes/useful-ai-prompts --skill aws-lambda-functionsAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 571 |
|---|---|
| repo stars | ★ 305 |
| Security audit | 3 / 3 scanners passed |
| Last updated | March 4, 2026 |
| Repository | aj-geddes/useful-ai-prompts ↗ |
How do you deploy AWS Lambda with the CLI?
Create, configure, and invoke AWS Lambda functions with IAM roles, zip deploys, and Node.js handlers using AWS CLI patterns.
Who is it for?
Backend developers spinning up a first AWS Lambda with CLI commands who already know Node.js handlers and want copy-paste IAM plus zip deploy steps.
Skip if: Teams standardizing on SAM, CDK, or Terraform multi-environment pipelines instead of manual aws CLI function bootstrapping.
When should I use this skill?
The user wants to create, configure, or invoke AWS Lambda with IAM roles and zip deploys using AWS CLI and Node.js.
What you get
IAM execution role, zipped deployment package, and a created Node.js Lambda function ready to invoke.
- IAM execution role
- Zipped Lambda deployment package
- Deployed Lambda function
Files
AWS Lambda Functions
Table of Contents
Overview
AWS Lambda enables you to run code without provisioning or managing servers. Build serverless applications using event-driven triggers, pay only for compute time consumed, and scale automatically with workload.
When to Use
- API endpoints and webhooks
- Scheduled batch jobs and data processing
- Real-time file processing (S3 uploads)
- Event-driven workflows (SNS, SQS)
- Microservices and backend APIs
- Data transformations and ETL jobs
- IoT and sensor data processing
- WebSocket connections
Quick Start
Minimal working example:
# Create Lambda execution role
aws iam create-role \
--role-name lambda-execution-role \
--assume-role-policy-document '{
"Version": "2012-10-17",
"Statement": [{
"Effect": "Allow",
"Principal": {"Service": "lambda.amazonaws.com"},
"Action": "sts:AssumeRole"
}]
}'
# Attach basic execution policy
aws iam attach-role-policy \
--role-name lambda-execution-role \
--policy-arn arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
# Create function from ZIP
zip function.zip index.js
aws lambda create-function \
--function-name my-function \
--runtime nodejs18.x \
--role arn:aws:iam::ACCOUNT:role/lambda-execution-role \
--handler index.handler \
--zip-file fileb://function.zip \
// ... (see reference guides for full implementation)Reference Guides
Detailed implementations in the references/ directory:
| Guide | Contents |
|---|---|
| Basic Lambda Function with AWS CLI | Basic Lambda Function with AWS CLI |
| Lambda Function with Node.js | Lambda Function with Node.js |
| Terraform Lambda Deployment | Terraform Lambda Deployment |
| Lambda with SAM (Serverless Application Model) | Lambda with SAM (Serverless Application Model) |
| Lambda Layers for Code Sharing | Lambda Layers for Code Sharing |
Best Practices
✅ DO
- Use environment variables for configuration
- Implement proper error handling and logging
- Optimize package size and dependencies
- Set appropriate timeout and memory
- Use Lambda Layers for shared code
- Implement concurrency limits
- Enable X-Ray tracing for debugging
- Use reserved concurrency for critical functions
❌ DON'T
- Store sensitive data in code
- Create long-running operations (>15 min)
- Ignore cold start optimization
- Forget to handle concurrent executions
- Ignore CloudWatch metrics
- Use too much memory unnecessarily
Basic Lambda Function with AWS CLI
Basic Lambda Function with AWS CLI
# Create Lambda execution role
aws iam create-role \
--role-name lambda-execution-role \
--assume-role-policy-document '{
"Version": "2012-10-17",
"Statement": [{
"Effect": "Allow",
"Principal": {"Service": "lambda.amazonaws.com"},
"Action": "sts:AssumeRole"
}]
}'
# Attach basic execution policy
aws iam attach-role-policy \
--role-name lambda-execution-role \
--policy-arn arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
# Create function from ZIP
zip function.zip index.js
aws lambda create-function \
--function-name my-function \
--runtime nodejs18.x \
--role arn:aws:iam::ACCOUNT:role/lambda-execution-role \
--handler index.handler \
--zip-file fileb://function.zip \
--timeout 30 \
--memory-size 256 \
--environment Variables={ENV=production,DB_HOST=db.example.com}
# Invoke function
aws lambda invoke \
--function-name my-function \
--payload '{"name":"John","age":30}' \
response.jsonLambda Function with Node.js
Lambda Function with Node.js
// index.js
exports.handler = async (event) => {
console.log("Event:", JSON.stringify(event));
try {
// Parse different event sources
const body =
typeof event.body === "string"
? JSON.parse(event.body)
: event.body || {};
// Process S3 event
if (event.Records && event.Records[0].s3) {
const bucket = event.Records[0].s3.bucket.name;
const key = event.Records[0].s3.object.key;
console.log(`Processing S3 object: ${bucket}/${key}`);
}
// Database query simulation
const results = await queryDatabase(body);
return {
statusCode: 200,
headers: {
"Content-Type": "application/json",
"Access-Control-Allow-Origin": "*",
},
body: JSON.stringify({
message: "Success",
data: results,
}),
};
} catch (error) {
console.error("Error:", error);
return {
statusCode: 500,
body: JSON.stringify({ error: error.message }),
};
}
};
async function queryDatabase(params) {
// Simulate database call
return { items: [] };
}Lambda Layers for Code Sharing
Lambda Layers for Code Sharing
# Create layer directory structure
mkdir -p layer/nodejs/node_modules
cd layer/nodejs
# Install dependencies
npm install lodash axios moment
# Go back and create zip
cd ..
zip -r layer.zip .
# Upload layer
aws lambda publish-layer-version \
--layer-name shared-utils \
--zip-file fileb://layer.zip \
--compatible-runtimes nodejs18.xLambda with SAM (Serverless Application Model)
Lambda with SAM (Serverless Application Model)
# template.yaml
AWSTemplateFormatVersion: "2010-09-09"
Transform: AWS::Serverless-2016-10-31
Globals:
Function:
Timeout: 30
MemorySize: 256
Runtime: nodejs18.x
Tracing: Active
Parameters:
Environment:
Type: String
Default: dev
AllowedValues: [dev, prod]
Resources:
# Lambda function
MyFunction:
Type: AWS::Serverless::Function
Properties:
FunctionName: !Sub "${Environment}-my-function"
CodeUri: src/
Handler: index.handler
Architectures:
- x86_64
Environment:
Variables:
STAGE: !Ref Environment
Policies:
- DynamoDBCrudPolicy:
TableName: !Ref DataTable
- S3CrudPolicy:
BucketName: !Ref DataBucket
Events:
ApiEvent:
Type: Api
Properties:
Path: /api/{proxy+}
Method: ANY
RestApiId: !Ref MyApi
S3Upload:
Type: S3
Properties:
Bucket: !Ref DataBucket
Events: s3:ObjectCreated:*
Filter:
S3Key:
Rules:
- Name: prefix
Value: uploads/
# DynamoDB table
DataTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: !Sub "${Environment}-data"
BillingMode: PAY_PER_REQUEST
AttributeDefinitions:
- AttributeName: id
AttributeType: S
KeySchema:
- AttributeName: id
KeyType: HASH
# S3 bucket
DataBucket:
Type: AWS::S3::Bucket
Properties:
BucketName: !Sub "${Environment}-data-${AWS::AccountId}"
VersioningConfiguration:
Status: Enabled
# API Gateway
MyApi:
Type: AWS::Serverless::Api
Properties:
Name: !Sub "${Environment}-api"
StageName: !Ref Environment
Cors:
AllowMethods: "'*'"
AllowHeaders: "'Content-Type,Authorization'"
AllowOrigin: "'*'"
Outputs:
FunctionArn:
Value: !GetAtt MyFunction.Arn
ApiEndpoint:
Value: !Sub "https://${MyApi}.execute-api.${AWS::Region}.amazonaws.com"Terraform Lambda Deployment
Terraform Lambda Deployment
# main.tf
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 5.0"
}
}
}
provider "aws" {
region = var.aws_region
}
# Lambda execution role
resource "aws_iam_role" "lambda_role" {
name = "lambda-execution-role"
assume_role_policy = jsonencode({
Version = "2012-10-17"
Statement = [{
Action = "sts:AssumeRole"
Effect = "Allow"
Principal = {
Service = "lambda.amazonaws.com"
}
}]
})
}
# CloudWatch Logs policy
resource "aws_iam_role_policy_attachment" "lambda_logs" {
role = aws_iam_role.lambda_role.name
policy_arn = "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
}
# S3 Lambda Layer (dependencies)
resource "aws_lambda_layer_version" "dependencies" {
filename = "layer.zip"
layer_name = "nodejs-dependencies"
compatible_runtimes = ["nodejs18.x"]
}
# Lambda function
resource "aws_lambda_function" "api_handler" {
filename = "lambda.zip"
function_name = "api-handler"
role = aws_iam_role.lambda_role.arn
handler = "index.handler"
runtime = "nodejs18.x"
timeout = 30
memory_size = 256
layers = [aws_lambda_layer_version.dependencies.arn]
environment {
variables = {
STAGE = "production"
DB_HOST = var.database_host
}
}
depends_on = [aws_iam_role_policy_attachment.lambda_logs]
}
# API Gateway trigger
resource "aws_lambda_permission" "api_gateway" {
statement_id = "AllowAPIGatewayInvoke"
action = "lambda:InvokeFunction"
function_name = aws_lambda_function.api_handler.function_name
principal = "apigateway.amazonaws.com"
}
# S3 trigger
resource "aws_lambda_permission" "s3_trigger" {
statement_id = "AllowS3Invoke"
action = "lambda:InvokeFunction"
function_name = aws_lambda_function.api_handler.function_name
principal = "s3.amazonaws.com"
source_arn = aws_s3_bucket.upload_bucket.arn
}
resource "aws_s3_bucket_notification" "bucket_notification" {
bucket = aws_s3_bucket.upload_bucket.id
depends_on = [aws_lambda_permission.s3_trigger]
lambda_function {
lambda_function_arn = aws_lambda_function.api_handler.arn
events = ["s3:ObjectCreated:*"]
filter_prefix = "uploads/"
filter_suffix = ".jpg"
}
}#!/bin/bash
# validate-api.sh - Validate API specification
# Usage: ./validate-api.sh <openapi_spec>
set -euo pipefail
SPEC_FILE="${{1:?Usage: $0 <openapi_spec>}}"
echo "Validating API spec: $SPEC_FILE"
# TODO: Add API validation
# - Validate OpenAPI/Swagger syntax
# - Check endpoint naming conventions
# - Verify response schemas
# - Check for required headers
# - Validate authentication definitions
echo "API validation complete."
# API Endpoint Scaffold
# TODO: Customize for your API framework
openapi: "3.0.3"
info:
title: "API Service"
version: "1.0.0"
paths:
/api/v1/resource:
get:
summary: "List resources"
# TODO: Define parameters and responses
responses:
"200":
description: "Success"
post:
summary: "Create resource"
# TODO: Define request body and responses
responses:
"201":
description: "Created"
Related skills
How it compares
Use aws-lambda-functions for quick CLI bootstrap; adopt IaC skills when functions must be reproducible across staging and production accounts.
FAQ
Which IAM policy does aws-lambda-functions attach?
aws-lambda-functions attaches arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole to a lambda-execution-role created with a lambda.amazonaws.com sts:AssumeRole trust policy via aws iam CLI commands.
How does aws-lambda-functions package code?
aws-lambda-functions zips index.js into function.zip, then calls aws lambda create-function with the Node.js runtime, following the repository’s basic Lambda CLI walkthrough for first deploys.
Is Aws Lambda Functions safe to install?
skills.sh reports 3 of 3 security scanners passed. Review the Security Audits panel on this page before installing in production.