Are you trying to run a command against a Linux instance? If so, you can try using an SSH library for your runtime such as python to connect through SSH and run a command. This is a bit of an old example but comes from AWS blog. Please use it as a reference. An easier option is using Systems Manager's Run Command. You can manage your EC2 instance through Systems Manager and then you can run a command such as AWS-RunShellScript to remotely run a command. If you want to get an output from the command within Lambda, you can use a SendCommand API action to do the same. This getting started guide, how to run commands on an EC2 instance with Systems Manager, walks through the process.
- AWS OFFICIALUpdated a year ago
- How do I resolve the "Log group does not exist" error for Lambda function logs in the CloudWatch console?AWS OFFICIALUpdated 3 years ago
- How can I get my Lambda function to work correctly with my Amazon EC2 instance or the AWS Instance Scheduler?AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 5 months ago
- EXPERTpublished 3 months ago