简体   繁体   中英

Run exe file on EC2 from AWS Lambda

I have a requirement to run a .exe file with the SQS event message as parameter. The .exe is installed on EC2. Is it possible to invoke the exe from the AWS Lamda function?

The best way to run scripts on EC2 instances from outside of the EC2 instance is probably to use AWS Systems Manager Run Command .

The setup is fairly simple:

  1. your EC2 instance needs to include the SSM Agent (it probably already does if it was launched from an Amazon-provided Amazon Linux or Ubuntu AMI)
  2. your EC2 instance needs to be launched with an IAM role with an attached AmazonEC2RoleforSSM policy, see here
  3. your Lambda function needs an IAM role allowing it to invoke Run Command (the action is ssm:SendCommand)

Alternatively, you could do this in other ways, for example:

  1. use Fabric or Paramiko to exec commands over SSH
  2. install a web server on the EC2 instance that allows you to remotely invoke an API to execute the script

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM