Archive for August, 2016

How to automatically install an .exe into a remote AWS EC2 instance (part 2)

August 30, 2016

Hi,

In this post I will show you how to run the PowerShell command from part 1 on all EC2 instances.

  1. Connect to AWS Console using your own credentials.
  2. Go to Compute -> EC2 and select Command History

ec2_console

  1. Select Run a command.
  2. Choose AWS-RunPowerShellScript.

send_command_window

       5. Select an instance from the instance list. If the desired instance is not in the list then jump down to SSM Run Command Prerequisites section for more pieces of information.

choose_instance

6. Copy paste the PowerShell script in the Commands field (you can take the script from part 1 of this article which can be found here)

  7. Run the Command.

 

SSM Run Command Prerequisites:

Make sure the following steps are verified such that an EC2 is ready for SSM:

  1. Check that the EC2 instance has an IAM role associated to it.
  2. If it doesn’t then this means that the SSM Service can’t be used on that instance because it requires a role and you can’t add a role to an already launched instance. In this case you need to create an AMI from the existing EC2 instance and then launch a new instance from that AMI. During the launch process you will be able to attach a role to the new instance.
  3. If the EC2 instance has a role then you need to make sure the SSM Policy is attached to that role (Roles -> Policies -> Attach Policy -> AmazonEC2RoleForSSM).
  4. Install the latest version of EC2 Service on the EC2 instance:(http://aws.amazon.com/developertools/5562082477397515)

Useful links:

  1. http://docs.aws.amazon.com/ssm/latest/APIReference/Welcome.html
  2. http://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/walkthrough-ui.html
  3. http://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/remote-commands-prereq.html