Created
January 7, 2018 20:22
-
-
Save l1m2p3/9277a164f4d6d7f536731b5832a71013 to your computer and use it in GitHub Desktop.
Sample script to reupload new deployment package to S3 and update Lambda to use the new package
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import boto3 | |
import json | |
import base64 | |
from datetime import datetime | |
from pytz import timezone | |
import sys | |
lambda_client = boto3.client('lambda') | |
s3 = boto3.resource('s3') | |
print('updating package') | |
# re-zip custom files into deployment package | |
os.system('zip -9 -q -r ./deploy.zip SimpleModel.py') | |
os.system('zip -9 -q -r ./deploy.zip SimpleModel.pt') | |
os.system('zip -9 -q -r ./deploy.zip main.py') | |
# upload to s3 | |
s3.meta.client.upload_file('./deploy.zip', 'uwaterloodsglambdapkgtest', 'deploy.zip') | |
# update lambda function | |
response = lambda_client.update_function_code( | |
FunctionName='pytorch_on_lambda', | |
S3Bucket='uwaterloodsglambdapkgtest', | |
S3Key='deploy.zip' | |
) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment