<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Coder Legion - Recent posts tagged s3</title>
<link>https://coderlegion.com/tag/s3</link>
<description>Powered by Question2Answer</description>
<item>
<title>How Exporting AMIs to S3 Helped Me Recover Customer Resources During a DR Event</title>
<link>https://coderlegion.com/13190/how-exporting-amis-to-s3-helped-me-recover-customer-resources-during-a-dr-event</link>
<description>&lt;p&gt;A few weeks ago, we were dealing with a situation that every cloud engineer eventually faces.&lt;/p&gt;
&lt;p&gt;A &lt;strong&gt;customer environment needed to be recovered in another region&lt;/strong&gt;, and we were under time pressure.&lt;/p&gt;
&lt;p&gt;At that moment, one of the lesser-known AWS capabilities became incredibly useful.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Exporting AMIs directly to S3.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Using this approach, we were able to:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;export the machine image&lt;/li&gt;
&lt;li&gt;replicate it to another region&lt;/li&gt;
&lt;li&gt;restore it as a new AMI&lt;/li&gt;
&lt;li&gt;bring the customer workloads back online&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Without needing to &lt;strong&gt;share KMS keys or redesign the environment&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;That experience reminded me that sometimes the &lt;strong&gt;most useful AWS features are the ones people rarely talk about.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Let’s walk through how this works.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&quot;what-is-ami-store-and-restore-&quot;&gt;What is AMI Store and Restore?&lt;/h2&gt;
&lt;p&gt;AWS allows you to &lt;strong&gt;export an Amazon Machine Image (AMI) to an S3 bucket&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;Instead of keeping the AMI only inside EC2 metadata, AWS converts it into a &lt;strong&gt;portable binary artifact&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;This artifact can then be:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;archived&lt;/li&gt;
&lt;li&gt;replicated to another region&lt;/li&gt;
&lt;li&gt;restored later as a new AMI&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Think of it as &lt;strong&gt;creating a portable machine image backup.&lt;/strong&gt;&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&quot;architecture-overview&quot;&gt;Architecture Overview&lt;/h2&gt;
&lt;p&gt;&lt;img src=&quot;https://dev-to-uploads.s3.amazonaws.com/uploads/articles/smpzgen8fpe917laybs0.png&quot; alt=&quot;Image description&quot;&gt;&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&quot;step-1-export-the-ami-to-s3&quot;&gt;Step 1 — Export the AMI to S3&lt;/h2&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;aws ec2 create-store-image-task \
--image-id ami-xxxx \
--bucket demo-dr-us-east-1-backup \
--region us-east-1
&lt;/code&gt;&lt;/pre&gt;
&lt;blockquote&gt;&lt;p&gt;AWS converts the AMI into a &lt;strong&gt;compressed &lt;code&gt;.bin&lt;/code&gt; artifact&lt;/strong&gt;.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Example response:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-json&quot;&gt;{
 &quot;ObjectKey&quot;: &quot;ami-xxxx.bin&quot;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;hr&gt;
&lt;h2 id=&quot;step-2-monitor-the-export-task&quot;&gt;Step 2 — Monitor the Export Task&lt;/h2&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;aws ec2 describe-store-image-tasks \
--region us-east-1
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Possible states:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;InProgress&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Completed&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Failed&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote&gt;&lt;p&gt;Once completed, the artifact appears in S3.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;hr&gt;
&lt;h2 id=&quot;step-3-verify-in-s3&quot;&gt;Step 3 — Verify in S3&lt;/h2&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;aws s3 ls s3://demo-dr-us-east-1-backup
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Example output:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-plaintext&quot;&gt;ami-0abc123.bin
&lt;/code&gt;&lt;/pre&gt;
&lt;hr&gt;
&lt;h2 id=&quot;step-4-replicate-to-another-region&quot;&gt;Step 4 — Replicate to Another Region&lt;/h2&gt;
&lt;p&gt;Using &lt;strong&gt;S3 Cross Region Replication (CRR)&lt;/strong&gt;, the artifact can automatically move to another region.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-plaintext&quot;&gt;Primary Region (USA)
        │
        ▼
S3 Bucket
        │
        │ CRR
        ▼
Backup Region (Mumbai)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This ensures the AMI artifact is safely stored in the DR region.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&quot;step-5-restore-the-ami&quot;&gt;Step 5 — Restore the AMI&lt;/h2&gt;
&lt;p&gt;From the destination region:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;aws ec2 create-restore-image-task \
--bucket demo-dr-ap-south-1-backup \
--object-key ami-xxxx.bin \
--name restored-ami \
--region ap-south-1
&lt;/code&gt;&lt;/pre&gt;
&lt;blockquote&gt;&lt;p&gt;This creates a &lt;strong&gt;new AMI&lt;/strong&gt;.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;strong&gt;Check for the progess in the destination region AMI Console&lt;/strong&gt;&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&quot;step-6-launch-the-instance&quot;&gt;Step 6 — Launch the Instance&lt;/h2&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;aws ec2 run-instances \
--image-id ami-new \
--instance-type t3.medium
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And the system is restored.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&quot;what-happens-with-kms-encrypted-amis-&quot;&gt;What Happens with KMS Encrypted AMIs?&lt;/h2&gt;
&lt;p&gt;During export:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;AWS internally decrypts the snapshots&lt;/li&gt;
&lt;li&gt;packages them into the artifact&lt;/li&gt;
&lt;li&gt;restores them in the destination region with new encrypted snapshots&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This means &lt;strong&gt;you don’t need to share KMS keys across regions&lt;/strong&gt;, which is often restricted in enterprise environments.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&quot;when-should-you-use-this-&quot;&gt;When Should You Use This?&lt;/h2&gt;
&lt;p&gt;This approach is great for:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;enterprise DR strategies&lt;/li&gt;
&lt;li&gt;KMS encrypted instance migrations&lt;/li&gt;
&lt;li&gt;long term infrastructure backups&lt;/li&gt;
&lt;li&gt;cross account migrations&lt;/li&gt;
&lt;li&gt;compliance driven archival&lt;/li&gt;
&lt;/ul&gt;
&lt;hr&gt;
&lt;h3 id=&quot;disclaimer-large-ami-exports-may-take-time&quot;&gt;Disclaimer: Large AMI Exports May Take Time&lt;/h3&gt;
&lt;p&gt;When using create-store-image-task, the AMI is exported and stored in Amazon S3 as a binary .bin file.&lt;/p&gt;
&lt;p&gt;If the AMI contains large EBS volumes, the resulting artifact can be tens or even hundreds of gigabytes.&lt;/p&gt;
&lt;p&gt;In such cases, AWS uploads the image to S3 using multipart upload.&lt;/p&gt;
&lt;p&gt;This means:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The export process can take significant time depending on the AMI size.&lt;/li&gt;
&lt;li&gt;Multiple parts are uploaded in parallel to improve reliability.&lt;/li&gt;
&lt;li&gt;The .bin file will only appear in S3 after the export task is completed.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Because of this, it's important to monitor the store task status before assuming the artifact is available.&lt;/p&gt;
&lt;p&gt;You can check the task prsk progress using:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;aws ec2 describe-store-image-tasks --region &amp;lt;region&amp;gt;&lt;/code&gt;&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&quot;final-thoughts&quot;&gt;Final Thoughts&lt;/h2&gt;
&lt;p&gt;Most AWS engineers never touch &lt;strong&gt;store-image-task&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;But it’s one of those hidden features that becomes incredibly useful when things go wrong.&lt;/p&gt;
&lt;p&gt;In disaster recovery planning, the goal isn’t just &lt;strong&gt;backup&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;The goal is &lt;strong&gt;portability and recovery independence&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;Exporting AMIs to S3 gives you exactly that.&lt;/p&gt;
</description>
<category>Articles</category>
<guid isPermaLink="true">https://coderlegion.com/13190/how-exporting-amis-to-s3-helped-me-recover-customer-resources-during-a-dr-event</guid>
<pubDate>Thu, 19 Mar 2026 11:29:37 +0000</pubDate>
</item>
</channel>
</rss>