简体   繁体   English

从AWS Lambda在EC2上运行exe文件

[英]Run exe file on EC2 from AWS Lambda

I have a requirement to run a .exe file with the SQS event message as parameter. 我需要运行以SQS事件消息为参数的.exe文件。 The .exe is installed on EC2. .exe已安装在EC2上。 Is it possible to invoke the exe from the AWS Lamda function? 是否可以从AWS Lamda函数调用exe?

The best way to run scripts on EC2 instances from outside of the EC2 instance is probably to use AWS Systems Manager Run Command . 从EC2实例之外的EC2实例上运行脚本的最佳方法可能是使用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) 您的EC2实例需要包含SSM代理 (如果它是从Amazon提供的Amazon Linux或Ubuntu AMI启动的,则可能已经包含了)
  2. your EC2 instance needs to be launched with an IAM role with an attached AmazonEC2RoleforSSM policy, see here 您的EC2实例需要使用带有附加AmazonEC2RoleforSSM策略的IAM角色启动,请参阅此处
  3. your Lambda function needs an IAM role allowing it to invoke Run Command (the action is ssm:SendCommand) 您的Lambda函数需要一个IAM角色,以允许其调用运行命令(操作为ssm:SendCommand)

Alternatively, you could do this in other ways, for example: 或者,您可以通过其他方式执行此操作,例如:

  1. use Fabric or Paramiko to exec commands over SSH 使用FabricParamiko通过SSH执行命令
  2. install a web server on the EC2 instance that allows you to remotely invoke an API to execute the script 在EC2实例上安装Web服务器,使您可以远程调用API来执行脚本

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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