What is the most effective way to automate the EC2 instance run Python script with a specific argument value?

0

How to run the Python script in an EC2 instance and pass an argument value to the script. The arguments include the name of the S3 bucket folder name and any other input.

Note.

  1. The Python script should not run while starting the instance (assuming the instance is always running).
질문됨 2년 전1021회 조회
1개 답변
0

Running a python script on an EC2 instance is no different from running it on a VM in your on-prem data center or your personal machine. You can take a look at this Stackoverflow post for an example of how to run a python script and pass arguments to it - https://stackoverflow.com/questions/14155669/call-python-script-from-bash-with-argument

In AWS, there are other ways to achieve the same thing without having to provision an EC2 machine by using serverless mechanisms such as Glue Python Shell or AWS Lambda

Glue Python Shell - https://docs.aws.amazon.com/glue/latest/dg/add-job-python.html

Lambda function - https://docs.aws.amazon.com/lambda/latest/dg/lambda-python.html

The advantage with serverless approaches is that you pay only when your program runs. With EC2 machine, you will pay as long as your machine is on, even if it is sitting there doing nothing. Plus you will be responsible for patching the machines.

profile pictureAWS
전문가
답변함 2년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠