User Tools

Site Tools


aws:lambdabased-lambdalayer-orig

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

aws:lambdabased-lambdalayer-orig [20/11/2025 10:57] – created andrewaws:lambdabased-lambdalayer-orig [20/11/2025 10:59] (current) andrew
Line 92: Line 92:
 </code> </code>
  
 +
 +
 +
 +<code>
 +# more lambda_layer_inLambda/lambda.py 
 +import json
 +# import urllib.request
 +import os
 +import sys
 +import subprocess
 +
 +#from pip._internal import main
 +
 +#main(['index versions', '-I', '-q', 'boto3', '--target', '/tmp/', '--no-cache-dir', '--disable-pip-version-check'])
 +
 +
 +def lambda_handler(event, context):
 +    name = 'boto3'
 +    latest_version = str(subprocess.run([sys.executable, '-m', 'pip', 'install', '{}==random'.format(name)], capture_output=True, text=True))
 +    latest_version = latest_version[latest_version.find('(from versions:')+15:]
 +    latest_version = latest_version[:latest_version.find(')')]
 +    latest_version = latest_version.replace(' ','').split(',')[-1]
 +
 +    print("version", latest_version)
 +
 +
 +</code>
  
aws/lambdabased-lambdalayer-orig.txt · Last modified: by andrew

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki