Finding the services running on multiple aws ec2 instances - amazon-web-services

Is there a command in the AWS cli to get a list of services running on my ec2 instances?
Normally I log into each ec2 instance individually, and check using Linux commands such as "netstat" or "ps -eaf".
There are around 400 instances, so if I do this manually it takes quite a lot of time. If any AWS commands are there to find the services running without actually logging into the instance, it would be great.
Thanks in advance.

The AWS Command Line Interface is a tool to manage your AWS services. You cannot use AWS-CLI to manage OS-level service. With AWS-CLI, you can control multiple AWS services from the command line and automate them through scripts.
Hope it helps :-)

You might have some luck with EC2 Run Command. From their docs:
Run Command provides a simple way of automating common administrative tasks
like executing Shell scripts and commands on Linux [...]
Run Command allows you to execute these commands across multiple
instances and provides visibility into the results

Related

How to run a command in CMD that will run on all AWS ec2 instances I have created?

I was wondering, is it possible and how to run a command from local PC which will then be ran on every ec2 instance I have created?
You can run common administrative tasks on multiple EC2 instances using AWS Systems Manager Run Command. Note there are some pre-requisites for using this.

AWS EC2 Ubuntu 19. Setting up multiple tinyproxy servers

So I'm trying to set up multiple proxy servers through tinyproxy with ubuntu on AWS. Is there a way to setup it way quicker without having to connect to each instance 1 by 1 and download the packages then setup the server? Thanks!
Seems like you are trying to find a way to run batch commands on multiple instances to provision them.
You can look into SSM Run Command to accomplish this. This will allow you to run Ansible playbooks, Shell commands, etc. on multiple instances based on tags / resource groups / manual selection.
Further reading from AWS regarding Run Command

What is the most efficient way to run scheduled commands on multiple EC2 instances?

Currently working on an environment requirement where we are to push the same file out to multiple EC2 instances running Windows on a scheduled interval. As it stands now, I see a few options and have tried each:
Windows Task Manager: run a basic task on a set schedule invoking the S3 Sync CLI tool
Cons I can see here include: setting up the task on each EC2 instance (there are many).
Lambda: scheduled lambda job that utilizes SSM to run commands on each server in a resource group
Cons: introducing another layer required to execute this task.
Run Command: using an AWS-RunRemoteScript document, run the script (stored in S3) bucket on target instances.
Cons: I'm not positive you can automate these commands on a schedule without adding another layer.
What is the most scalable path forward? Thanks in advance for your help.
Using the Run Command feature of AWS Systems Manager together with either the Maintenance Window feature of AWS Systems Manager or using CloudWatch Events to schedule the execution of Run Command should be useful here.
If you also tag instances appropriately, you can use the tag targeting feature of Run Command to ensure that all instances run the command (including new instances launched in the future as long as they are tagged).
/Mats

Amazon EC2 - how to get list of process running on instances via AWS API?

How to get a list of process running on Amazon EC2 instances via the AWS API?
This could be accomplished by using the Amazon EC2 Systems Manager Run Command, which uses an agent installed on EC2 instances to run remote commands.
It takes a bit of configuration, but allows you to run commands on potentially hundreds of instances with one command.
This isn't possible. The EC2 API doesn't provide any actions to perform operations or retrieve data from the operating system layer.

Powershell Automation in ec2

We are trying to automate running of multiple powershell scripts in AWS EC2 instance. Any suggestion how this can be done. These execution has to be sequential.
In order to configure state on a fresh EC2 instance, you can use 'User Data' in order to:
a. Fully provision and configure state using powershell, see:
http://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/ec2-instance-metadata.html#instancedata-add-user-data
b. Install an agent for a configuration management tool such as Puppet, Chef, Ansible (as mentioned in the comment above). An example of provisioning stock Window's AMI's can be followed here: http://blog.rolpdog.com/2015/09/manage-stock-windows-amis-with-ansible.html
If you wish to trigger scripts on an existing Amazon EC2 instance (or a whole fleet of instances), also consider Running PowerShell Commands or Scripts with Amazon EC2 Run Command.