Last active
September 22, 2017 00:55
-
-
Save rustyeddy/40248a5f5d3586b11064cceca726e7c1 to your computer and use it in GitHub Desktop.
AWS Lambda - running a bashscript from python
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 logging | |
import subprocess | |
def lambda_handler(event, context): | |
# Probably get the script name from an environment variable or event... | |
script = "bashscript.sh" | |
log = logging.getLogger("lambda-logger") | |
log.setLevel(logging.INFO) | |
log.info("Attempting to run bash script: " + script) | |
output = subprocess.check_output(script, stderr=subprocess.STDOUT, shell=True) | |
outstr = output.decode("utf-8") | |
log.info(outstr) | |
return outstr |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment