Skip to content

Add direct AWS Lambda deployment without Chalice dependency#5

Draft
Copilot wants to merge 6 commits intomainfrom
copilot/create-aws-zip-file-version
Draft

Add direct AWS Lambda deployment without Chalice dependency#5
Copilot wants to merge 6 commits intomainfrom
copilot/create-aws-zip-file-version

Conversation

Copy link

Copilot AI commented Feb 11, 2026

Enables deployment to AWS Lambda via zip file upload, removing the Chalice requirement for external users. The existing Chalice deployment path remains unchanged for internal use.

Changes

  • lambda_function.py: Standalone handler with proper error codes (400 for client errors, 500 for server errors)
  • .github/workflows/build-deployment-zip.yaml: Auto-generates deployment.zip on releases, uploadable as artifact or release asset
  • build-deployment-zip.sh: Local build script for customization scenarios
  • DEPLOYMENT.md: Complete deployment guide covering IAM setup, S3 configuration, and troubleshooting
  • README.md: Restructured to show both deployment options upfront

Deployment Package Structure

deployment.zip (~40MB)
├── lambda_function.py
├── chalicelib/
│   ├── __init__.py
│   └── ytb_api_utils.py
└── [dependencies]/
    ├── boto3/
    ├── google-api-python-client/
    └── ...

Dependencies installed: boto3, google-api-python-client, google-auth, google-auth-oauthlib, google-auth-httplib2

Notably excluded: chalice (only needed for the Chalice deployment path)

Usage

Download deployment.zip from releases → upload to Lambda console → configure IAM/S3 → done. See DEPLOYMENT.md for details on IAM policies and S3 token storage.

Original prompt

This section details on the original issue you should resolve

<issue_title>Create version that can be directly uploaded to AWS as a zip file</issue_title>
<issue_description>I.e., without chalice dependency. Just the normal process.

https://github.com/ACC-HelloWorld/5-data-logging#aws-lambda-function

AccelerationConsortium/ac-dev-lab#231
AccelerationConsortium/ac-dev-lab#271

https://docs.aws.amazon.com/lambda/latest/dg/python-package.html

copying some code from the notebook mentioned in https://github.com/ACC-HelloWorld/5-data-logging#aws-lambda-function

# -*- coding: utf-8 -*-
"""1.5.2-mongodb-aws-lambda-prep.ipynb

Automatically generated by Colab.

Original file is located at
    https://colab.research.google.com/github/AccelerationConsortium/ac-microcourses/blob/main/docs/courses/hello-world/1.5.2-mongodb-aws-lambda-prep.ipynb

# Preparing the Python code and dependencies for AWS Lambda

[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/AccelerationConsortium/ac-microcourses/blob/main/docs/courses/hello-world/1.5.2-mongodb-aws-lambda-prep.ipynb)

For simplicity, we'll package `pymongo`, our Python dependency, along with our `lambda_function.py` script per the [guidelines in the AWS docs](https://docs.aws.amazon.com/lambda/latest/dg/python-package.html). See also the [How to Use PyMongo to Connect MongoDB Atlas with AWS Lambda](https://www.mongodb.com/developer/products/atlas/awslambda-pymongo/) MongoDB tutorial and the [Manage Connections with AWS Lambda](https://www.mongodb.com/docs/atlas/manage-connections-aws-lambda/) MongoDB documentation page. This notebook is intended to be run on Google Colab.
"""

# Commented out IPython magic to ensure Python compatibility.
# %mkdir dependencies

# Commented out IPython magic to ensure Python compatibility.
# %pip install --target ./dependencies pymongo

# Commented out IPython magic to ensure Python compatibility.
# %%writefile lambda_function.py
# import os
# import json
# from pymongo import MongoClient
# 
# atlas_uri = os.environ['ATLAS_URI']
# client = MongoClient(atlas_uri)
# 
# def lambda_handler(event, context):
#     try:
#         payload = json.loads(event["body"])
#         document = payload["document"]
#         db_name = payload["database"]
#         collection_name = payload["collection"]
#         db = client[db_name]
#         collection = db[collection_name]
#         result = collection.insert_one(document)
#         return {
#             "statusCode": 200,
#             "body": json.dumps({"message": "Document inserted successfully"}),
#         }
#     except Exception as e:
#         return {
#             "statusCode": 500,
#             "body": json.dumps({"error": str(e)}),
#         }
#

# Commented out IPython magic to ensure Python compatibility.
# %cd dependencies
!zip -r ../deployment.zip *
# %cd ..
!zip deployment.zip lambda_function.py

"""Download the file:"""

import sys

if 'google.colab' in sys.modules:
    from google.colab import files
    files.download('deployment.zip')

"""NOTE: If the above cell doesn't work in Google Colab, you can download `deployment.zip` using the left navigation bar by **hovering over the file**, clicking the three vertical dots, and clicking "download", as shown below. If you don't see the file, you may need to click the refresh icon near the top of the sidebar. You will then upload this `.zip` file to AWS Lambda.
"""

In our case, we don't need to package pymongo. However, we do need the dependencies in https://github.com/AccelerationConsortium/streamingLambda/blob/main/requirements.txt, except for chalice. Write a GitHub action that automatically creates a new deployment.zip for new release versions.

Keep in mind the dependency file within chalicelib/ folder.

The main overall goal is for people outside the AC organization to be able to easily and quickly create a lambda function for their own organization/research group/etc.

See also https://ac-training-lab.readthedocs.io/en/latest/devices/picam.html, which is sort of the entry point. The whole goal is to get a new, fully functioning LAMBDA_FUNCTION_URL (which also means dealing with the YouTube token.pickle and S3)</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@sgbaird
Copy link
Member

sgbaird commented Feb 11, 2026

cc @seth-leavitt

Copilot AI and others added 5 commits February 11, 2026 18:21
Co-authored-by: sgbaird <45469701+sgbaird@users.noreply.github.com>
Co-authored-by: sgbaird <45469701+sgbaird@users.noreply.github.com>
Co-authored-by: sgbaird <45469701+sgbaird@users.noreply.github.com>
Co-authored-by: sgbaird <45469701+sgbaird@users.noreply.github.com>
Co-authored-by: sgbaird <45469701+sgbaird@users.noreply.github.com>
Copilot AI changed the title [WIP] Create version for AWS upload as zip file without chalice Add direct AWS Lambda deployment without Chalice dependency Feb 11, 2026
Copilot AI requested a review from sgbaird February 11, 2026 18:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create version that can be directly uploaded to AWS as a zip file

2 participants