I have a running AWS instance. I want to set user-data for this instance.
Question is how do I do it either using AWS console or using AWS CLI tools.
You have to stop your instance to change the user-data. The AWS EC2 User Guide has instructions on how to do it: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Stop_Start.html#Using_ChangingAttributesWhileInstanceStopped
Related
Right now I am testing to see if I am able to write
touch test.txt
simply to another ec2 instance.
I have looked into both ssh and ssm but I do not understand where to begin the code. Any ideas to remotely send commands?
If you want to send a command remotely you can make use of the AWS run command functionality of SSM.
To do this you will need to ensure that you’re both running SSM agent and have a valid IAM role setup on the remote instance. The getting started section should help that.
Finally you can call the remote instance using the send-command function. Either create your own document or use the existing ‘AWS-RunShellScript’ document.
I was able to successfully setup and run tests on ec2 instance by setting up JMeter, Grafana (UI to display results) and a database called influxDB. The only issue is that a user has to logon to the instance to run the test as the test plans need to be uploaded on the instance for the same.
I was hoping if I could leverage SSM (aws run command) by which I can store the test plan in an S3 bucket and then use SSM to take this test plan and run the test from AWS SSM directly instead of logging onto the ec2 instance?
Please note, I would like to still run the test on the ec2 instance but as a user I don't want to login to the instance directly but rather have aws ssm take care of this.
Any insight on the same will be helpful. Thanks!!
I was able to mount an S3 bucket and fix the problem.
I have a requirement to run a .exe file with the SQS event message as parameter. The .exe is installed on EC2. Is it possible to invoke the exe from the AWS Lamda function?
The best way to run scripts on EC2 instances from outside of the EC2 instance is probably to use AWS Systems Manager Run Command.
The setup is fairly simple:
your EC2 instance needs to include the SSM Agent (it probably already does if it was launched from an Amazon-provided Amazon Linux or Ubuntu AMI)
your EC2 instance needs to be launched with an IAM role with an attached AmazonEC2RoleforSSM policy, see here
your Lambda function needs an IAM role allowing it to invoke Run Command (the action is ssm:SendCommand)
Alternatively, you could do this in other ways, for example:
use Fabric or Paramiko to exec commands over SSH
install a web server on the EC2 instance that allows you to remotely invoke an API to execute the script
I want to create a simple Web UI that can be used to list the active EC2 instance and give my developer an easy way to start and stop the EC2 server without having log into the AWS console.
I was wondering if anyone has seen something like this before?
Use IAM to create a user, assign a policy that only allows describe, start and stop actions on the EC2 resource you want. AWS console is then your simple GUI.
You can certainly create a web page like this. The easiest would be to call the commands via the JavaScript API, but you'd have to find a way to provide credentials.
Another option is to give them Elastic Wolf, which is a desktop application. Give them a set of credentials that has the required permissions and they can view/start/stop instances via a graphical UI.
Or, just let them use the AWS Console, with scoped-down permissions to only view instances, and then start/stop.
Finally, you could just give them the AWS Command-Line Interface (CLI) and a simple script to turn on/off desired instances, eg:
aws ec2 start-instances --instance-ids i-123471b4 --region us-east-1
aws ec2 stop-instances --instance-ids i-123471b4 --region us-east-1
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.