Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

Google Drive Sync Lambda

Syncs public Google Docs to an S3 bucket as plain text files.

Documents Being Synced

Document ID Source URL
1juZcZg0ygOesa4LLWOuULUu501BGaBWW3dtvQZQzJr8 Link
1-QCHQaGe44fB4w4OkAwYdcZFW1X8nAjwj2jbNbFf5lg Link
15kZEyxk1EaEx2yJ-CghO8ZYHcgVCjmG9LXaMAAkbVQQ Link
1bGJlcbhu7CGs6D6DqP831jL0EnoGQQa_l68m9J1s-20 Link

Prerequisites

  • AWS CLI configured with appropriate credentials
  • AWS SAM CLI installed (installation guide)
  • Python 3.11+

Local Testing

Test fetching the documents locally (doesn't upload to S3):

python lambda_function.py

Deployment

Option 1: AWS SAM (Recommended)

  1. Build the application:

    sam build
  2. Deploy (first time - guided):

    sam deploy --guided

    You'll be prompted for:

    • Stack name (e.g., gdrivesync)
    • AWS Region
    • BucketName parameter (must be globally unique)
  3. Deploy (subsequent):

    sam deploy

Option 2: Manual Deployment

  1. Create the S3 bucket:

    aws s3 mb s3://your-bucket-name
  2. Create a ZIP package:

    zip lambda.zip lambda_function.py
  3. Create the Lambda function:

    aws lambda create-function \
      --function-name gdrivesync-function \
      --runtime python3.11 \
      --handler lambda_function.lambda_handler \
      --zip-file fileb://lambda.zip \
      --role arn:aws:iam::YOUR_ACCOUNT:role/YOUR_LAMBDA_ROLE \
      --timeout 60 \
      --memory-size 256 \
      --environment Variables="{S3_BUCKET_NAME=your-bucket-name}"

Manual Invocation

Trigger the Lambda manually:

aws lambda invoke \
  --function-name gdrivesync-function \
  --payload '{}' \
  response.json

cat response.json

S3 Output Structure

s3://your-bucket/
├── docs/
│   ├── 1juZcZg0ygOesa4LLWOuULUu501BGaBWW3dtvQZQzJr8.txt
│   ├── 1-QCHQaGe44fB4w4OkAwYdcZFW1X8nAjwj2jbNbFf5lg.txt
│   ├── 15kZEyxk1EaEx2yJ-CghO8ZYHcgVCjmG9LXaMAAkbVQQ.txt
│   ├── 1bGJlcbhu7CGs6D6DqP831jL0EnoGQQa_l68m9J1s-20.txt
│   └── _manifest.json

Schedule

By default, the Lambda runs daily at 6 AM UTC. To modify, edit the Schedule in template.yaml.

Adding More Documents

Edit GOOGLE_DOC_IDS in lambda_function.py and redeploy.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages