from the web application to how can I run the Python script in the Ubuntu terminal?

0

Is there a way to run the python script terminal and get the output EC2 instance?

As an example, I get two values from the web app as input. With these two values as arguments, a Python script runs on the terminal.

Python3 add.py value1 value2
  1. What AWS services are required?
  2. Is there a way to get these values to be sent to a web application?
  3. What is the best way to run or trigger the Python script on the EC2 instance from the web app?

It's challenging for me to figure this out.

1 Answer
0

If I understand your question correctly: You have a web application and you want to send two values to a Python script; have it perform some operation and return a result.

While you could do this with EC2 I wouldn't recommend it - you would have a whole instance running all the time even when your web application isn't requesting any results.

Instead, consider using Lambda. Create a Lambda function using Python then publish that function using Lambda function URLs - you pass the two values to the URL and it executes the Lambda function, returning the appropriate value.

profile pictureAWS
EXPERT
answered 2 years ago
  • Brettski, I know it's not recommended for simple tasks, but the actual application is image processing.

    The S3 bucket folder name is the argument value. It takes a minimum of two to three hours to complete.

    I have tested the script manually and it works well. I want to automate it on the EC2 instance

    Thanks

  • Thanks for expanding on the question. In that case, I would use SQS: Send the job details to a SQS queue; have EC2 instances scale based on the length of the queue (that way you can run zero instances when there are no jobs; and you can scale to more instances if necessary); then your script on the EC2 instances reads the job details from the SQS queue. Don't forget to set the message visibility timeout to several hours. Note that you can create the SQS message as a trigger from S3 when the object is uploaded.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions