<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>Python on {O}</title>
    <link>https://omarmakled.com/tags/python/</link>
    <description>Recent content in Python on {O}</description>
    <generator>Hugo -- 0.151.1</generator>
    <language>en-us</language>
    <atom:link href="https://omarmakled.com/tags/python/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Deploy a Python App to AWS with Elastic Beanstalk &amp; Terraform</title>
      <link>https://omarmakled.com/posts/eb-terraform/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://omarmakled.com/posts/eb-terraform/</guid>
      <description>&lt;p&gt;This example shows how to build and deploy a &lt;strong&gt;simple Python application&lt;/strong&gt; using &lt;strong&gt;AWS Elastic Beanstalk&lt;/strong&gt; for managed hosting and &lt;strong&gt;Terraform&lt;/strong&gt; for infrastructure as code. The &lt;code&gt;deploy.sh&lt;/code&gt; script automates the application packaging and deployment process.&lt;/p&gt;
&lt;hr&gt;
&lt;h3 id=&#34;project-structure&#34;&gt;Project Structure&lt;/h3&gt;
&lt;p&gt;Here&amp;rsquo;s a quick overview of the project&amp;rsquo;s key components:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;app/&lt;/code&gt;&lt;/strong&gt;: Contains the Python application, &lt;code&gt;main.py&lt;/code&gt;, along with &lt;code&gt;Procfile&lt;/code&gt; for defining the web server, and &lt;code&gt;requirements.txt&lt;/code&gt; for Python dependencies.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;terraform/&lt;/code&gt;&lt;/strong&gt;: Holds all the Terraform configuration files (&lt;code&gt;.tf&lt;/code&gt;) that define the AWS infrastructure:
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;main.tf&lt;/code&gt;: Defines the core AWS resources like the S3 bucket for application versions, IAM roles for Elastic Beanstalk, and the Elastic Beanstalk application and environment themselves.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;variables.tf&lt;/code&gt;: Declares input variables for customizability (e.g., AWS region, instance type).&lt;/li&gt;
&lt;li&gt;&lt;code&gt;outputs.tf&lt;/code&gt;: Exports important values like the S3 bucket name and the Elastic Beanstalk environment URL.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;deploy.sh&lt;/code&gt;&lt;/strong&gt;: A shell script that orchestrates the deployment process:
&lt;ul&gt;
&lt;li&gt;Reads outputs from Terraform to get dynamic values.&lt;/li&gt;
&lt;li&gt;Zips the &lt;code&gt;app/&lt;/code&gt; directory.&lt;/li&gt;
&lt;li&gt;Uploads the zipped application to the designated S3 bucket.&lt;/li&gt;
&lt;li&gt;Creates a new Elastic Beanstalk application version.&lt;/li&gt;
&lt;li&gt;Updates the Elastic Beanstalk environment to use the new version.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;hr&gt;
&lt;h3 id=&#34;how-it-works&#34;&gt;How It Works&lt;/h3&gt;
&lt;p&gt;First, Terraform provisions all necessary AWS resources for Elastic Beanstalk. Then, the &lt;code&gt;deploy.sh&lt;/code&gt; script automates the rest: it fetches deployment details from Terraform, zips your Python application, uploads it to S3, and finally, updates your Elastic Beanstalk environment with this new application version.&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
