I am having an instance running in AWS, this instance was installed with tomcat, java,DB, etc.,
I want to create an another instance like my running instance.
how to clone my running instance with all the installations to be available in new instance? I read about creating AMI, will it make my new instance with tomcat, java,DB, etc., installed?
Yes, you can create an AMI from your running instance and then launch a new instance from that AMI and it will essentially be a clone.
Choosing the Create Image command on an existing Amazon EC2 instance will create an Amazon Machine Image (AMI) that contains a copy of all disk volumes attached to the instance.
You can then launch a new EC2 instance from the AMI. This will result in the new instance having exactly the same disk content. When launching the new instance you can select a different instance type, network setting, etc -- the only part that will be identical is the content of the disk volumes.
Give it a try, it's very easy!
Select the original instance in the Amazon EC2 management console
Click Actions/Image/Create Image to create the AMI
Select the new AMI in the AMIs section of the console
Select the AMI, then click Actions/Launch to launch a new instance from the AMI
See: Creating an Amazon EBS-Backed Linux AMI
Related
Is it possible to backup EC2 instance locally? (Not just the data , but the installations on Linux in EC2 as well)
I found number of options that would take data backup, but is there a way where we could backup fully functional Ec2 as is to local system? If not, can we download the image may be of EC2 locally which can be restored to same/another AWS environment when needed?
can we download the image may be of EC2 locally which can be restored to same/another AWS environment when needed?
for this the easiest solution would be this
got to instances under ec2 service in your account management console.
select the instance you wish to backup/copy.
select create image.
once image is created you can view it under ec2 navigation pane -> images-> ami.
to launch instance from the image, select and launch it.
could backup fully functional Ec2 as is to local system
the possible solution what i know and have tried to use export.Exporting as a VM is useful when you want to deploy a copy of an Amazon EC2 instance in your on-site virtualization environment. You can export most EC2 instances to Citrix Xen, Microsoft Hyper-V, or VMware vSphere.
your VM which is to be exported is stored in s3 so you will be charged according to s3 rates+ EBS snapshot charge
In AWS cloud formation, i use the cloud former tool. I can use that tool to create a cloud formation template from existing resources. And then use the template to create a stack. I tested with that tool. It can work, (as in it can create instances with same memory size, with same volume size, same VPC settings, and auto start the instances). But there is no files in the volume.
Do i have to create a snapshot of the existing volume, create a new volume from the snapshot, attach it to the newly created instance, and copy the files manually ?
Or is there any better way ?
Do i have to create a snapshot of the existing volume, create a new volume from the snapshot, attach it to the newly created instance, and copy the files manually ?
Cloudformation is provisioning resources, but is not responsible for provisioning the contents of those resources - that you have to do yourself.
You can leverage the EC2 Userdata to manually pull files from S3 or other repos as the instance boots.
Or is there any better way ?
If you want to share data between applications, EFS is always an option. In your case, though, using Userdata might be effective.
If you wish to launch new EC2 instances with software automatically loaded, there are basically two choices:
Use a pre-configured AMI, or
Use a startup script to load the software
Pre-configured AMI
An Amazon Machine Image (AMI) is a copy of a disk. When a new EC2 instance is launched, an AMI is selected and the boot disk (and optionally other disks) are automatically pre-loaded with the contents of the AMI.
A common practice is to boot an EC2 instance and configure it as desired. Then, create an AMI. Thereafter, when a new EC2 instance is required for the application, launch it using the pre-built AMI.
There are also tools available to automate the building of an AMI, such as Netflix Aminator and Packer.
Benefits: New machine boots quickly, fully-configured.
Issues: Need to create a new AMI whenever you update your software.
Use a startup script to load the software
When an Amazon EC2 instance is launched from a standard Amazon-provided AMI (eg Amazon Linux, Microsoft Windows), software on the AMI automatically looks at the User Data passed to an EC2 instance. If the User Data contains a startup script, the script will be executed -- but only the first time that an instance is launched. This is an excellent way to install software on the instance.
You are responsible for writing the script. The script should install whatever tools, software and data you want on the instance.
Benefits: Updating your software? Just launch a new instance and the script will install the latest version of your software (assuming you have written the script to always point to the latest version).
Issues: It takes longer to launch the new instance, since the software is being installed.
I am not able to find a find documents showing how can I copy a Windows instance to an Amazon S3 bucket.
Can any one help me with step by step approach to do this and suggest some of the links?
You can not copy AMIs to s3. You can either create a snapshot of your volumes or create another image (AMI).
I assume you're trying to create a backup of your AMIs. So, there are some alternatives for doing that.
Create a new AMI from an existing running image. Reference: Creating an Amazon EBS-Backed Windows AMI
Creating a Windows AMI from a Running Instance
You can create an AMI using the AWS Management Console or the command line. The following diagram summarizes the process for creating an Amazon EBS-backed AMI from a running EC2 instance. Start with an existing AMI, launch an instance, customize it, create a new AMI from it, and finally launch an instance of your new AMI. The steps in the following diagram match the steps in the procedure below. If you already have a running Amazon EBS-backed instance, you can go directly to step 4.
You can create images using the AWS CLI command create-image
Create Snapshots of your volumes, these snapshots will be stored behind the scenes in s3. Reference: Creating an Amazon EBS Snapshot
You can create EBS snapshots using the AWS CLI command create-snapshot
+ Resources
Copying an Amazon EBS Snapshot
Copying an AMI
If I create a custom AMI for an EBS backed EC2 instance after installing numerous applications and making lot of config changes to the EC2 instance like IP Tables, httpd.conf file etc...
Will the custom AMI image capture all those config changes and/or installed applications so that I can use it to launch exact functioning copy of the Custom AMI originating EC2 Instance?
Anything done after launching an EC2 instance will be independent of what the original AMI had. There isn't a relationship among the instances which use the same AMI as well; except that they all were materialised from a single AMI - the individual / independent changes in the Instances ( AMI ) would be in silos.
Coming back to your point; after making numerous changes; you would need to create an image AMI out of the running instance where the changes have been made. Going forward you can use the AMI to create new instances. Already created instances wouldn't reflect any new changes.
This is where the tools like Ansible, Chef, Puppet come into picture.
I have a running micro strategy instance in AWS (Amazon Web Services). I created a snap shot of my running instance, after which I created a AMI using the snap shot. When i tried to create a new instance with the image I was not able to create it. I am getting a failure message.
My currently running AMI is : ami-b1b9cdd8
MY AMI created from the snapshot : ami-817320e8
Kindly help me on the same
It is not possible to create a (working) AMI from a snapshot of a Windows instance. Instead, create the AMI directly from the instance (not via a snapshot).