Compare Linux application file system between 2 AWS EC2 instances - linux

We have a Java based application running in Linux EC2 instances. We have different components running in different EC2 instances.
Every month we go for an AMI upgrade by creating new instances, deploying the code and killing the old instances. We are facing challenge in making sure that all components are deployed successfully in the instances.
Are there tools to get a snapshot of the application file system from old instance before AMI upgrade and compare it with the snapshot taken from new instance after code deployment?
If so that will make our work easier. We have a tool of 8 instances running the application.

Related

Deploy NodeJS application on EC2 via launch template

I built a simple NodeJS application and ran on an EC2 instance.
Everything works fine. I decided to create an AMI (Amazon Linux based) and a launch template to be used by a ASG.
The problem is, I cannot get the application start automatically.
I tried to add the following command through the user_data field but it doesn't work:
node main.js
Any ideas on how to automatically start this application once launched by the ASG?
Typically you would add this to the startup script of the AMI, so once the instance has started it will run the script on boot.
You may want to look at PM2 as well, it's a great tool for things like this and also makes it easy to setup each node instance in cluster mode ( assuming you have an EC2 instance with more than one core )
Some other ways of doing this, albeit not an auto scale but with DigitalOcean they offer a CASS model called 'apps' that basically pushes you app into a container from a git-repo and deploys it, you can then just spin new instances out as needed. Downside is that the bandwidth is a bit small but CND etc can help with that.

AWS: How to launch multiple of the same instance from python?

I have an AWS Windows Server 2016 VM. This VM has a bunch of libraries/software installed (dependencies).
I'd like to, using python3, launch and deploy multiple clones of this instance. I want to do this so that I can use them almost like batch compute nodes in Azure.
I am not very familiar with AWS, but I did find this tutorial.
Unfortunately, it shows how to launch an instance from the store, not an existing configured one.
How would I do what I want to achieve? Should I create an AMI from my configured VM and then just launch that?
Any up-to-date links and/or advice would be appreciated.
Yes, you can create an AMI from the running instance, then launch N instances from that AMI. You can do both using the AWS console or you could call boto3 create_image() and run_instances(). Alternatively, look at Packer for creating AMIs.
You don't strictly need to create an AMI. You could simply the bootstrap each instance as it launches via a user data script or some form of CM like Ansible.

AWS EC2 AMI launch with user-data

I am trying to launch my own AMI using user-data so that it can run a script and then terminate.
So I launched an Ec2 Windows Base and configure it to have all the tools I need (NodeJS etc) and saved my script to C:\Projects\index.js.
I then saved it as an Image.
So I then used the console to launch an EC2 from my new AMI with the user-data of
node C:\Projects\index.js --uuid=1
</powershell>
If I run that command having RDP into the EC2 it works, so it seems that the userdata did not run when the Image was started.
Having read some of the other questions and answers it could be because the AMI created was made from an Instance that started already. So the userdata did not persist.
Can anyone advise me on how I can launch my AMI with a custom userdata each time? (as the UUID will change)
Thanks
Another solution that worked for me is to run Sysprep with EC2Launch.
The issue is that AWS doesn't reestablish the route to the profile service (169.254.169.254) in your custom AMI. See response by SanjitPatel in this post. So when I tried to use my custom AMI to create spot requests, my new instances were failing to find user data.
Shutting down with Sysprep, essentially forces AWS re-do all setup work on the instance, as if it were run for the first time. So when you create your instance, shut it down with Sysprep and then create your custom AMI, AWS will setup the profile service route correctly for the new instances and execute your user data. This also avoids manually changing Windows Tasks and executing user data on subsequent boots, as persist tag does.
Here is a quick step-by-step:
1.Create an instance using one of the AWS Windows AMIs (Windows Server 2016 Nano Server doesn't support Sysprep) and passing your desired user data (this may be optional, but good to make sure AWS wires setup scripts correctly to handle user data).
2.Customize your instance as needed.
3.Shut down your instance with Sysprep. Just open EC2LaunchSettings application and click "Shutdown with Sysprep".
4.Create your custom AMI from the instance you just shut down.
5.Use your custom AMI to create other instances, passing user data on instance creation. User data will be executed on instance launch. In my case, I used Spot Request screen, which had a User Data text box.
Hope this helps!

How to change platform of Amazon EC2 instance

I have an on-demand instance running in Amazon EC2. I want to create a reserved instance.
My instance configuration is
Instance type :m1.small
Availability zone:us-west-2c
Platform: Red Hat Enterprise Linux Server release 6.4
I have set up this instance with all required software to run my web service (30GB EBS is attached to this instance)
Got to know how to create a reserved instance from here. When I was about to purchase a reserved instance, I noticed that Linux/UNIX is cost effective than Red Hat Enterprise Linux. Is there any way I can change my running instance platform or Should I redo every setup with a new instance?
AFAIK, there is no way to replace the instance's platform (and pricing) and maintaining its current deployment. I've found this article about a workaround for 'sharing EBS' but it doesn't guarantee that an EBS volume created for RHEL can be attached to a Linux instance (I'd bet against it).
If you already paid for reserved instances, I suggest you contact aws support team to see if there are any alternatives, or at least - a refund.
(BTW please update us if there is a solution)

Install vFrabric tc server (as bundled with STS) into Linux EC2 instance?

I have been developing a Spring MVC web app using Springsource Tool Suite (STS). STS comes with vFabric tc server developer edition I believe. When I deploy the .war file into my EC2 Linux AMI instance running tomcat6, there are incompatibilities between tomcat and vFabric.
For example, vFabric will accept objectName.getMethod() whereas it will return an error in tomcat6. I have to change it to objectName.method.
Here is my question. So, when making changes now, I don't use STS anymore and every change I have to package and redeploy which is time consuming. What is a good way around this?
I am thinking of installing the vFrabic tc server in my EC2 linux instance. Will that work? If I do that, theoretically, everything I develop in STS should be 100% compatible when deployed, correct?
Second question. How do I install vFrabic tc server in my EC2 instance?
Thanks!
One suggestion would be to develop inside of STS using a Tomcat server instead of tcServer. However, then of course you loose some of the nice capabilities of tcServer.
If no one here can give you a complete answer, I would recommend the SpringSource forums (for STS):
http://forum.springsource.org/forumdisplay.php?32-SpringSource-Tool-Suite
or here for tcServer:
http://forum.springsource.org/forumdisplay.php?64-tc-Server-General

Resources