1

I have a bat file on an AWS Windows 2012 Server instance. Is it possible to run an AWS Lambda function (Python or Node) to execute the bat file?

Thanks

somesingsomsing
  • 3,182
  • 4
  • 29
  • 46

3 Answers3

2

You could possibly use the EC2 Run Command feature to accomplish this. https://aws.amazon.com/ec2/run-command/

Mark B
  • 183,023
  • 24
  • 297
  • 295
1

If I understand your question correctly, you're asking if it's possible to have your Lambda function connect to your EC2 instance and execute a .bat file?

If that's your question, than the answer is "no" unless (I think) your EC2 instance is publicly available. Currently, Lambda functions do not have access to anything behind a VPC.

https://aws.amazon.com/lambda/faqs/

Q: Can I access resources behind Amazon VPC with my AWS Lambda function?

AWS Lambda functions cannot currently access resources behind a VPC.

https://aws.amazon.com/blogs/aws/aws-lambda-update-python-vpc-increased-function-duration-scheduling-and-more/

The above blog post said this would be available late 2015 (though it was written in Oct 2015), however it's still not available.

As was suggested, try using the EC2 run command instead.

Brooks
  • 7,099
  • 6
  • 51
  • 82
  • Yes I'm trying to execute a bat file on my EC2 instance using a lambda function. I really don't need to use a lambda but thought it would be cool to do so. Thank you for answering my question – somesingsomsing Feb 03 '16 at 20:59
  • Yeah, unfortunately Lambda can't connect to VPC resources. I'm not 100% sure, but MAYBE if your EC2 instance has a public IP, the Lambda function can connect to it. I haven't tried it, but Lambda is supposed to be able to connect to external resources, so why not an EC2 public IP address? Don't quote me on that... – Brooks Feb 03 '16 at 21:04
0

You can rdp in the instance and execute it or let lambda place a message/triger in the queue and let process on the instance know that script needs to run and trigger it.

Take a look at this question: launch a shell script from lambda in aws

Community
  • 1
  • 1
Vor
  • 33,215
  • 43
  • 135
  • 193