- Consulting
- Training
- Partners
- About Us
x
In order to perform updates, patches, restart a particular process or running a particular powershell script in a Windows based EC2 instance we need to login to the machine and then make the required changes. Sometimes in a huge production environment this tends to be a cumbersome job for managing large fleet of machines. Therefore in order to make our lives easier AWS has introduced a new add-on feature for EC2 called as Command.
Using this feature we can perform system administrator tasks on Windows based EC2 machines. Currently the following actions are supported in Run Command.
Since Run Command runs from the AWS console and no username and password is required to access the instances, questions may arise as to how safe this feature is? Run Command incorporates with IAM policies and roles. Each and every command which is run using Run Command is stored in CloudTrail and also remains in the Console for 30 days.
Run Command shows the output in the console for only 2500 characters and the rest of the output is truncated. In order to keep track of all the commands and their detailed output we can integrate it with S3 and store the output in form of logs in an S3 bucket.
We shall see how we can use the Run Command feature to run a PowerShell script on an EC2 instances.
In order to setup the EC2 instance to user Run command these are the pre-requisites needed.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "ssm:DescribeAssociation", "ssm:GetDocument", "ssm:ListAssociations", "ssm:UpdateAssociationStatus", "ssm:UpdateInstanceInformation" ], "Resource": "*" }, { "Effect": "Allow", "Action": [ "ec2messages:AcknowledgeMessage", "ec2messages:DeleteMessage", "ec2messages:FailMessage", "ec2messages:GetEndpoint", "ec2messages:GetMessages", "ec2messages:SendReply" ], "Resource": "*" }, { "Effect": "Allow", "Action": [ "ec2:DescribeInstanceStatus" ], "Resource": "*" }, { "Effect": "Allow", "Action": [ "logs:CreateLogGroup", "logs:CreateLogStream", "logs:DescribeLogGroups", "logs:DescribeLogStreams", "logs:PutLogEvents" ], "Resource": "*" }, { "Effect": "Allow", "Action": [ "s3:PutObject", "s3:GetObject", "s3:AbortMultipartUpload", "s3:ListMultipartUploadParts", "s3:ListBucketMultipartUploads" ], "Resource": "*" } ] } |
1 2 3 4 5 6 7 8 9 10 11 12 13 |
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "ssm:*", "ec2:DescribeInstanceStatus" ], "Resource": "*" } ] } |
In this task we shall create a role using which the Run Command can access the EC2 instance.
Launch and EC2 instance and make sure you attach the IAM Role we created in the previous steps. Refer the Diagram and launch an EC2 instance.
Open the Amazon Management Console and click on Commands in the navigation pane as shown in the figure below.
The Run Command is available only in the following region.
There are also a few limitations to the EC2 run command as follows
The Run Command
Run Command does not have any charge beyond the standard usage charges for Amazon EC2, Amazon S3, and other AWS services that are used with this feature.
Voiced by Amazon Polly |
CloudThat is a leading provider of cloud training and consulting services, empowering individuals and organizations to leverage the full potential of cloud computing. With a commitment to delivering cutting-edge expertise, CloudThat equips professionals with the skills needed to thrive in the digital era.
Our support doesn't end here. We have monthly newsletters, study guides, practice questions, and more to assist you in upgrading your cloud career. Subscribe to get them all!
Sanket
Dec 31, 2015
Well explained..!!!!
Shaan
Dec 21, 2015
Good one.
Niko
Dec 16, 2015
Hi Ravi, great post and overview of Run command! We just launched Linux support today, so check out our blog post and documentation and feel free to update your post with the new examples and Linux support. Thanks
Rainder singh
Dec 12, 2015
Usefull information
Arman
Dec 9, 2015
Nice one dude. Cheers. Well explained.
Click to Comment