Amazon Q Business: Build a Google Drive Upload Plugin
By Braincuber Team
Published on February 6, 2026
Generative AI isn't just about chatting with text; it's about taking action. Amazon Q Business (formerly Amazon Q) allows you to build "Custom Plugins" that connect your AI assistant to real-world APIs.
In this guide, we will build a powerful automation for "LegalDocFlow", a hypothetical law firm. We'll teaching Amazon Q to take a conversation summary or a generated draft and upload it directly to a specific Google Drive folder using a secure, serverless backend.
The Architecture:
- Amazon Q Business: The conversational interface.
- API Gateway + Lambda: The backend logic.
- Google Service Account: The identity uploading files for the bot.
- AWS Secrets Manager: Secure storage for Google credentials.
Step 1: Google Cloud Setup
First, we need a robot identity (Service Account) that Amazon Q can "impersonate" to talk to Google Drive.
- Go to the Google Cloud Console and create a new project "AmazonQ-Drive-Connector".
- Enable the Google Drive API.
- Create a Service Account named
upload-bot. - Create it, then go to the "Keys" tab and Create new key (JSON). Download this file (
credentials.json). - Crucial Step: Go to your actual Google Drive using your browser. Create a folder named "Legal Uploads". Share this folder with the email address of the Service Account (found in the JSON file). Give it "Editor" permissions.
Step 2: Secrets Manager
Never hardcode credentials. We'll store the Google JSON key in AWS Secrets Manager.
- Go to AWS Secrets Manager > Store a new secret.
- Choose "Other type of secret" -> "Plaintext".
- Paste the entire content of
credentials.json. - Name it:
google/drive/service-account.
Step 3: The Lambda Function
This logic retrieves the secret, authenticates with Google, and uploads the file content sent by Amazon Q.
import json
import boto3
from google.oauth2 import service_account
from googleapiclient.discovery import build
from googleapiclient.http import MediaIoBaseUpload
import io
def get_secret():
client = boto3.client('secretsmanager')
response = client.get_secret_value(SecretId='google/drive/service-account')
return json.loads(response['SecretString'])
def lambda_handler(event, context):
try:
# Extract file info from Amazon Q request body
body = json.loads(event['body'])
file_name = body.get('fileName', 'upload.txt')
file_content = body.get('content', '')
folder_id = body.get('folderId')
creds_json = get_secret()
scopes = ['https://www.googleapis.com/auth/drive']
creds = service_account.Credentials.from_service_account_info(creds_json, scopes=scopes)
service = build('drive', 'v3', credentials=creds)
file_metadata = {'name': file_name, 'parents': [folder_id]}
media = MediaIoBaseUpload(io.BytesIO(file_content.encode('utf-8')), mimetype='text/plain')
file = service.files().create(body=file_metadata, media_body=media, fields='id').execute()
return {
'statusCode': 200,
'body': json.dumps({'message': 'File uploaded', 'fileId': file.get('id')})
}
except Exception as e:
return {'statusCode': 500, 'body': json.dumps({'error': str(e)})}
Step 4: The OpenAPI Spec
This file teaches Amazon Q how to call your API. It serves as the "Instruction Manual" for the AI.
openapi: 3.0.0
info:
title: Google Drive Uploader
version: 1.0.0
paths:
/upload:
post:
summary: Upload a text file to Google Drive
description: Uploads content to a specific Google Drive folder.
operationId: uploadFile
requestBody:
required: true
content:
application/json:
schema:
type: object
properties:
fileName:
type: string
description: The name of the file to save.
content:
type: string
description: The text content to write inside the file.
folderId:
type: string
description: The Google Drive Folder ID to upload into.
responses:
'200':
description: Successful upload
content:
application/json:
schema:
type: object
properties:
fileId:
type: string
Conclusion
Once you configure this plugin in the Amazon Q Business console, you can simply ask the bot: "Please save a summary of this conversation as 'Client-Meeting-Notes.txt' to the Legal Uploads folder." Amazon Q will extract the content, invoke your Lambda, and securely place the file in Drive.
Automate Your Workflow with AI?
Ready to connect Amazon Q to Salesforce, Jira, or your own internal tools? We build enterprise-grade AI plugins.
