<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by DJ. KONE on Medium]]></title>
        <description><![CDATA[Stories by DJ. KONE on Medium]]></description>
        <link>https://medium.com/@djakkone?source=rss-dc23c840bbd4------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*qZWClQTIxr7Y12PUZThh9Q.jpeg</url>
            <title>Stories by DJ. KONE on Medium</title>
            <link>https://medium.com/@djakkone?source=rss-dc23c840bbd4------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 28 May 2026 17:06:07 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@djakkone/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com" rel="hub"/>
        <item>
            <title><![CDATA[Using Terraform To Deploy a Web Server and Run a Bootstrap Script]]></title>
            <link>https://medium.com/@djakkone/using-terraform-to-deploy-a-web-server-and-run-a-bootstrap-script-995d8b370f8c?source=rss-dc23c840bbd4------2</link>
            <guid isPermaLink="false">https://medium.com/p/995d8b370f8c</guid>
            <category><![CDATA[deployment]]></category>
            <category><![CDATA[web-server]]></category>
            <category><![CDATA[terraform]]></category>
            <category><![CDATA[bootstrap-script]]></category>
            <category><![CDATA[database]]></category>
            <dc:creator><![CDATA[DJ. KONE]]></dc:creator>
            <pubDate>Fri, 31 Oct 2025 16:43:33 GMT</pubDate>
            <atom:updated>2025-10-31T16:43:33.938Z</atom:updated>
            <content:encoded><![CDATA[<p>Terraform isn’t just for big, end-to-end projects. As a Cloud or DevOps engineer, you’ll often work on smaller but critical tasks like creating and connecting a database server, setting up a security group, or running a bootstrap script on a web server.</p><p>Read more: <a href="https://cloudwithdj.com/using-terraform-to-deploy-a-web-server-and-run-a-bootstrap-script/">https://cloudwithdj.com/using-terraform-to-deploy-a-web-server-and-run-a-bootstrap-script/</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6QhT9hzqskjXiHSH_Ultbw.png" /></figure><p>Terraform isn’t just for big, end-to-end projects. As a Cloud or DevOps engineer, you’ll often work on smaller but critical tasks like creating and connecting a database server, setting up a security group, or running a bootstrap script on a web server.</p><p>For beginners, these tasks are great practice because they reflect what you’ll do in enterprise environments. I created a step-by-step tutorial to walk you through some of the daily tasks you might encounter.</p><p>This tutorial walks you through deploying a simple AWS setup using Terraform. You’ll create a database server, a web server with a fixed IP address, configure security groups, and run a bootstrap script on the web server.</p><p>Read more: <a href="https://cloudwithdj.com/using-terraform-to-deploy-a-web-server-and-run-a-bootstrap-script/">https://cloudwithdj.com/using-terraform-to-deploy-a-web-server-and-run-a-bootstrap-script/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=995d8b370f8c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mastering IAM: Using Boto3 to Manage AWS Resources with Python Scripts]]></title>
            <link>https://medium.com/@djakkone/mastering-iam-using-boto3-to-manage-aws-resources-with-python-scripts-cbe32444518a?source=rss-dc23c840bbd4------2</link>
            <guid isPermaLink="false">https://medium.com/p/cbe32444518a</guid>
            <category><![CDATA[boto3]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[aws-iam]]></category>
            <category><![CDATA[sdk]]></category>
            <dc:creator><![CDATA[DJ. KONE]]></dc:creator>
            <pubDate>Thu, 28 Nov 2024 19:04:42 GMT</pubDate>
            <atom:updated>2024-12-15T01:37:42.557Z</atom:updated>
            <content:encoded><![CDATA[<p>In this tutorial, I will show you how Boto3 can be used to directly interact with AWS resources from Python scripts.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*I0hrMEMNDO3DihgrZbOeEQ.png" /></figure><p>If you’re diving into AWS with Python, <strong>Boto3</strong> is the go-to library. It’s the official SDK that makes it easy to interact with AWS resources directly from your Python scripts. In this guide, I’ll walk through how to use Boto3 to handle various tasks with AWS Identity and Access Management (IAM).</p><p>With IAM, you can:</p><ul><li>Create new users</li><li>Manage permissions</li><li>Set up policies</li><li>And so much more.</li></ul><h3>Prerequisite</h3><p>Before we dive into the code, make sure you’ve got these set up:</p><ul><li><strong>Python 3</strong>: Install it if you don’t already have it.</li><li><strong>Boto3</strong>: You can install it with pip: <strong><em>pip install boto3.</em></strong></li><li><strong>AWS Credentials</strong>: You’ll need these to access your AWS account. See below:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SmULehX3omfmECt63lBMLQ.png" /></figure><h3>How to create a user</h3><p>When you set up a new AWS account, it’s a best practice to create a dedicated IAM user instead of using your root account for day-to-day tasks.</p><ul><li>create a python file <strong><em>createuser.py</em></strong> with the code below in the file</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7iF_pcHevV_-ouiayl1ZCA.png" /></figure><ul><li>Run python createuser.py</li><li>You should see this below in your terminal.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*17UlWGeyA7stIMVvh2J_TQ.png" /></figure><ul><li>Go to your AWS console, you should see the user has been created.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rtO4GL1Ri6jOaICGkqPjog.png" /></figure><h3>How to List All IAM Users</h3><ul><li>create a python file with the following code</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cj4Ar9HowWna2sxwRufdYw.png" /></figure><ul><li>Run it. Here is the result.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gmmMA9a20vG1jdO8h6wkHA.png" /></figure><h3>How to Update a User</h3><p>Need to rename an IAM user? AWS lets you update a user’s details with Boto3’s <strong>update_user</strong> function. This is especially useful when renaming users to align with new naming conventions or correcting a mistake.</p><ul><li>create a python file with this code</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qpsv9K2lpw0ulcPU4AjonA.png" /></figure><ul><li>Here is the result in your terminal.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gcw1mqm-lecLRdD-m4DRqA.png" /></figure><ul><li>You should see the change in your aws console.</li></ul><h3>How to Create an IAM Policy</h3><p>An IAM policy defines the actions a user or group can perform and the resources those actions apply to. With Boto3, you can create custom policies tailored to your specific access control needs. Let’s walk through creating a policy that grants access to specific actions in DynamoDB.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*i5rkqOD5bJzVSjizB611zQ.png" /></figure><ul><li>Go to the IAM console. Click on poloicies and see new policy.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gjeD_HeyVCOz-BubE0FjYA.png" /></figure><h3>How to List All IAM Policies</h3><p>To efficiently manage permissions in your AWS account, it’s essential to know which IAM policies exist. Using Boto3, we can retrieve a list of IAM policies, filtering for those created within your account.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*n5gg6GoR2tvNFoyw80DWpw.png" /></figure><h3>How to Attach a Policy to a User</h3><p>Attaching IAM policies to individual users is essential for granting specific permissions. Below is a step-by-step guide using Boto3 to attach a policy to a user.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GfpVttu0CXlzMr4IQ0rWlQ.png" /></figure><h3>How to Create a Group</h3><p>When managing permissions in AWS, creating groups helps streamline the process. Instead of attaching policies to individual users, you can attach policies to a group. All users added to the group inherit the permissions of the group’s policies.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vKexVFIs0Wdlm8PT6cM1dg.png" /></figure><h3>How to Add a User to a Group</h3><p>In AWS Identity and Access Management (IAM), users can be added to groups to inherit the permissions attached to the group. This is an efficient way to manage user permissions across your AWS account.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*b9yOvv0aQz3mUidcHRPseg.png" /></figure><h3>How to Attach an IAM Policy to a Group</h3><p>Attaching a policy to a group allows all users in that group to inherit the permissions defined in the policy. This streamlines permission management for multiple users.</p><p>Find the python code here: <a href="https://github.com/djcloudking/aws-skills-challenges/blob/main/15_AWS%20IAM/attachpolicytogroup.py">https://github.com/djcloudking/aws-skills-challenges/blob/main/15_AWS%20IAM/attachpolicytogroup.py</a></p><h3>How to Create an IAM Role</h3><p>An IAM role is a secure way to grant permissions to AWS services or users. The creation of a role requires defining a <strong>trust relationship policy</strong> to specify which entities (such as AWS services) can assume the role.</p><p>Find the python code here: <a href="https://github.com/djcloudking/aws-skills-challenges/blob/main/15_AWS%20IAM/iamrole.py">https://github.com/djcloudking/aws-skills-challenges/blob/main/15_AWS%20IAM/iamrole.py</a></p><h3>How to Attach an IAM Policy to a Role</h3><p>An IAM policy defines the permissions for an IAM role. You can attach policies to a role using the attach_role_policy method provided by the AWS SDK (boto3).</p><p>Find the python code here: <a href="https://github.com/djcloudking/aws-skills-challenges/blob/main/15_AWS%20IAM/attachiampolicytorole.py">https://github.com/djcloudking/aws-skills-challenges/blob/main/15_AWS%20IAM/attachiampolicytorole.py</a></p><p>— — — — —</p><p>Thank you for reading and/or following along! Leave us a clap or a comment, Share &amp; Follow. Please stay tuned for all my upcoming projects.</p><p>— — — — — — -</p><p>🛠 Want more? Subscribe to my Newsletter and receive daily AWS cloud updates in your mailbox ➡<a href="https://substack.com/@whatsnewinthecloud"> My Newsletter</a></p><p>🕒If you haven’t read my earlier articles on AWS services, cloud-native technologies &amp; DevOps tools, be sure to visit my blog and catch up ➡ <a href="https://cloudwithdj.com/blog/">My Blog</a></p><p>♻ Want more? Discover my comprehensive Cloud tutorials and projects ➡ <a href="https://github.com/djcloudking?tab=repositories">My Cloud Projects Repo</a></p><p>Contact me directly on <a href="https://www.linkedin.com/in/djakaridiakone/">LinkedIn</a> or <a href="http://info@fahmacloud.com/">Email</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cbe32444518a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Terraform Implementation: Create EKS Cluster using Terraform Modules]]></title>
            <link>https://medium.com/@djakkone/terraform-implementation-create-eks-cluster-using-terraform-modules-f6fa503df2dc?source=rss-dc23c840bbd4------2</link>
            <guid isPermaLink="false">https://medium.com/p/f6fa503df2dc</guid>
            <category><![CDATA[aws-eks]]></category>
            <category><![CDATA[terraform]]></category>
            <category><![CDATA[modules]]></category>
            <category><![CDATA[kubernetes]]></category>
            <dc:creator><![CDATA[DJ. KONE]]></dc:creator>
            <pubDate>Tue, 19 Nov 2024 23:21:24 GMT</pubDate>
            <atom:updated>2024-12-15T01:37:36.992Z</atom:updated>
            <content:encoded><![CDATA[<p>In this short lab, I will show you how to create an EKS Cluster properly using Terraform.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-Vy9LGs1ZwDmkaoxUz7jWg.png" /></figure><p>Usually, you’d create a `main.tf` file and put all the resources needed to set up your EKS cluster in one place. But this time, you’ll be using Terraform modules instead.</p><p>Modules make things a lot easier to manage. For example, if you need to update inbound rules, you just go to `vpc.tf` instead of digging through `main.tf`. It keeps things organized and makes troubleshooting so much simpler. I actually wrote a blog about <a href="https://medium.com/@djakkone/troubleshooting-terraform-use-terraform-modules-to-address-common-issues-74d80d1a066d">troubleshooting using terraform modules</a>, check it out.</p><h3>PREREQUESITES</h3><ul><li>AWS account access</li><li>Knowledge of Kubernetes</li></ul><h3>Step 1: Create the architecture</h3><p>This structure shows the key components and their roles in deploying the EKS cluster:</p><p>EKS Cluster Deployment<br>├── VPC Module<br>│ ├── Subnets<br>│ ├── Route Tables<br>│ └── Internet Gateway<br>├── EKS Module<br>│ ├── Worker Nodes<br>│ └── Control Plane<br>├── Security Group Module<br>│ ├── Ingress Rules<br>│ └── Egress Rules<br>├── Variables<br>│ ├── VPC Configuration<br>│ ├── EKS Cluster Settings<br>│ └── Security Group Parameters<br>├── Versions<br>│ ├── Terraform Version<br>│ ├── AWS Provider Version<br>│ └── Kubernetes Provider Version<br>└── Outputs<br> ├── VPC ID<br> ├── EKS Cluster Name<br> └── Security Group IDs</p><h3>Step 2: Install AWS CLI</h3><ul><li>Follow the below link to Install AWS CLI.</li></ul><pre>https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html</pre><h3>Step 3: Install Terraform (on your local machine)</h3><ul><li>Next, Install Terraform using the below link.</li></ul><pre>https://developer.hashicorp.com/terraform/tutorials/aws-get-started/install-cli</pre><h3>Step 4: Connect Terraform to AWS</h3><ul><li>For Terraform to speak with AWS, you need AWS credentials. Download Access keys</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*h8pUR6IV_uPHEvzM3MkRWQ.png" /></figure><h3>Step 5: Create Terraform modules</h3><p>These are the 6 files you will create to deploy your eks cluster:</p><ul><li>Create VPC module</li><li>Create EKS module</li><li>Create Security Groupe module</li><li>Create variables</li><li>Create version</li><li>Create output</li></ul><p>Find the modules in this repository: <a href="https://github.com/djcloudking/terraform-challenges/tree/main/11_Create%20a%20EKS%20Cluster%20using%20Terraform%20Modules">https://github.com/djcloudking/terraform-challenges/tree/main/11_Create%20a%20EKS%20Cluster%20using%20Terraform%20Modules</a></p><h3>Step 6: Run Terraform</h3><ul><li><strong>Initialize Terraform</strong><br>Run terraform init. This step sets up the Terraform environment, downloading necessary modules, providers, and configurations.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LprN3wJqVi-N6fZynvy6MA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V8atChQWlGYKaBMJONuplA.png" /></figure><ul><li><strong>Review the Terraform Configuration (Optional)</strong><br>Use terraform plan to preview the infrastructure changes Terraform will apply. This helps ensure the configuration aligns with your expectations before deployment.</li><li><strong>Apply the Terraform Configuration</strong><br>Execute terraform apply to deploy the EKS cluster along with the VPC. Terraform will handle the creation process seamlessly.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GitrStcwzQ6fli6_xUCDYg.png" /></figure><p>Your EKS cluster has been deployed successfully. And the other resources stated above.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*orNvG1w5YJdqHZhKH2ygJw.png" /></figure><h3>Step 7: Secure EKS cluster</h3><ul><li>Go to EKS console. Click on your cluster.</li><li>Go to access tab. Copy the access entry. If you don’t have one, click <strong><em>Create Access entry.</em></strong></li><li>Navigate back to the compute tab, you should see the node group and the desire state.</li><li>You have successfully secure your EKS cluster, not everyone should get access to it.</li></ul><p>That’s all, folks! Following the steps above will enable you to create EKS cluster using Terraform modules.</p><p>— — — — —</p><p>Thank you for reading and/or following along! Leave us a clap or a comment, Share &amp; Follow. Please stay tuned for all my upcoming projects.</p><p>— — — — — — -</p><p>🛠 Want more? Subscribe to my Newsletter and receive daily AWS cloud updates in your mailbox ➡<a href="https://substack.com/@whatsnewinthecloud"> My Newsletter</a></p><p>🕒If you haven’t read my earlier articles on AWS services, cloud-native technologies &amp; DevOps tools, be sure to visit my blog and catch up ➡ <a href="https://cloudwithdj.com/blog/">My Blog</a></p><p>♻ Want more? Discover my comprehensive Cloud tutorials and projects ➡ <a href="https://github.com/djcloudking?tab=repositories">My Cloud Projects Repo</a></p><p>Contact me directly on <a href="https://www.linkedin.com/in/djakaridiakone/">LinkedIn</a> or <a href="http://info@fahmacloud.com/">Email</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f6fa503df2dc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Cost-Effective Management for AWS CI/CD Infrastructure using Python and Lambda.]]></title>
            <link>https://medium.com/@djakkone/cost-effective-management-for-aws-ci-cd-infrastructure-using-python-and-lambda-dfb01630ac45?source=rss-dc23c840bbd4------2</link>
            <guid isPermaLink="false">https://medium.com/p/dfb01630ac45</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[aws-lambda]]></category>
            <category><![CDATA[ci-cd-pipeline]]></category>
            <category><![CDATA[cost-optimization]]></category>
            <dc:creator><![CDATA[DJ. KONE]]></dc:creator>
            <pubDate>Wed, 13 Nov 2024 19:36:28 GMT</pubDate>
            <atom:updated>2024-12-15T01:37:33.706Z</atom:updated>
            <content:encoded><![CDATA[<p>In this tutorial, I will show you how to streamline CI/CD Cost Management with Python Scripts and AWS Lambda.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*idEDm_CxU1Xo91UNxYiQcg.png" /></figure><h3><strong>Scenario</strong></h3><p>Consider your DevOps team using a development lab for application testing, where AWS EC2 instances in the lab run continuously. Your management raises concerns about the escalating costs, as these instances operate 24/7 even when the team isn’t working.</p><h3>Solution</h3><p>The task is clear: implement an automated solution that provides the necessary CI/CD environment while reducing unnecessary expenses.</p><p>To address this, we can automate instance management by using a Python script combined with AWS Lambda. The script will target EC2 instances tagged as “Dev,” stopping them outside of active work hours.</p><h3>Prerequisites</h3><ul><li>Python installed.</li><li>AWS CLI installed</li><li>AWS account with necessary IAM permissions.</li><li>Knowledge of AWS Lambda, EC2, and Boto3 documentation</li></ul><h3>Step 1: Define the Scope</h3><p>Since costs are primarily associated with development environments, we’ll focus on EC2 instances tagged “Dev” in our solution. This tag will enable our Python script to identify and manage only the relevant resources.</p><p>Below is a snapshot of the EC2 fleet used by our developers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nle1uWUp6gMdFJDGu6jvnQ.png" /></figure><h3>Step 2: Write the Python Script</h3><p>Our Python script uses Boto3, the AWS SDK for Python, to interact with AWS services.</p><p><strong>Script Flow:</strong></p><ul><li>Imports Boto3 to interact with AWS.</li><li>Creates an EC2 client for a specified region</li><li>Fetches a list of all running instances.</li><li>Filters for instances tagged “Dev” and stops them.</li><li>Outputs the IDs of the stopped instances for verification.</li></ul><p><strong>Script Breakdown:</strong></p><ul><li>Imports necessary modules.</li><li>Identifies “Dev” instances using specific tag criteria.</li><li>Stops the instances and confirms successful execution.</li></ul><p>Before all of this, you should make sure your AWS is configured.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/654/1*aBD5A3zJafox0wb5UyqAoQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZbaSXb5t3ZNZbjJjC9LUmw.png" /></figure><h3>Step 3: Test the Script</h3><ul><li>Run the script manually to verify it’s stopping only the desired “Dev” instances. You’ll see confirmation of which instances were stopped, displayed both in the console and the EC2 dashboard.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*De7bCu5daphhvsdcm2jrfQ.png" /></figure><p>Verify from the console:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IpMXTX2VhJWJj31neww_fA.png" /></figure><ul><li>Run the script again. Based on our script you should get an error message.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LHtcPN1ADcP1TdhXQJSUYQ.png" /></figure><h3>Step 4: Automate with AWS Lambda</h3><p>It’s time to fully automate this process. Make sure we don’t need a human to run the python script.</p><p>First, create a Lambda function with your Python script.</p><ul><li>In the Lambda console, create a new function with Python as the runtime.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/658/1*9ivIUIEEVmi7JpKq2qLnIA.png" /></figure><ul><li>Paste your Python script into the function’s code editor and save.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WIbAoQ2V9qiex-hDsQ7gcg.png" /></figure><p>Second, configure AWS EventBridge to trigger this Lambda function on a schedule, such as weekdays at 7 p.m. after the team’s working hours.</p><ul><li>Use EventBridge to set a cron job to trigger the Lambda function according to your desired schedule.</li><li>From our Lambda Function, copy the function ARN and Click “Add Trigger”</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gYWoWcE151mHRtER0OS2uw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/991/1*q87E5H_9mvjD5FiKgUtWPA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UeULay9BcIlwaqdQhmDxEQ.png" /></figure><ul><li>Trigger has been created.</li></ul><p>With Lambda and EventBridge, the script will run automatically, stopping the “Dev” instances on schedule, eliminating human error and further controlling costs.</p><h3>Step 5: Test the Lambda Function</h3><ul><li>Lastly, it’s time to test our Lambda function. To do so, let’s ensure that we have at least ONE Dev Instance running in our EC2 Instance Dashboard.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cYl0Ey3jN-qTvB9FDfrtFA.png" /></figure><ul><li>Run the Lambda function to confirm it performs as expected. Check the EC2 dashboard to ensure that only “Dev” instances were stopped.</li></ul><h4>Challenge:</h4><p>After testing lambda, I encountered this error message:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*36g9-iJ3_c0mKGQ8jSPTVA.png" /></figure><p>The error indicates that the Lambda function does not have permission to stop EC2 instances. The IAM role attached to the function does not have the necessary permissions to allow the <strong><em>ec2:StopInstances</em></strong> action on the specified instance.</p><h4>My Solution:</h4><p>If you don’t have permissions to do the following changes, contact your AWS Administrator. In my case, this what I did:</p><ul><li>Go to the <strong><em>IAM console</em></strong> and select the ‘<strong><em>Lambdaec2describerole</em></strong>’ role.</li><li>Click on ‘<strong><em>Add permissions</em></strong>’ and then ‘<strong><em>Create inline policy</em></strong>’.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oj4L5HsTrXh_K6whhSXxPA.png" /></figure><ul><li>In the JSON editor, add the following policy:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TySbSRSgURuCGAE9JXTgew.png" /></figure><ul><li>Click ‘<strong><em>Review policy</em></strong>’ and give it a name like ‘<strong><em>AllowStopEC2Instance</em></strong>’.</li><li>Click ‘<strong><em>Create policy</em></strong>’ to attach the new inline policy to the ‘Lambdaec2describerole’ role.</li><li><strong>Re-test your Lambda function, everything will work fine.</strong></li></ul><p>If you haven’t experienced this issue, it shouldn’t be a concern.</p><p>With this automated solution, you’ve successfully managed the cost of your CI/CD environment, ensuring it serves the team’s needs without unnecessary expense or oversight. This approach minimizes manual intervention, optimizes performance, and keeps your DevOps processes streamlined.</p><p>— — — — —</p><p>Thank you for reading and/or following along! Leave us a clap or a comment, Share &amp; Follow. Please stay tuned for all my upcoming projects.</p><p>— — — — — — -</p><p>🛠 Want more? Subscribe to my Newsletter and receive daily AWS cloud updates in your mailbox ➡<a href="https://substack.com/@whatsnewinthecloud"> My Newsletter</a></p><p>🕒If you haven’t read my earlier articles on AWS services, cloud-native technologies &amp; DevOps tools, be sure to visit my blog and catch up ➡ <a href="https://cloudwithdj.com/blog/">My Blog</a></p><p>♻ Want more? Discover my comprehensive Cloud tutorials and projects ➡ <a href="https://github.com/djcloudking?tab=repositories">My Cloud Projects Repo</a></p><p>Contact me directly on <a href="https://www.linkedin.com/in/djakaridiakone/">LinkedIn</a> or <a href="http://info@fahmacloud.com/">Email</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dfb01630ac45" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Automating Image Analysis in a photo-sharing application with AWS Lambda, S3, Rekognition, and…]]></title>
            <link>https://medium.com/@djakkone/automating-image-analysis-in-a-photo-sharing-application-with-aws-lambda-s3-rekognition-and-cb00e6271d3c?source=rss-dc23c840bbd4------2</link>
            <guid isPermaLink="false">https://medium.com/p/cb00e6271d3c</guid>
            <category><![CDATA[recognition]]></category>
            <category><![CDATA[dynamodb]]></category>
            <category><![CDATA[lambda]]></category>
            <category><![CDATA[aws-serverless-services]]></category>
            <dc:creator><![CDATA[DJ. KONE]]></dc:creator>
            <pubDate>Wed, 09 Oct 2024 05:30:12 GMT</pubDate>
            <atom:updated>2024-12-15T01:37:29.525Z</atom:updated>
            <content:encoded><![CDATA[<h3>Automating Image Analysis in a photo-sharing application with AWS Lambda, S3, Rekognition, and DynamoDB using CDK and Python</h3><p>This short tutorial is the perfect example of how to use CDK with Python to automate a workflow. Read below for more details.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/942/1*h2f016tQOWq_XP-VrzU1qA.png" /></figure><h3>Scenario</h3><p>You have a photo-sharing application where users can upload images, and you’d like to automatically analyze each image as soon as it’s uploaded.</p><p>Once the image is uploaded to an S3 bucket, AWS Rekognition will be used to analyze the photo, identifying key details like objects and scenes. The results of this analysis should be stored in DynamoDB, allowing each user to view details about their uploaded photos. AWS Lambda will manage the process of analyzing the image and saving the results, and you’ll use AWS CDK in Python to set up this automated workflow.</p><h3>Architecture</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/942/1*h2f016tQOWq_XP-VrzU1qA.png" /></figure><h3>Project Outline</h3><p>In this tutorial, we’re going to set up a simple workflow that automatically analyzes images whenever they’re uploaded to an S3 bucket. We’ll use AWS Rekognition to handle the image analysis, and the results will be saved in DynamoDB. AWS Lambda will take care of orchestrating everything behind the scenes, and we’ll use the AWS Cloud Development Kit (CDK) in Python to build it all.</p><h3>Pre-requisite</h3><ul><li>AWS account with admin rights</li><li>Knowledge of CDK, Python, Javascript</li></ul><h3>Now, let’s have fun</h3><h3>Step 1. Install the CDK in our environment</h3><ul><li>Go to you AWS console.</li><li>Open Cloudshell.</li><li>Run sudo npm install -g aws-cdk-lib</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fqUvwa-swvH1om_GVHv5IA.png" /></figure><p><strong><em>Cheat Sheet: directory name must be cdk-app/ to go with the rest of the tutorial, changing it will cause an error</em></strong></p><ul><li>Create a directory mkdir cdk-app</li><li>Move in the directory cd cdk-app/</li><li>Now, initialize the application cdk init app-language</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YbK9kptzwy8Dwp_Ge-xC8Q.png" /></figure><ul><li>Always verify if it works correctly cdk ls</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1neHXtMmq2nEAiXRQwMTmQ.png" /></figure><h3>Step 2. Copy the content of cdk-app-stack.js into lib/cdk-app-stack.js</h3><ul><li>List the contents of <strong>lib/</strong> and go inside the folder</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*liB8zGdHJKpCa5epHAdFuQ.png" /></figure><ul><li>Remove the content: rm cdk-app-stack.js and create new content touch cdk-app-stack.js</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KucjD_nYX_zpXUUFq993XA.png" /></figure><ul><li>Open the new file: nano cdk-app-stack.js</li><li>Copy the content of cdk-app-stack.js located in this code repository: <a href="https://github.com/djcloudking/python-challenges/blob/main/95_Python%20project%206/lib/cdk-app-stack.js">https://github.com/djcloudking/python-challenges/blob/main/95_Python%20project%206/lib/cdk-app-stack.js</a> and paste it in cloudshell</li><li>Run cat cdk-app-stack.jsto verify if everything is there.</li></ul><h3>Step 3. Setup the Lambda function</h3><ul><li>Back to cdk-app, verify if lambda function does not exist yet.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nnZ4CG_ItdDtw8CYvGOpMg.png" /></figure><ul><li>If no, create a new lambda directory mkdir lambda &amp;&amp; cd lambda</li><li>Then, create a python file touch index.py. Edit it with nano index.py.</li><li>Copy the python code in this repository: <a href="https://github.com/djcloudking/python-challenges/blob/main/95_Python%20project%206/lambda/index.py">https://github.com/djcloudking/python-challenges/blob/main/95_Python%20project%206/lambda/index.py</a> and paste it.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RIgYSG81k6D4vAdX2K3BBg.png" /></figure><ul><li>Verify if the code has been copied using cat index.py</li></ul><h3>Step 4. Bootstrap the CDK application</h3><ul><li>It’s time to bootstrap our cdk application cdk bootstrap</li><li>Run cdk bootstrap . You should see a message asking you to specify an environment name.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YT41LJOdOmQt713-8mTgVQ.png" /></figure><ul><li>Go one level down with cd ..</li><li>Run again cdk bootstrap</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mQmeDYsavzJxDUnocZI34w.png" /></figure><h3>Step 5. Synthesize as a CloudFormation template</h3><ul><li>Go to CloudFormation console and verify if something has been created</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4H6VISS-1ZiZfIudQ9ZbaA.png" /></figure><ul><li>Now, run cdk synth to target cloudformation template that is going to be created and deployed to the cloudformation stack.</li></ul><h3>Step 6. deploy the CDK stack</h3><ul><li>Finally, deploy the cdk stack: cdk deploy</li><li>If asked, enter Y to continue the deployment</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8r_sopcgUN1EH3VOkN1h1w.png" /></figure><ul><li>At the end of the deployment of the CDK, you will see a new stack in cloudformation</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bydD2hYcGf1toO6sWHsCog.png" /></figure><h3>Step 7 — Verify S3 bucket and DynamoDB table</h3><ul><li>Go to AWS S3 dashboard.</li><li>Select a bucket and upload a picture in the bucket.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YE3UV9cVwCU2KB6kMUb1SQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*FFx-ruH2LSuzkWFA" /></figure><ul><li>If our CDK has been deployed correctly, we will see the description of this picture in our DynamoDB table.</li><li>Go to the DynamoDB table. Click on explore items.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A_uEquk6BBplRe85d2LBaA.png" /></figure><ul><li>As we intended, a Lambda function is triggered when an image is uploaded to the S3 bucket. Rekognition analyzes the picture and sends the results to DynamoDB.</li><li>Let’s try again with different images.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/996/1*ZJacII94_zEsBZ9uZnp8Xw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*T7UkKKhhX-T-fbn8" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uPxQr7oRIIGBCArOPtUVow.png" /></figure><p>By following this tutorial, you have successfully created a serverless solution that analyzes images using AWS Rekognition and stores the results in DynamoDB, all orchestrated via CDK in Python. This pipeline can be extended to handle more complex workflows or scaled for production use.</p><p>— — — — —</p><p>Thank you for reading and/or following along! Leave us a clap or a comment, Share &amp; Follow. Please stay tuned for all my upcoming projects.</p><p>— — — — — — -</p><p>🛠 Want more? Subscribe to my Newsletter and receive daily AWS cloud updates in your mailbox ➡<a href="https://substack.com/@whatsnewinthecloud"> My Newsletter</a></p><p>🕒If you haven’t read my earlier articles on AWS services, cloud-native technologies &amp; DevOps tools, be sure to visit my blog and catch up ➡ <a href="https://cloudwithdj.com/blog/">My Blog</a></p><p>♻ Want more? Discover my comprehensive Cloud tutorials and projects ➡ <a href="https://github.com/djcloudking?tab=repositories">My Cloud Projects Repo</a></p><p>Contact me directly on <a href="https://www.linkedin.com/in/djakaridiakone/">LinkedIn</a> or <a href="http://info@fahmacloud.com/">Email</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cb00e6271d3c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Three Tier Architecture: Deploying a dynamic E-commerce Website on AWS Using Terraform]]></title>
            <link>https://medium.com/@djakkone/three-tier-architecture-deploying-a-dynamic-e-commerce-website-on-aws-using-terraform-76d77bf7d58b?source=rss-dc23c840bbd4------2</link>
            <guid isPermaLink="false">https://medium.com/p/76d77bf7d58b</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[deployment]]></category>
            <category><![CDATA[terraform]]></category>
            <dc:creator><![CDATA[DJ. KONE]]></dc:creator>
            <pubDate>Mon, 07 Oct 2024 05:58:10 GMT</pubDate>
            <atom:updated>2024-12-15T01:35:01.683Z</atom:updated>
            <content:encoded><![CDATA[<p>In this short tutorial, I will show you how to deploy an ecommerce website on AWS, how Terraform helps you quickly build and maintain a strong, reliable platform that can grow with your business.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hn9JNwDvCD0g6IoXWFUyKA.png" /></figure><h3>Background</h3><p>A <strong>three-tier architecture </strong>is a common framework for building scalable, reliable cloud applications. It breaks the application into three distinct layers, each serving a specific role:</p><ul><li>Presentation Layer (Web Tier): this layer is responsible for user interaction, managing the user interface (UI/UX), and processing HTTP/S requests and responses.</li><li>Application Layer (App Tier): this layer handles the core business logic and processes data exchanges between the web and database layers.</li><li>Data Layer (Database Tier): this layer stores, manages, and retrieves the application’s data, handling queries from the application layer.</li></ul><p>This architecture promotes high availability, scalability, and clear separation of responsibilities, making it easier to maintain, scale, and optimize each layer independently.</p><h3>Project Outline</h3><p>Deploy an E-commerce Website on AWS in a three tier architecture using Terraform.</p><h3>Prerequisite</h3><ul><li>Access to AWS account.</li><li>Install Terraform</li><li>Familiarity with 3-tier-architecture</li></ul><h3>Let’s have fun.</h3><p>Leveraging AWS services and Terraform allow you to efficiently build and maintain a robust, reliable platform that evolves alongside your business.</p><h3>1. Create main.tf file and connect AWS to Terraform</h3><ul><li>Go to your favorite IDE or open a terminal.</li><li>Copy and paste the code below. Do not forget to change your profile name.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/686/1*C21ZzI0Qa2tznNg5a2TtJw.png" /></figure><ul><li>Next, go to AWS S3 console. Create a S3 bucket.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*jPlxjYtnLw5qKzzhcA4nvw.png" /></figure><p>I named my bucket terraform-ecom.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*b8aOj_SFCeGxpCUeoZw3FA.png" /></figure><ul><li>Store Terraform state file in your S3 bucket by using the code below.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/654/1*oyr1rJbVbjhj71wdvBnsug.png" /></figure><ul><li>It’s time to initialize our terraform code. Open a new terminal and run <strong>terraform init.</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*TX6oyFpFbgO0VVSGOvg3Xg.png" /></figure><h3>2- Create VPC</h3><ul><li>Create two new files named variables.tf and vpc.tf respectively.</li><li>In the variables.tf file, copy the code below to declare vpc variables.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/789/1*v0j0OZLK18nPf-KtLQo-BQ.png" /></figure><ul><li>In the vpc.tf file, write your terraform code for vpc resource.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/939/1*g9zNtWDwy7HCd4kmIXfNFg.png" /></figure><p><em>Cheat Sheet: After running your terraform code, verify your AWS if each resource is created correctly</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*R-NEACHeBOvMzmIoXYWG3g.png" /></figure><h3>3- Create Internet Gateway resource</h3><ul><li>In the same vpc.tf, add the code lines for internet gateway.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*rbG1e6-sImghTvV6oABSsw.png" /></figure><h3>4- Create Public subnet</h3><ul><li>Back to your variables.tf file, create variables for public subnets</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*GZs5xdDycGanMo8VfHKaig.png" /></figure><ul><li>In your vpc.tf file, add the two public subnets using terraform code.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/926/1*XBbRH3uYbqKSfIpexGGxkg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*tmvxYcIT5hq9EferFzhO-w.png" /></figure><h3>4- Create Route Table</h3><ul><li>In the same vpc.tf, create route table</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*lrbFJ1Y_PkOTIFfXLBZViQ.png" /></figure><ul><li>Associate public subnet to route table</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*1lDAH7O0lRe66lRsHCAmPQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*bB542dCAjFjKDbV7xLedAQ.png" /></figure><h3>5- Create Private subnet</h3><ul><li>Still in vpc.tf file, complete your terraform code with private subnets</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*S-l_T9Ilv5jOXpO6JaMMvA.png" /></figure><ul><li>It’s time to run <strong>terraform plan</strong>, then <strong>terraform apply</strong>.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*d7i-Yw-IT9UpgFMRnQT9Og.png" /></figure><ul><li>Go back to your AWS console. Verify if all the resources you mentioned in your vpc.tf file have been created.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*gdMt8cfj3Cp72TOmT8ZJUA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*dv1U3LrdKjo0zVMWJ-H4Dg.png" /></figure><h3><strong>6- Create Nat gateway</strong></h3><p>Leverage Terraform to deploy a NAT gateway, allowing outbound traffic from instances within private subnets.</p><ul><li>Create a natgateway.tf file.</li><li>Copy and paste the following code lines in your file.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*OJZIRYgmyL-HDsmhDtn-3w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/814/1*6O0sX340QU_41XYP-P7SMQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*mvsjH7aNVrRGQZvysccEJA.png" /></figure><ul><li>After running terraform plan and terraform deploy, you should see Elastic IP address, and Nat gateways deployed in AWS.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*SD_I8VnacRoJemAGdQYeOA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*sNFzz88v5wbWcmPfpgeiqg.png" /></figure><h3>7 — Create security groups</h3><ul><li>Write a Terraform script to configure a security group, managing inbound and outbound traffic for instances.</li><li>If you are having some issues to create security groups using terraform, find the code repository in this repo: <a href="https://github.com/djcloudking/terraform-challenges/blob/main/9_Deploy%20e-comerce%20website%20on%20AWS/security-group.tf">https://github.com/djcloudking/terraform-challenges/blob/main/9_Deploy%20e-comerce%20website%20on%20AWS/security-group.tf</a></li><li>Once again, verify if your security groups deployed correctly.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*Z0cN2qXIuY1DR-vP0RpGkg.png" /></figure><h3>8- Create RDS</h3><p>Use Terraform to set up a Relational Database Service (RDS) for efficient database management.</p><ul><li>First, create a rds.tf file.</li><li>Next, create a database subnet group and a database instance.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*8kp7I1l88rL-yDUyGXnZuA.png" /></figure><ul><li>Go to your RDS dashboard and verify if it deployed.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*nCxDtauifak2rgW0SwOLGg.png" /></figure><ul><li>Finally, create a certificate manager.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*iYjtwULK5PcSepCWXR47hA.png" /></figure><h3>9- Create Application Load Balancer</h3><ul><li>Create alb.tf file</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*FgiYjFeU64ZI3WnVAY5dRA.png" /></figure><ul><li>create a target group</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*YfUuBfAzxTGtmcU9w1rX-w.png" /></figure><ul><li>Create a listener on port 80</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*5c0tRHNpME5uXC3kwdS30Q.png" /></figure><ul><li>Create a listener on port 443</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*f12XzAfwOqxIba48ihS5SA.png" /></figure><h3>10- Create a SNS</h3><ul><li>Create a sns.tf file.</li><li>Copy and paste the code below in the file.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*fB65iOMSRYXBzHkTD9VkKQ.png" /></figure><ul><li>Verify if SNS deployed in AWS.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*ZK1JL5Ob04gdyApCl2ekvQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*ardKdBYXxEdk5cRpLVChrw.png" /></figure><h3>11- Create Auto Scaling Group</h3><p>Leverage Terraform to create an Auto Scaling Group.</p><ul><li>Find the code repository in this repo: <a href="https://github.com/djcloudking/terraform-challenges/blob/main/9_Deploy%20e-comerce%20website%20on%20AWS/asg.tf">https://github.com/djcloudking/terraform-challenges/blob/main/9_Deploy%20e-comerce%20website%20on%20AWS/asg.tf</a></li></ul><h3>12- Create Record Set in Route 53</h3><ul><li>Create route53.tf file.</li><li>Create a record set in Route 53</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*cIuZXfY195jRW0xfKa2M_w.png" /></figure><p>Following these steps will enable you to deploy a secure and scalable e-commerce website on AWS using Terraform. This guide offers a clear and structured process, ensuring that others can easily replicate your deployment.</p><p>— — — — —</p><p>Thank you for reading and/or following along! Leave us a clap or a comment, Share &amp; Follow. Please stay tuned for all my upcoming projects.</p><p>— — — — — — -</p><p>🛠 Want more? Subscribe to my Newsletter and receive daily AWS cloud updates in your mailbox ➡<a href="https://substack.com/@whatsnewinthecloud"> My Newsletter</a></p><p>🕒If you haven’t read my earlier articles on AWS services, cloud-native technologies &amp; DevOps tools, be sure to visit my blog and catch up ➡ <a href="https://cloudwithdj.com/blog/">My Blog</a></p><p>♻ Want more? Discover my comprehensive Cloud tutorials and projects ➡ <a href="https://github.com/djcloudking?tab=repositories">My Cloud Projects Repo</a></p><p>Contact me directly on <a href="https://www.linkedin.com/in/djakaridiakone/">LinkedIn</a> or <a href="http://info@fahmacloud.com/">Email</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=76d77bf7d58b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Troubleshooting Terraform: Use Terraform Modules To Address Common Issues]]></title>
            <link>https://medium.com/@djakkone/troubleshooting-terraform-use-terraform-modules-to-address-common-issues-74d80d1a066d?source=rss-dc23c840bbd4------2</link>
            <guid isPermaLink="false">https://medium.com/p/74d80d1a066d</guid>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[troubleshooting]]></category>
            <category><![CDATA[terraform]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[DJ. KONE]]></dc:creator>
            <pubDate>Sat, 03 Aug 2024 05:35:52 GMT</pubDate>
            <atom:updated>2024-12-15T01:30:21.337Z</atom:updated>
            <content:encoded><![CDATA[<p>In this short tutorial, I will show you how to use Terraform modules to troubleshoot common issues when building AWS infrastructure. Specifically, we’ll address leap and bounds issues to ensure a smoother and more efficient deployment process.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jqlEs2dfyS0UXtSfq2qzAg.png" /></figure><h3>Background</h3><p><strong>Terraform</strong> is like a magic wand for managing your cloud infrastructure. Imagine writing a few lines of code, and voilà, your servers, databases, and networks are all set up automatically. That’s the power of Terraform.</p><p><strong>Terrform module</strong> is a container for multiple resources that are used together. This can include configuration files, input variables, output values, and nested resources. Modules allow you to abstract your infrastructure into reusable components.</p><h3>Prerequisite</h3><p>For this project, you need:</p><ul><li>AWS account</li><li>Terraform installed</li></ul><h3>Project Outline</h3><p>When working with Terraform, you might encounter some challenges that can seem like they appear out of nowhere, growing by “leaps and bounds.” As a cloud engineer, this is one way to resolve these issues: the use of modules.</p><p>In our example, you notice that your team has built AWS infrastructure (EC2, VPC, S3, EBS, etc.) using Terraform. However, it seems that the EC2 instance is not being created when using the same Terraform template again. In the following tutorial, I will show you how to fix this issue and properly implement AWS EC2.</p><h3>Let’s Have Fun</h3><p>Instead of writing all the code in the main configuration file, I will use modules to separate the EC2 configuration, troubleshoot issues, and keep it ready for future implementation.</p><h3>Verify if terraform and AWS are installed properly</h3><ul><li>Open the terminal and type <strong>terraform --version</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*thNNogvlKi-u5ptR6CtCpA.png" /></figure><ul><li>Verify if AWS is configured properly. Type <strong>aws --version</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dOYjCVR2HTOGm4cR6fc6xw.png" /></figure><h3>Detach the EC2 configuration</h3><ul><li>Detach the EC2 configuration from the main Terraform template.</li><li>Create a new folder for your troubleshooting session.</li><li>Inside the new folder, create a file named main.tf.</li><li>Open main.tf and add the EC2 resource configuration.</li><li>Add the provider definitions at the top of the main.tf file.</li><li>Create variables to simplify the code.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HTrAWtwB48Wap2UA15KnMg.png" /></figure><p>If you leave the code as it is, you will encounter an error during execution. To fix this, create a new file named terraform.tfvars to define the values for ami and instance_type. Also,terraform.tfvars can be used to stored sensitive information.</p><h3>Add some changes to our terraform code</h3><ul><li>Update our Terraform code to use these variables. Creating a terraform.tfvars file ensures that any developers in the project can easily use and update it when needed to create new AWS EC2 resources.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*arIe0i4OHC0rKqJIFmy-oQ.png" /></figure><h3>Create terraform variables</h3><ul><li>Create a new file named variables.tf to simplify and parameterize the code.</li><li>Go back to main.tf, copy and cut all the variable definitions.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BCIZpbtC0e8uMPedv8nLpw.png" /></figure><ul><li>Open variables.tf and paste the variable definitions into variables.tf.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9P-c7QqM94-j0Hjawde9Lg.png" /></figure><h3>Create the new EC2 resource</h3><ul><li>Go to the terraform project and run <strong>terraform init</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*592IoZjPcY3tVI-mptH4dQ.png" /></figure><ul><li>Then <strong>terraform plan</strong>. Finally <strong>terraform apply</strong>. Type Yes.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wRIKu8CSPNPiYobyv8BCDQ.png" /></figure><h3>Add more changes for a robust code</h3><p>Now, let’s imagine that the code you are writing will be used by developers outside of your team. For that reason, I will add<strong> output</strong> and <strong>input.</strong></p><ul><li>Run <strong>terraform destroy</strong></li><li>Create a new file named outputs.tf</li><li>Add the following lines to outputs file:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VD855TgJ4Kwm6O6lblCW5A.png" /></figure><ul><li>Run <strong>terraform init</strong>, <strong>terraform plan</strong>and <strong>terraform apply</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W8OlwCe4TbfHHLFghXUgyw.png" /></figure><h3>Create modules for EC2</h3><p>To improve reusability and maintainability, we will create modules for EC2. This will be especially helpful when creating EC2 instances multiple times. By doing so, it resolves our issues.</p><ul><li>Run terraform destroy.</li><li>Create a new folder called modules/ec2. This folder will contain all the necessary files for the EC2 module.</li><li>Move the following files <strong>main.tf, variables.tf, terraform.tfvars and outputs.tf </strong>in the folder.</li><li>After moving these files, delete terraform.tfvars. Other developers executing the module will create their own terraform.tfvars.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/304/1*BJPpCIOQ2OBpwO3F8nSMSg.png" /></figure><p>At this stage, any developer or team member can create a new main.tf file with the provider defined, from any location or repository, and execute the module to implement a new EC2 instance. Here’s how it will look:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*da0IezSSnAk0iSwVj-RK3A.png" /></figure><ul><li>Finally, execute terraform plan and terraform apply to deploy the resources.</li><li>Any developer can write a main.tf file, call the module they need, and add the necessary values to execute the code.</li></ul><p>Voila! You’ve troubleshot the Terraform issue using a Terraform module. This approach also makes it easy to create reusable code for your Terraform automation.</p><p>— — — — —</p><p>Thank you for reading and/or following along! Leave us a clap or a comment, Share &amp; Follow. Please stay tuned for all my upcoming projects.</p><p>— — — — — — -</p><p>🛠 Want more? Subscribe to my Newsletter and receive daily AWS cloud updates in your mailbox ➡<a href="https://substack.com/@whatsnewinthecloud"> My Newsletter</a></p><p>🕒If you haven’t read my earlier articles on AWS services, cloud-native technologies &amp; DevOps tools, be sure to visit my blog and catch up ➡ <a href="https://cloudwithdj.com/blog/">My Blog</a></p><p>♻ Want more? Discover my comprehensive Cloud tutorials and projects ➡ <a href="https://github.com/djcloudking?tab=repositories">My Cloud Projects Repo</a></p><p>Contact me directly on <a href="https://www.linkedin.com/in/djakaridiakone/">LinkedIn</a> or <a href="http://info@fahmacloud.com/">Email</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=74d80d1a066d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a DEV environment on AWS using Terraform — Part II]]></title>
            <link>https://medium.com/@djakkone/building-a-dev-environment-on-aws-using-terraform-part-ii-31218f39daf7?source=rss-dc23c840bbd4------2</link>
            <guid isPermaLink="false">https://medium.com/p/31218f39daf7</guid>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[terraform]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[DJ. KONE]]></dc:creator>
            <pubDate>Tue, 16 Jul 2024 23:17:44 GMT</pubDate>
            <atom:updated>2024-12-15T01:25:43.828Z</atom:updated>
            <content:encoded><![CDATA[<h3>Building a DEV environment on AWS using Terraform — Part II</h3><p>In this part, I will install Docker on AWS EC2 before deploying.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/801/1*4kLlMQoTTbOVYpsNuntMLg.png" /></figure><p>In part II, here what you will learn:</p><ul><li>Configuring AWS EC2 Userdata with Terraform</li><li>Setting Up VSCode SSH Configuration</li><li>Utilizing Terraform Provisioners</li><li>Installing Docker on EC2 before deploying</li><li>Replacing Resources and Deploying EC2 with Terraform</li><li>Working with Terraform Variables</li><li>Using Terraform Conditional Expressions</li><li>Basics of Terraform Outputs</li></ul><h3>Part II:</h3><h3>Launching an AWS EC2 Instance with Terraform</h3><ul><li>Google “AWS EC2 resource in terraform”. You should land on the section in the terraform documentation that mention AWS EC2.</li><li>Go back to VS Code and add the block to <strong><em>main.tf </em></strong>in the <strong><em>Terraform</em></strong> directory.</li><li>Enter the necessary information needed to create a VPC.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*Ryqj5X2Tw024TCv1RssSAA.png" /></figure><ul><li>Run terraform plan, then terraform apply -auto-approve. You should see a new resource.</li><li>Reorganize the code in main.tf</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*HTpkgPuQw-XV-vD_HnVjRg.png" /></figure><h3>Configuring AWS EC2 Userdata with Terraform</h3><ul><li>Add userdata to our content to boostrap our instance. Boostrap goes over instance for docker to be ready.</li><li>Create a new file named <strong><em>userdata.tpl</em></strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*g0C-FIpU-TVpUIuuNYklKQ.png" /></figure><ul><li>Add it to the resource “aws_instance”</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*rhgg7aHMhO6KwwhYHGdwOg.png" /></figure><ul><li>Run terraform plan, then terraform apply -auto-approve. You should see a new resource.</li><li>Go to EC2 dashboard to verify.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*vekmKHfknivS2Vkqa8-GGg.png" /></figure><ul><li>Or run terraform state list</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*Hi9Inhbudx2dZ5svBzWjEw.png" /></figure><ul><li>Run terraform state show aws_instance.dev_node</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*L-VGZVCoooFbwc3UPDq74A.png" /></figure><ul><li>Copy and save the public IP address to connect “44.202.189.9”</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*oy9GqnsR-3M0rsFgny0KQw.png" /></figure><ul><li>Connect to the instance:ssh -i ~/.ssh/keypairname username@ippublicaddress</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*sWI0FBwOKXT2nUGPCkqNwQ.png" /></figure><ul><li>When connected, verify if docker is installed</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*s4BKBst7eSTCAt8FobuKeA.png" /></figure><h3>Setting Up VSCode SSH Configuration</h3><ul><li>Go to the extension, and search for “Remote — SSH”. Install it.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*XK87Qmvmdt58Kdcx4SPyaA.png" /></figure><ul><li>Go back to explorer and type:cat ~/.ssh/config</li><li>Create a file named “windows-ssh-config.tpl</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*qAm72021qAMNIDHqEsYSpQ.png" /></figure><ul><li>Create another file for linux named “linux-ssh-config.tpl</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*cSFyymv9tLh4sSx0clM7aQ.png" /></figure><h3>Utilizing Terraform Provisioners</h3><ul><li>Go back to main.tf, under resource “aws_instance” enter this code</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*FHuFLXiFcksysqKqR92how.png" /></figure><ul><li>Runterraform state list</li><li>Runterraform apply-replace aws_instance.dev_node</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/889/1*8qKAkXradts6VVzBvUaJkQ.png" /></figure><ul><li>Enter Y.</li><li>Go to your console and verify if itt’s working.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*yIVlLZgQ_s5kepjI71QjLQ.png" /></figure><ul><li>Enter cat ~/.ssh/config, you should get a correct result.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*qAm72021qAMNIDHqEsYSpQ.png" /></figure><h3>Installing Docker on EC2 before deploying</h3><ul><li>In VS code, go to view. Click on Command palette, then ssh. Check the IP address and click on it.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*PLQ6QlN_62mgpO9WLr8G1w.png" /></figure><ul><li>Select Linux, and click OK.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*iTsQHhhqnHcQht3kqB1lUA.png" /></figure><ul><li>Open terminal and run docker</li><li>Run docker --version</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/848/1*FnnV_gXn0pwtTHOXZ6CG9Q.png" /></figure><ul><li>Click “Yes, I trust the authors”.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/885/1*oQeH6bUpU22J8ebluJeT9g.png" /></figure><ul><li>You’ve deployed a DEV environment using Terraform, and accesible via SSH remote. You can stop the lab here.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*ymrFNeEokQVzyTL2ikFctw.png" /></figure><p><strong>BONUS: Or you can continue the lab.</strong></p><p>Let’s try to optimize what I did. I am going to modify couple of scripts to adjust everything.</p><h3>Replacing Resources and Deploying EC2 with Terraform</h3><ul><li>Modify the type of OS we are using. Change windows in the provisioner so that it can be useful when using other operating systems.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*H6GpOztr0ywcG--XsPX9Pw.png" /></figure><ul><li>Use the interpolation syntax: $ { } which is a calculated variable used</li><li>Create a new file named “variables.tf”</li><li>Go to the terraform document. Search for “Declaring an input variable”</li><li>Copy the code and enter the necessary changes</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/681/1*yZtJ_rPTrPfjKZZ6VNqi_g.png" /></figure><ul><li>Save the file.</li><li>Run terraform destroy -auto-approve. Enter <strong><em>windows</em></strong> when a value is requested.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*Iq0iZgHrZlHpZ6xN648Haw.png" /></figure><h3>Working with Terraform Variables</h3><ul><li>The system is requesting to define var.host_os</li><li>Create a new file named “terraform.tfars” with the following details</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*weq2bVlRARvtA58LhgabsA.png" /></figure><ul><li>Create a another file named “dev.tfars” with the following details</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*-slVe7tG-JkUlirYxaOkIg.png" /></figure><ul><li>Run the following command: terraform console -var-file=”dev.tfars”, then enter the variable</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*ehnjcwXXe1q-CL2A9USNgQ.png" /></figure><h3>Using Terraform Conditional Expressions</h3><ul><li>Run the following command: <em>terraform console -var=”host_os=windows</em>”, then enter the variable</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*E0AP3coSmfk9gSPMg0tbOA.png" /></figure><ul><li>You realize you should set or change the interpreter by integrating variables.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*OmAdQPp6WOwCeiHBjNOU8A.png" /></figure><ul><li>Run terraform plan, then runterraform apply -auto-approve.</li><li>If nothing change, run terraform plan -refresh-only.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*tyOTy9FfrdGhKI537Ok5UQ.png" /></figure><h3>Basics of Terraform Outputs</h3><ul><li>Launch <em>terraform console</em>, and type <em>aws_instance.dev_node.public_ip</em> to view IP address.</li><li>Create a new file “outputs.tf”</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/970/1*HjnptGLzCaIzcew3WCzH4g.png" /></figure><ul><li>Run terraform apply -refresh-only.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*C7i09MEldGoJORwKffLv8Q.png" /></figure><ul><li>Run terraform output.to see the final result.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*s_f3PmJfh-b2kkOIl73XvQ.png" /></figure><p>This is how you can optimize your terraform script with variables and outputs. This is the end.</p><p>— — — — —</p><p>Thank you for reading and/or following along! Leave us a clap or a comment, Share &amp; Follow. Please stay tuned for all my upcoming projects.</p><p>— — — — — — -</p><p>🛠 Want more? Subscribe to my Newsletter and receive daily AWS cloud updates in your mailbox ➡<a href="https://substack.com/@whatsnewinthecloud"> My Newsletter</a></p><p>🕒If you haven’t read my earlier articles on AWS services, cloud-native technologies &amp; DevOps tools, be sure to visit my blog and catch up ➡ <a href="https://cloudwithdj.com/blog/">My Blog</a></p><p>♻ Want more? Discover my comprehensive Cloud tutorials and projects ➡ <a href="https://github.com/djcloudking?tab=repositories">My Cloud Projects Repo</a></p><p>Contact me directly on <a href="https://www.linkedin.com/in/djakaridiakone/">LinkedIn</a> or <a href="http://info@fahmacloud.com/">Email</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=31218f39daf7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a DEV environment on AWS using Terraform]]></title>
            <link>https://medium.com/@djakkone/building-a-dev-environment-on-aws-using-terraform-9e4c4a8522c6?source=rss-dc23c840bbd4------2</link>
            <guid isPermaLink="false">https://medium.com/p/9e4c4a8522c6</guid>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[terraform]]></category>
            <category><![CDATA[devops]]></category>
            <dc:creator><![CDATA[DJ. KONE]]></dc:creator>
            <pubDate>Tue, 16 Jul 2024 18:55:34 GMT</pubDate>
            <atom:updated>2024-12-15T01:15:36.028Z</atom:updated>
            <content:encoded><![CDATA[<p>In this short tutorial, I will create a secure and isolated AWS environment for developers, accessible through Remote SSH for streamlined workflow and enhanced security.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZsfcOuP3DbmixJ4m_QoUMQ.png" /></figure><h3>Scenario</h3><p>My manager asked me to set up a new development environment. So, I decided to document the whole process of creating a secure and isolated AWS environment for our developers. I’ll also show you how to make it easily accessible using VS Code’s Remote SSH extension.</p><h3>Architecture</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/801/1*4kLlMQoTTbOVYpsNuntMLg.png" /></figure><h3>Project Outline</h3><p>Don’t forget! Our main goal is to create a secure and isolated AWS environment for developers, accessible through Remote SSH for streamlined workflow and enhanced security.</p><p>Here’s what you’ll learn:</p><p>Part I</p><ul><li>Setting up IAM role, keys and permission</li><li>Setting Up Visual Studio Code for AWS and Terraform</li><li>Initializing Terraform and Configuring the AWS Provider</li><li>Applying Terraform to create an AWS VPC</li><li>Utilizing Terraform State</li><li>Applying Terraform to create AWS Subnets</li><li>Creating an AWS Internet Gateway</li><li>Applying Terraform to create AWS Route Tables</li><li>Managing AWS Security Groups with Terraform</li><li>Using Terraform Data Sources</li><li>Applying Terraform to create an EC2 Key Pair</li><li>Launching an AWS EC2 Instance with Terraform</li></ul><h3>Pre-requisite</h3><ul><li>AWS account with the right access</li><li>AWS CLI installed</li><li>Terraform installed</li><li>Visual studio Code used as IDE.</li></ul><h3>PART I</h3><h3>Setting up IAM role, keys and permission</h3><ul><li>Go to IAM dashboard</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*hubrrbf8owx6DtqNtkaxaw.png" /></figure><ul><li>Click on <strong>users</strong>, then click <strong>create a user.</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*ZwPVRyYIES-59mBBR5ovgw.png" /></figure><ul><li>Fill out the form with the necessary details. I chose “djdev” as my username.</li><li>Do not check “provide user access to the AWS Management Console”. We need the “Access key — programmatic access”.</li><li>In the <strong><em>Set permissions</em></strong> window, select <strong><em>attach policies directly.</em></strong></li><li>Search for and select <strong><em>Administrator Access </em></strong>in the permissions policies section<strong>. </strong>Leave<strong> <em>tag</em> </strong>as default.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*L8RBJcaRnLT6Ksi7RND4mw.png" /></figure><ul><li>Now click on the user you created.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*gZjHYrrOsxPxTy5FmklZWw.png" /></figure><ul><li>Scroll down and click <strong><em>Security Credentials</em></strong> tab.</li><li>Scroll down again and go to <strong><em>Access keys.</em></strong> Then click <strong><em>create access key.</em></strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*w-6ySjS_uENFOCCvXUnd2w.png" /></figure><ul><li>Select CLI for our programmatic access credentials.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*BfZDr3J5MvV_IJoNBdm7HA.png" /></figure><ul><li>Check the bottom for confirmation. For tags, add what you want to describe what you’re doing.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*CdV95azgzHwbxZVXV_ZctQ.png" /></figure><ul><li>You’ve created your access key. Download the CSV file.</li></ul><h3>Setting Up Visual Studio Code for AWS and Terraform</h3><ul><li>Open Visual Studio Code. Go to the extension. Search for AWS and install AWS Toolkit.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*RdxjYABZfMJy4RKwHNJfUQ.png" /></figure><ul><li>Go to View, then Command Palette.</li><li>Click on “AWS: create credential profile (djtest)”</li><li>Copy the credentials from your CSV file and paste it in the credentials window.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*bBOIW0hrE3TR1c1tBVY1mA.png" /></figure><ul><li>Save and close the window.</li><li>Click Connect to AWS. You should see your profile.</li></ul><h3>Initializing Terraform and Configuring the AWS Provider</h3><ul><li>Go back to the extension. Add Terraform and close the extension window.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*CspZQhaEItYSixAqnvARug.png" /></figure><ul><li>Create a new working directory or folder named <strong><em>Terraform</em></strong>. Open and select the folder in VS Code.</li></ul><p>It’s now time to create our terraform files, starting with <strong><em>providers.tf, </em></strong>which is used by Terraform to interact with APIs for anything you want to build.</p><ul><li>Go into the <strong><em>Terraform</em></strong> folder and create a file named <strong><em>providers.tf</em></strong></li><li>Add the necessary code to the file</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*I1QGU6PgM7nLN5rDe5b7nQ.png" /></figure><p><em>Cheat Sheet: I deleted the version so that it can download whatever version is newer.</em></p><ul><li>Look into the terraform documentation on how to add the provider block. Use the provider block with “shared credentials file”</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*Kr3ptREQIW3bkYrOh679wQ.png" /></figure><ul><li>Copy and paste it under required provider</li><li>Change shared credentials to “~/.aws/credentials” if you’re using Linux or “C:/Users/djkon/.aws/credentials” if you are using Windows and add your profile name.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*Nyvtkk3Qxtc6lG7JybXq8w.png" /></figure><ul><li>Open the terminal. Then run <strong><em>terraform init.</em></strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*CHnycdum-4ZfXkkX4uEuuA.png" /></figure><ul><li>Terraform has been successfully initialized.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*acmnYHGLan7u3WoqglLTwQ.png" /></figure><p><strong><em>Terraform Errors Example</em></strong><em>: Be careful about what you’re writing. You may encounter some errors, but read the error messages and try to resolve them</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/964/1*_gHGj4NcDdgzvFPtyWT6FQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*IVwBhrMzLb9rU5KkF0Lblw.png" /></figure><p><em>I resolved this issue by entering the right attribute and changing the profile name.</em></p><h3>Applying Terraform to create an AWS VPC</h3><ul><li>Google “AWS VPC resource in terraform”. You should land on the section in the terraform documentation that mention AWS VPC.</li><li>Go back to VS Code and create a new file called <strong><em>main.tf </em></strong>in the <strong><em>Terraform</em></strong> directory.</li><li>Enter the necessary information needed to create a VPC.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*4j_mkkLkNC4Il27xZSI2dA.png" /></figure><ul><li>Save the file and run <strong><em>terraform plan</em></strong>.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*Jp30UXoyqohlvq5V0LVXrQ.png" /></figure><ul><li>Enter <strong><em>terraform apply</em></strong>, then <strong><em>yes</em></strong>.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*RcD-w4KwDA3J32cN3GbuUQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*rv8kKlKsV186cWYxz5fDoA.png" /></figure><ul><li>Next, click on AWS icon. Click No, and Resource. You should see your VPC.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*nIUIHPn6qW_TEjghT0GImw.png" /></figure><ul><li>Go to the VPC Dashboard and verify if you see the VPC you created.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*oegRQgfwXdJE0i-HCzD_KQ.png" /></figure><h3>Utilizing Terraform State</h3><p>Terraform use State to determine which changes to make to your infrastructure.</p><ul><li>The command <strong><em>terraform state list</em></strong> shows all the resources you created.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*UHDfJb_Z511MTsN3taUg-g.png" /></figure><ul><li>The command <strong><em>terraform show</em></strong> displays everything in details.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*f2_JhLH9RWe_-XYhVYMmVA.png" /></figure><ul><li>The command <strong><em>terraform destroy</em></strong> kills all existing resource.</li></ul><h3>Applying Terraform to create AWS Subnets</h3><ul><li>Google again “AWS subnets resource in terraform”. You should land on the section in the terraform documentation that mention AWS subnets.</li><li>Go back to VS Code and add the new code block to the <strong><em>main.tf </em></strong>in the <strong><em>Terraform</em></strong> directory.</li><li>Enter the necessary information needed to create subnets.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/856/1*IENvQ8KvAYGN97pRC_osWg.png" /></figure><ul><li>Ensure that our resource receive a public ip address. Add <strong><em>Map_public_ip_on_launch</em></strong> to label it correctly.</li><li>Run <strong><em>terraform plan. </em></strong>You should see all the details that you applied.</li><li>Run <strong><em>terraform apply -auto-approve. </em></strong>This new command will allow you to skip the yes or no question.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*gTg9juOXiPkKCgMPq_u5Dw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*Pl-PJ8r5K1QX2BYyULnmRg.png" /></figure><p><strong><em>Terraform Errors Example</em></strong><em>: Be careful about what you’re writing. You may encounter some errors, but read the error messages and try to resolve them.</em></p><p><em>When I first executed this code:</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/907/1*Qom5LxnmCDBY7xoxFNejRw.png" /></figure><p><em>I received this error message:</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*DXEusneECjweFZLLiTeOJw.png" /></figure><p><em>I fixed it by changing the AZ from us-east-1 to us-east-1a.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/856/1*IENvQ8KvAYGN97pRC_osWg.png" /></figure><h3>Creating an AWS Internet Gateway</h3><ul><li>Repeat the same process between terraform documentation and main.tf</li><li>Add the necessary information related to the infrastructure you want to create.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*Qr78a5P7fmt6YnSZdmE3SQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/895/1*c6XtaHNivIADwgCODKy8RQ.png" /></figure><ul><li>Run terraform plan, then terraform apply -auto-approve. You should see a new resource, such as an internet gateway, in your resources and in your AWS account.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*GggpcTwn_STnu9FZFmZqsQ.png" /></figure><h3>Applying Terraform to create AWS Route Tables</h3><ul><li>Repeat the same process between terraform documentation and main.tf</li><li>Add the necessary information related to the infrastructure you want to create.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*0ECl8oJA2mFmsfBWMux4Pw.png" /></figure><ul><li>Run terraform plan, then terraform apply -auto-approve. You should see a new resource, such as an internet gateway, in your resources and in your AWS account.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*xWWaab6eefgHxw-1TIa6sg.png" /></figure><ul><li>Now, let’s bridge the gap between route table and public subnet by providing a <strong><em>route table association</em></strong>.</li><li>Apply the same process: search the resource in the terraform documentation, then copy the code block in the main.tf file</li><li>Add the necessary information related to the infrastructure you want to create.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/964/1*Vg5N4GnhhHurtEE3AI4l2A.png" /></figure><ul><li>Run terraform plan, then terraform apply -auto-approve.</li><li>Verify if those resources were created.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*zaz80PFVo3lATxzQfG1n2A.png" /></figure><h3>Managing AWS Security Groups with Terraform</h3><ul><li>Repeat the same process between terraform documentation and main.tf</li><li>Add the necessary information related to the infrastructure you want to create.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/673/1*XiIGWqsQ8y203WRSuBsaAQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/679/1*-KZ_4Crj7cuTNkvK5FbghQ.png" /></figure><ul><li>Run terraform plan, then terraform apply -auto-approve. You should see a new resource.</li></ul><h3>Using Terraform Data Sources</h3><ul><li>Data source is a query from AMI to deploy a resource.</li><li>Go to EC2 dashboard. Click on “Launch instance”.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*vhhT-lTJRKZmXWX-WBY5bQ.png" /></figure><ul><li>Click on Ubuntu AMI and copy AMI ID number.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*scTYVcGJg043DyPNwzLynA.png" /></figure><ul><li>Go back to EC2 dashboard. Click on AMIs under Images. Select Public images. Then enter the same AMI ID in the search bar.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*dcfzRR_MRb_4mWg_OCy1cA.png" /></figure><ul><li>Copy the AMI name and Owner.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*SXncNeQXGuwLIZP9GeBiIw.png" /></figure><ul><li>Repeat the same process between terraform documentation and vscode.</li><li>Create a new file “datasources.tf”, enter this block code.</li><li>Add the necessary information related to the infrastructure you want to create.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*z-LMsl4nW1h6FtJF6XDPqg.png" /></figure><ul><li>Save the file.</li><li>Run terraform plan, then terraform apply -auto-approve. You should see a new resource.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*lgDMie3yX9HfmbsGVir9wA.png" /></figure><h3>Applying Terraform to create an EC2 Key Pair</h3><ul><li>Open the terminal and type ssh-keygen -t ed25519</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*v7B-pFUbgoidOmKeAYlTtQ.png" /></figure><ul><li>Name your keypair. I chose “dj_auth”. Do not add a passphrase.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*bjdoo3i2P4xeTh9QMWFE5g.png" /></figure><ul><li>Enter sls ~/.ssh to see the directory.</li><li>Repeat the same process between terraform documentation and main.tf, and use a terraform file function.</li><li>Add the necessary information related to the infrastructure you want to create.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*mznj-ZaH3Pjj314oCw5XRw.png" /></figure><ul><li>Run terraform plan, then terraform apply -auto-approve. You should see a new resource.</li></ul><h3>Launching an AWS EC2 Instance with Terraform</h3><p>You’ve completed the first part. Click the follow link to <a href="https://medium.com/@djakkone/building-a-dev-environment-on-aws-using-terraform-part-ii-31218f39daf7">access Part II </a>on how we deploy EC2 in our DEV environment.</p><p>Part II: <a href="https://medium.com/@djakkone/building-a-dev-environment-on-aws-using-terraform-part-ii-31218f39daf7">https://medium.com/@djakkone/building-a-dev-environment-on-aws-using-terraform-part-ii-31218f39daf7</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*s_f3PmJfh-b2kkOIl73XvQ.png" /></figure><p>Thank you for reading and/or following along! Leave us a clap or a comment. Please stay tuned for all my upcoming projects.</p><p>— — — — —</p><p>Thank you for reading and/or following along! Leave us a clap or a comment, Share &amp; Follow. Please stay tuned for all my upcoming projects.</p><p>— — — — — — -</p><p>🛠 Want more? Subscribe to my Newsletter and receive daily AWS cloud updates in your mailbox ➡<a href="https://substack.com/@whatsnewinthecloud"> My Newsletter</a></p><p>🕒If you haven’t read my earlier articles on AWS services, cloud-native technologies &amp; DevOps tools, be sure to visit my blog and catch up ➡ <a href="https://cloudwithdj.com/blog/">My Blog</a></p><p>♻ Want more? Discover my comprehensive Cloud tutorials and projects ➡ <a href="https://github.com/djcloudking?tab=repositories">My Cloud Projects Repo</a></p><p>Contact me directly on <a href="https://www.linkedin.com/in/djakaridiakone/">LinkedIn</a> or <a href="http://info@fahmacloud.com/">Email</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9e4c4a8522c6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to create a FTP Server on Ubuntu]]></title>
            <link>https://medium.com/@djakkone/how-to-create-a-ftp-server-on-ubuntu-dc1e609c2b53?source=rss-dc23c840bbd4------2</link>
            <guid isPermaLink="false">https://medium.com/p/dc1e609c2b53</guid>
            <category><![CDATA[linux-server]]></category>
            <category><![CDATA[ftp]]></category>
            <category><![CDATA[vsftpd]]></category>
            <dc:creator><![CDATA[DJ. KONE]]></dc:creator>
            <pubDate>Tue, 16 Jul 2024 04:32:43 GMT</pubDate>
            <atom:updated>2024-07-16T04:32:43.392Z</atom:updated>
            <content:encoded><![CDATA[<p>Need a FTP server, but don’t know how to create one? Welcome to this short tutorial. I will show you how to create a FTP server on Ubuntu.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YRvPlprDUOSIdLov7ONwQw.png" /></figure><h3>SUMMARY</h3><p>There are tons of ways to do this, depending on what kind of computer you’re using. But don’t worry, we’re not going to get lost in the weeds here. Let’s keep it simple and focus on setting one up using Ubuntu.</p><p>This setup uses vsftpd (Very Secure FTP Daemon), which is a popular FTP server for Unix-like systems, including Linux, due to its security and performance. It is the default FTP server in the Ubuntu, CentOS, Fedora,</p><h3>PREREQUESITES</h3><ul><li>Access to Linux/Ubuntu</li><li>Knowledge of Bash scripting</li></ul><h3>STEPS</h3><h3>Step 1: Install vsftpd</h3><ul><li>Update your package list and install vsftpd.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*8rQQoHisPmyDfYY0sBT4Ow.png" /></figure><ul><li>Install vsftp</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*uGoFdq3mz65cbvFQS68Nhg.png" /></figure><h3>Step 2: Configure vsftpd</h3><ul><li>Open vsftpd configuration file.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*jv24eGW-MYZ7myU2Q-sh0Q.png" /></figure><ul><li>Verify if local user, upload and write commands, FTP connection with SSL/TLS are <strong>enabled</strong>.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*Br91IMcoZBNNjUC1O2GyMA.png" /></figure><h3>Step 3: Create an FTP User</h3><ul><li>Create a user for FTP access. I selected djftp.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/886/1*sNqKwcu74BpE1v0cbhkeig.png" /></figure><ul><li>Set a password when prompted and follow the prompts to complete the user setup.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eYA4NihO-mMYOKF0yRadjQ.png" /></figure><h3>Step 4: Create FTP Directory</h3><ul><li>Create a directory for FTP uploads and set the appropriate permissions.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kHjry_O6QOeo85X6rZV8MQ.png" /></figure><h3>Step 5: Restart vsftpd</h3><ul><li>Restart the vsftpd service to apply the changes.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*RxQf5rvXjKJ9j5Eh5sL8gw.png" /></figure><h3>Step 6: Adjust Firewall (if needed)</h3><ul><li>Allow FTP traffic through the firewall using`ufw`.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fuT0SMwafClDQ5C7hk6k1Q.png" /></figure><h3>Step 7: Accessing the FTP Server</h3><ul><li>Access your new FTP server</li><li>Enter the password when prompted. You should now be able to upload and download files to/from the `/home/djftp/ftp/upload` directory.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/984/1*yqOEnFTJs-WAoUmrVEo9Yw.png" /></figure><h3>ADDITIONAL</h3><p>Upload a VDI file to the FTP server.</p><ul><li>Navigate to the Upload Directory:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/877/1*DBYRgPKGtDJ8HtsSrAt2Sg.png" /></figure><ul><li>Switch to Binary Mode (important for non-text files like .VDI).</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*jc_sZVM85er0r-RSfVVHYA.png" /></figure><ul><li>Upload the .VDI File</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Nh9F6sdN91mPi_AEBrL4-g.png" /></figure><ul><li>Verify if VDI file has been uploaded,</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZmA9fqkyz1IRcXdp0BFf1A.png" /></figure><p>Voila! You’ve created a FTP (vsftp) server, and uploaded an Oracle VDI file in the server.</p><p>— — — — —</p><p>Thank you for reading and/or following along! Leave us a clap or a comment. Please stay tuned for all my upcoming projects.</p><p>➡ Don’t forget to catch all my medium <a href="https://medium.com/@djakkone">Cloud projects</a>.</p><p>➡ Seeking lab exercises to replicate? Discover my comprehensive, step-by-step tutorials on <a href="https://github.com/djcloudking">GitHub</a>.</p><p>➡ Or Contact me directly on <a href="https://www.linkedin.com/in/djakaridiakone/">LinkedIn</a> or <a href="http://info@fahmacloud.com/">Email</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dc1e609c2b53" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>