Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The quickest first run is the Lambda console: create a function from scratch, choose a current Python runtime, let AWS create an execution role, and run the generated test event. For a repeatable, programmatic deployment, put lambda_function.py at the root of a ZIP archive and call aws lambda create-function with the runtime, handler, ZIP location, and execution-role ARN.

Create and test it in the AWS console

  1. Open the Lambda console and choose Create function.
  2. Select Author from scratch, enter a function name such as hello-world, and select a currently supported Python runtime. AWS’s current Python walkthrough uses Python 3.14; runtime support changes, so confirm the version in the guide when you publish.
  3. Under permissions, create or select an execution role. This IAM role is assumed by the function when it accesses AWS services; it is different from the identity you use to sign in or run the CLI.
  4. Choose Create function. AWS creates a basic Python function with a lambda_function source module.
  5. Edit the code if needed and choose Deploy. Create a test event, select that event, and choose Test. Inspect the returned payload and the function’s logs.

Creating the function only provisions it. A separate test or invocation is what proves that the handler executed.

Programmatically create the function with the AWS CLI

1. Write the handler

Create a file named lambda_function.py:

def lambda_handler(event, context):
    return {
        "statusCode": 200,
        "body": "Hello World"
    }

The handler setting combines the Python module name and callable name: lambda_function.lambda_handler. If you rename either the file or function, change the handler value to match.

2. Build the ZIP with the correct root layout

From the directory containing the file, run:

zip function.zip lambda_function.py

The archive should contain lambda_function.py at its top level, not inside an enclosing project directory. With dependencies, install them into the same archive root or use a Lambda layer. AWS explains the layout and packaging rules in Working with .zip file archives for Python Lambda functions.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.

3. Create the Lambda function

With AWS CLI credentials configured, substitute your real account ID and role name in this command:

aws lambda create-function 
  --function-name hello-world 
  --runtime python3.14 
  --handler lambda_function.lambda_handler 
  --role arn:aws:iam::ACCOUNT_ID:role/ROLE_NAME 
  --zip-file fileb://function.zip

The ZIP package, runtime, handler, and execution role are required inputs for this form of create-function; see the AWS CLI reference. The CLI identity must be allowed to create Lambda functions and pass the specified role. Do not replace the role with broad administrator access merely to make the command succeed.

Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.

Use a runtime that AWS currently supports in your Region. The AWS Python guide lists Python 3.13 deprecation on June 30, 2029, create blocking on July 31, 2029, and update blocking on August 31, 2029; for Python 3.12 it lists October 31, November 30, 2028, and January 10, 2029 respectively. Verify the current runtime table before choosing a version.

Invoke the function after creation

Provisioning is not an invocation. Run a test separately, either with the console’s test event or with the CLI:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
aws lambda invoke 
  --function-name hello-world 
  --payload '{"name":"reader"}' 
  response.json

cat response.json

Depending on your AWS CLI version and shell, you may need to encode the payload as base64 or use the CLI’s raw-in-base64-out option. A successful response should contain the JSON returned by lambda_handler. For execution details and errors, inspect the function’s CloudWatch Logs group.

Choose the packaging and deployment route

Route Best for What you must provide Trade-off
Lambda console A quick first function and interactive test Function name, supported runtime, and an execution role Lowest setup overhead, but changes are less repeatable
AWS CLI An explicit scripted creation operation Credentials, permission to pass the role, ZIP archive, runtime, handler, and role ARN Repeatable commands, but every input must be correct
AWS SAM or CloudFormation Team deployments and infrastructure in source control A YAML or JSON template plus the SAM or CloudFormation workflow Most repeatable, with more initial tooling and template setup

ZIP-based deployment is appropriate for this no-dependency example. AWS also supports container-image packages, but an image build and registry workflow add unnecessary complexity for a single Hello World function.

Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft

ZIP size and S3 rules

  • A ZIP deployment package has a 250 MB maximum unzipped size, including layers.
  • A local ZIP can be uploaded directly when it is below 50 MB; larger packages should be uploaded to Amazon S3.
  • For an S3-based CLI upload, the S3 bucket must be in the same AWS Region as the Lambda function.

These limits and upload choices are documented in AWS’s Python packaging guide and ZIP deployment guide. A dependency-free Hello World file is far below both limits.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshoot the common failures

“Unable to import module” or handler not found

  • Confirm the archive root contains lambda_function.py, rather than project/lambda_function.py.
  • Confirm the configured handler is exactly lambda_function.lambda_handler.
  • Check capitalization and spelling; module and function names are case-sensitive.
  • If you added dependencies, verify they were installed into the ZIP root or supplied through a compatible layer.

Role or permission errors during creation

Check that the role ARN exists, trusts the Lambda service, and that the CLI identity can pass it. The role controls the function’s access to AWS services; add only the service permissions the function actually needs.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.

The function was created but the test fails

Invoke it separately, inspect the returned error and CloudWatch Logs, and compare the event shape with what your handler expects. Creation success does not validate application logic.

Make the deployment repeatable with a template

For more than a one-off experiment, define the function in AWS SAM or CloudFormation. SAM templates describe the function and packaging settings in YAML or JSON, and the SAM CLI can build, package, and deploy them. CloudFormation provides the underlying infrastructure resource model. Start with the CLI sequence above to understand the required runtime, handler, code package, and role; move to a template when those settings need to be reviewed, versioned, and reused. AWS’s CreateFunction API documents the same core function properties.

Checklist before you run the command

  • A supported Python runtime is selected.
  • lambda_function.py defines lambda_handler(event, context).
  • The ZIP contains the handler file at its root.
  • The handler value matches the module and callable.
  • An execution-role ARN is available and the CLI identity can pass it.
  • Your AWS Region and credentials are configured.
  • You have planned a separate invocation or console test.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.