С помощью лямбды вы можете загрузить файл с S3, загрузить его с openpyxl, затем внести изменения в него и затем загрузить его на S3.
from openpyxl import load_workbook
from tempfile import NamedTemporaryFile
import boto3
import botocore
s3 = boto3.resource('s3')
def download_file(bucket, key):
try:
file = NamedTemporaryFile(delete=False)
s3.Bucket(bucket).download_file(key, file.name)
return file.name
except botocore.exceptions.ClientError as e:
if e.response['Error']['Code'] == "404":
return None
else:
raise
else:
raise
def upload_workbook(workbook, bucket, key):
with NamedTemporaryFile() as tmp:
workbook.save(tmp.name)
tmp.seek(0)
s3.meta.client.upload_file(tmp.name, bucket, key)
file = download_file("your-s3-bucket", "your-s3-key")
workbook = load_workbook(file)
# process workbook
upload_workbook(workbook, "your-bucket", "your-key")