{"id":14219,"date":"2016-06-07T18:40:18","date_gmt":"2016-06-07T14:40:18","guid":{"rendered":"http:\/\/www.msp360.com\/blog\/?p=14219"},"modified":"2021-06-09T12:04:01","modified_gmt":"2021-06-09T08:04:01","slug":"how-to-move-amazon-ec2-to-different-availability-zone-vpc-region","status":"publish","type":"post","link":"https:\/\/www.msp360.com\/resources\/blog\/how-to-move-amazon-ec2-to-different-availability-zone-vpc-region\/","title":{"rendered":"How to Move Amazon EC2 Instance to a Different Availability Zone, Virtual Private Cloud or a Region (CLI Scripts Included)"},"content":{"rendered":"<p>Moving <a href=\"https:\/\/www.msp360.com\/resources\/blog\/ec2-instance-types\/\">Amazon EC2 instance<\/a> to another Availability Zone, VPC or AWS Region may result in a headache for administrators, who think that it is a must to stop the existing and brand a new instance each time. If it\u2019s a production instance, the interruption disrupts the working process and leads to the significant money\/time losses. So, do you really have to migrate all the data manually?<!--more--><\/p>\n<p>The answer is \u201cno\u201d if you know how to properly use AWS native tools. \u00a0In this article, we explain how to easily move working Amazon EC2 instance to a different Availability Zone, VPC or AWS Region.<\/p>\n<div class=\"table-of-content \">\n\t\t\t\t<p>Table of Contents<\/p>\n\t\t\t\t<ul><\/ul>\n\t\t\t\t<\/div>\n<p>Let\u2019s get started from the step one.<\/p>\n<h2>Step 1: Create an AMI<\/h2>\n<ul>\n<li>Under the <b>EC2<\/b> section, choose <b>Instances<\/b>, right-click an instance you wish to migrate and choose \u00a0<b>Image<\/b> --&gt; <b>Create Image<\/b><\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-14221 size-full\" src=\"https:\/\/www.msp360.com\/resources\/wp-content\/uploads\/2016\/06\/aws-console-create-amazon-ec2-instance-image.png\" alt=\"AWS: change Region, Availability Zone or VPC - Creating Amazon EC2 Instance image\" width=\"1020\" height=\"590\" srcset=\"https:\/\/www.msp360.com\/resources\/wp-content\/uploads\/2016\/06\/aws-console-create-amazon-ec2-instance-image.png 1020w, https:\/\/www.msp360.com\/resources\/wp-content\/uploads\/2016\/06\/aws-console-create-amazon-ec2-instance-image-300x174.png 300w, https:\/\/www.msp360.com\/resources\/wp-content\/uploads\/2016\/06\/aws-console-create-amazon-ec2-instance-image-768x444.png 768w, https:\/\/www.msp360.com\/resources\/wp-content\/uploads\/2016\/06\/aws-console-create-amazon-ec2-instance-image-624x361.png 624w\" sizes=\"auto, (max-width: 1020px) 100vw, 1020px\" \/><\/p>\n<p><strong>Here is an AWS CLI script:<\/strong><\/p>\n<pre>@echo off\r\nset \/p id=Instance Id:\r\nset \/p name=AMI name:\r\n\"C:\\Program Files\\Amazon\\AWSCLI\\aws.exe\" ec2 create-image --instance-id %id% --name %name%\r\n<\/pre>\n<p>Now you have created an <strong>Amazon Machine Image<\/strong> \u2014 an image of the whole instance with all operating system and software configurations. Now it\u2019s time to launch.<\/p>\n<div class=\"call-to-action\">\n<div class=\"call-to-action__left\" style=\"width: 65%;\">\n<div class=\"call-to-action__tag\">FREE WHITEPAPER<\/div>\n<div class=\"call-to-action__title\">Backup and Disaster Recovery on AWS<\/div>\n<div class=\"call-to-action__text\">Every minute of downtime means money lost.<br \/>\nPlan your perfect disaster recovery strategy on AWS:<\/div>\n<!--HubSpot Call-to-Action Code --><span class=\"hs-cta-wrapper hs-cta-deferred\" id=\"hs-cta-wrapper-1877aad4-920c-45f8-a82a-42c9c41af323\" data-portal=\"5442029\" data-id=\"1877aad4-920c-45f8-a82a-42c9c41af323\"><span class=\"hs-cta-node hs-cta-1877aad4-920c-45f8-a82a-42c9c41af323\" id=\"hs-cta-1877aad4-920c-45f8-a82a-42c9c41af323\"><!--[if lte IE 8]><div id=\"hs-cta-ie-element\"><\/div><![endif]--><a href=\"https:\/\/cta-redirect.hubspot.com\/cta\/redirect\/5442029\/1877aad4-920c-45f8-a82a-42c9c41af323\" target=\"_blank\" rel=\"noopener\"><img decoding=\"async\" class=\"hs-cta-img\" id=\"hs-cta-img-1877aad4-920c-45f8-a82a-42c9c41af323\" style=\"border-width:0px;\" src=\"https:\/\/no-cache.hubspot.com\/cta\/default\/5442029\/1877aad4-920c-45f8-a82a-42c9c41af323.png\" alt=\"CTA\"><\/a><\/span><\/span><!-- end HubSpot Call-to-Action Code -->\n<\/div>\n<div class=\"call-to-action__right\" style=\"width: 35%;\"><img decoding=\"async\" src=\"https:\/\/www.msp360.com\/resources\/wp-content\/uploads\/2019\/10\/Backup-and-DR-WP-icon.png\" alt=\"WP icon\" \/><\/div>\n<\/div>\n<h2><a name=\"step2\"><\/a>Step 2: Launch created AMI in the desired Availability Zone \/ VPC \/ AWS Region<\/h2>\n<ul>\n<li>If you want to migrate EC2 instance to another region, then under the <b>EC2<\/b> section choose <b>AMIs<\/b>, <b>right-click your AMI<\/b> and choose <b>Copy AMI<\/b><\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-14222 size-full\" src=\"https:\/\/www.msp360.com\/resources\/wp-content\/uploads\/2016\/06\/aws-console-copy-image-amazon-ec2-instance.png\" alt=\"AWS: change Region, Availability Zone or VPC - Copying AMI\" width=\"958\" height=\"611\" srcset=\"https:\/\/www.msp360.com\/resources\/wp-content\/uploads\/2016\/06\/aws-console-copy-image-amazon-ec2-instance.png 958w, https:\/\/www.msp360.com\/resources\/wp-content\/uploads\/2016\/06\/aws-console-copy-image-amazon-ec2-instance-300x191.png 300w, https:\/\/www.msp360.com\/resources\/wp-content\/uploads\/2016\/06\/aws-console-copy-image-amazon-ec2-instance-768x490.png 768w, https:\/\/www.msp360.com\/resources\/wp-content\/uploads\/2016\/06\/aws-console-copy-image-amazon-ec2-instance-624x398.png 624w\" sizes=\"auto, (max-width: 958px) 100vw, 958px\" \/><\/p>\n<ul>\n<li>Select a destination region and a new name for your AMI. Switch to your destination region and go to the next section.<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-14223 size-large\" src=\"https:\/\/www.msp360.com\/resources\/wp-content\/uploads\/2016\/06\/aws-console-choose-new-region-for-new-instance-1024x693.png\" alt=\"AWS: change Region, Availability Zone or VPC - New AMI settings\" width=\"625\" height=\"423\" srcset=\"https:\/\/www.msp360.com\/resources\/wp-content\/uploads\/2016\/06\/aws-console-choose-new-region-for-new-instance-1024x693.png 1024w, https:\/\/www.msp360.com\/resources\/wp-content\/uploads\/2016\/06\/aws-console-choose-new-region-for-new-instance-300x203.png 300w, https:\/\/www.msp360.com\/resources\/wp-content\/uploads\/2016\/06\/aws-console-choose-new-region-for-new-instance-768x519.png 768w, https:\/\/www.msp360.com\/resources\/wp-content\/uploads\/2016\/06\/aws-console-choose-new-region-for-new-instance-624x422.png 624w, https:\/\/www.msp360.com\/resources\/wp-content\/uploads\/2016\/06\/aws-console-choose-new-region-for-new-instance.png 1060w\" sizes=\"auto, (max-width: 625px) 100vw, 625px\" \/><\/p>\n<p id=\"last\"><b>Here is an AWS CLI script:<\/b><\/p>\n<div id=\"slidebox\"><a class=\"close\">\u00a0<\/a><!--HubSpot Call-to-Action Code --><span class=\"hs-cta-wrapper hs-cta-deferred\" id=\"hs-cta-wrapper-23045ab4-654d-4d3e-8af6-45f3fc73419a\" data-portal=\"5442029\" data-id=\"23045ab4-654d-4d3e-8af6-45f3fc73419a\"><span class=\"hs-cta-node hs-cta-23045ab4-654d-4d3e-8af6-45f3fc73419a\" id=\"hs-cta-23045ab4-654d-4d3e-8af6-45f3fc73419a\"><!--[if lte IE 8]><div id=\"hs-cta-ie-element\"><\/div><![endif]--><a href=\"https:\/\/cta-redirect.hubspot.com\/cta\/redirect\/5442029\/23045ab4-654d-4d3e-8af6-45f3fc73419a\" target=\"_blank\" rel=\"noopener\"><img decoding=\"async\" class=\"hs-cta-img\" id=\"hs-cta-img-23045ab4-654d-4d3e-8af6-45f3fc73419a\" style=\"border-width:0px;\" src=\"https:\/\/no-cache.hubspot.com\/cta\/default\/5442029\/23045ab4-654d-4d3e-8af6-45f3fc73419a.png\" alt=\"CTA\"><\/a><\/span><\/span><!-- end HubSpot Call-to-Action Code --><\/div>\n<pre>@echo off\r\nset \/p id=AMI id:\r\nset \/p region=Source region:\r\n\"C:\\Program Files\\Amazon\\AWSCLI\\aws.exe\" ec2 copy-image --source-region us-east-1 --source-image-id %id% --name \"Migrated\"\r\n<\/pre>\n<p><strong>Note:<\/strong> Before you run the script, run \"C:\\Program Files\\Amazon\\AWSCLI\\aws.exe\" and specify your destination region as a default.<\/p>\n<ul>\n<li>If you need to move an instance to a different Availability Zone or VPC, choose <b>AMIs<\/b> under the <b>EC2<\/b> section, <b>right-click your AMI<\/b> and choose<b> Launch<\/b>. (Learn how to create <a href=\"https:\/\/www.msp360.com\/resources\/blog\/creating-and-accessing-amazon-s3-vpc-endpoint\/\">S3 VPC endpoint<\/a> if needed.)<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-14224 size-full\" src=\"https:\/\/www.msp360.com\/resources\/wp-content\/uploads\/2016\/06\/aws-console-launch-new-amazon-ec2-instance-from-ami.png\" alt=\"AWS: change Region, Availability Zone or VPC - Launching new EC2 instance from AMI\" width=\"960\" height=\"586\" srcset=\"https:\/\/www.msp360.com\/resources\/wp-content\/uploads\/2016\/06\/aws-console-launch-new-amazon-ec2-instance-from-ami.png 960w, https:\/\/www.msp360.com\/resources\/wp-content\/uploads\/2016\/06\/aws-console-launch-new-amazon-ec2-instance-from-ami-300x183.png 300w, https:\/\/www.msp360.com\/resources\/wp-content\/uploads\/2016\/06\/aws-console-launch-new-amazon-ec2-instance-from-ami-768x469.png 768w, https:\/\/www.msp360.com\/resources\/wp-content\/uploads\/2016\/06\/aws-console-launch-new-amazon-ec2-instance-from-ami-624x381.png 624w\" sizes=\"auto, (max-width: 960px) 100vw, 960px\" \/><\/p>\n<ul>\n<li>Choose an <b>Instance type<\/b> at the first step. Then choose <b>desired VPC<\/b> and <b>desired subnet<\/b> under the <b>Configure Instance Details<\/b> section. Also, you will be asked to specify other settings such as <i>Storage<\/i>, <i>Tags<\/i> and <i>Security<\/i> groups.<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-14225 size-large\" src=\"https:\/\/www.msp360.com\/resources\/wp-content\/uploads\/2016\/06\/aws-console-create-new-vpc-and-subnet-1024x717.png\" alt=\"AWS: change Region, Availability Zone or VPC - Creating new VPC and subnet\" width=\"625\" height=\"438\" srcset=\"https:\/\/www.msp360.com\/resources\/wp-content\/uploads\/2016\/06\/aws-console-create-new-vpc-and-subnet-1024x717.png 1024w, https:\/\/www.msp360.com\/resources\/wp-content\/uploads\/2016\/06\/aws-console-create-new-vpc-and-subnet-300x210.png 300w, https:\/\/www.msp360.com\/resources\/wp-content\/uploads\/2016\/06\/aws-console-create-new-vpc-and-subnet-768x537.png 768w, https:\/\/www.msp360.com\/resources\/wp-content\/uploads\/2016\/06\/aws-console-create-new-vpc-and-subnet-624x437.png 624w, https:\/\/www.msp360.com\/resources\/wp-content\/uploads\/2016\/06\/aws-console-create-new-vpc-and-subnet.png 1066w\" sizes=\"auto, (max-width: 625px) 100vw, 625px\" \/><\/p>\n<p>Now you know how to successfully migrate EC2 instance to another region, Availability Zone, VPC by using native AWS tools. Notice that you don't have to stop it to perform a migration, therefore you don't have to spend more time and money than needed.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Moving Amazon EC2 instance to another Availability Zone, VPC or AWS Region may result in a headache for administrators, who think that it is a must to stop the existing and brand a new instance each time. If it\u2019s a production instance, the interruption disrupts the working process and leads to the significant money\/time losses. [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":26987,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[877,885],"tags":[],"class_list":["post-14219","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog-articles","category-other"],"acf":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.msp360.com\/resources\/wp-json\/wp\/v2\/posts\/14219","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.msp360.com\/resources\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.msp360.com\/resources\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.msp360.com\/resources\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.msp360.com\/resources\/wp-json\/wp\/v2\/comments?post=14219"}],"version-history":[{"count":1,"href":"https:\/\/www.msp360.com\/resources\/wp-json\/wp\/v2\/posts\/14219\/revisions"}],"predecessor-version":[{"id":51236,"href":"https:\/\/www.msp360.com\/resources\/wp-json\/wp\/v2\/posts\/14219\/revisions\/51236"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.msp360.com\/resources\/wp-json\/wp\/v2\/media\/26987"}],"wp:attachment":[{"href":"https:\/\/www.msp360.com\/resources\/wp-json\/wp\/v2\/media?parent=14219"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.msp360.com\/resources\/wp-json\/wp\/v2\/categories?post=14219"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.msp360.com\/resources\/wp-json\/wp\/v2\/tags?post=14219"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}