<?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 Islam Salah on Medium]]></title>
        <description><![CDATA[Stories by Islam Salah on Medium]]></description>
        <link>https://medium.com/@islamsalah830?source=rss-3906cef5a55a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*QkBXN-pk6j-MyaZAmmdyhA@2x.jpeg</url>
            <title>Stories by Islam Salah on Medium</title>
            <link>https://medium.com/@islamsalah830?source=rss-3906cef5a55a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 01:10:43 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@islamsalah830/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[Kubernetes Scaling Strategies]]></title>
            <link>https://islamsalah830.medium.com/kubernetes-scaling-strategies-4fb42855ac58?source=rss-3906cef5a55a------2</link>
            <guid isPermaLink="false">https://medium.com/p/4fb42855ac58</guid>
            <category><![CDATA[scaling]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[kubernetes-cluster]]></category>
            <category><![CDATA[k8s]]></category>
            <category><![CDATA[kubernetes-scaling]]></category>
            <dc:creator><![CDATA[Islam Salah]]></dc:creator>
            <pubDate>Tue, 16 Jan 2024 10:22:56 GMT</pubDate>
            <atom:updated>2024-01-16T10:22:56.280Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*x1Oe7eSrzjFQP-GbYsYPgg.png" /></figure><p><strong>Kubernetes </strong>(sometimes referred to as K8s) is an open-source container orchestration platform that schedules and automates the deployment, management and scaling of containerized applications (microservices). The Kubernetes platform is all about optimization — automating many of the DevOps processes that were previously handled manually and simplifying the work of software developers.</p><p><strong>Horizontal Scaling</strong> Horizontal scaling, also known as scaling out, involves adding more instances of application components, such as pods or containers, to distribute the workload across multiple nodes. By horizontally scaling your application, you can handle increased traffic and achieve better load balancing. This approach enhances fault tolerance and allows you to scale your application horizontally by adding or removing instances as needed.</p><p><strong>Vertical Scaling</strong> Vertical scaling, also known as scaling up or down, involves adjusting the resources allocated to individual instances of your application components. It typically involves increasing or decreasing the CPU, memory, or storage capacity of a single instance. Vertical scaling allows you to handle increased workload by providing more resources to a specific component, but it may have limitations in terms of the maximum capacity of a single instance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*6sMi8Z1phnws3yJI" /></figure><p>Each scaling strategy offers a unique approach to efficiently manage resources and ensure optimal performance:</p><p><strong>1. Horizontal Pod Autoscaling (HPA): </strong><br>Automatically scales the number of pods in a deployment or replicaset based on observed CPU utilization or other selected metrics.</p><p><strong>2. Vertical Pod Autoscaling (VPA): </strong><br>Automatically adjusts the CPU and memory resources allocated to pods in a deployment or replicaset.</p><p><strong>3. Cluster Autoscaling: </strong><br>Dynamically adjusts the number of nodes in a Kubernetes cluster based on the demands of the workloads and resources availability.</p><p><strong>4. Manual Scaling: </strong><br>Involves manually setting the number of replicas in a deployment or replicaset, using a command like</p><pre>$ kubectl scale --replicas=desired_replica_count object_type/object_name</pre><p><strong>5. Predictive Scaling:</strong><br>Uses advanced algorithms and AI, like in PredictKube, to forecast future demand and proactively scale resources before they are needed.</p><p><strong>6. Custom Metrics Based Scaling: </strong><br>Scales pods based on custom metrics provided by Kubernetes metrics APIs, beyond the default CPU and memory metrics.</p><p>Consider a follow for more article if this is useful.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4fb42855ac58" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Parameter plugins in Jenkins for Git Tags as Input]]></title>
            <link>https://islamsalah830.medium.com/extended-choice-parameter-plugin-in-jenkins-for-git-tags-as-input-7f64d07b4d47?source=rss-3906cef5a55a------2</link>
            <guid isPermaLink="false">https://medium.com/p/7f64d07b4d47</guid>
            <category><![CDATA[jenkins-pipeline]]></category>
            <category><![CDATA[jenkins]]></category>
            <category><![CDATA[git-tags]]></category>
            <category><![CDATA[jenkins-plugins]]></category>
            <category><![CDATA[jenkins-parameter]]></category>
            <dc:creator><![CDATA[Islam Salah]]></dc:creator>
            <pubDate>Tue, 09 Jan 2024 15:58:32 GMT</pubDate>
            <atom:updated>2024-01-09T15:59:57.517Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/796/0*KPddwI3WXfthaJsT.png" /></figure><p>If we would like to make our Jenkins job parameterized which requires the input of a specific Git Tag in a specific Git repo.</p><p>there are two options that I tried and worked good for me.</p><h3>Extended Choice Parameter</h3><p>This is parameter plugin to use for user inputs.</p><pre>parameters {<br>extendedChoice (<br>name: &#39;TAG_VERSION&#39;,<br>defaultValue: &#39;develop-1.0.0-beta-1&#39;,<br>description: &#39;TAG_VERSION&#39;,<br>type: &#39;PT_SINGLE_SELECT&#39;,<br>groovyScript: &quot;&quot;&quot;<br>def gettags = (&quot;git ls-remote -t https://github.com/demo-repo/example.git&quot;).execute()<br>return gettags.text.readLines().collect { it.split()[1].replaceAll(&#39;refs/tags/&#39;, &#39;&#39;).replaceAll(&quot;\\\\^\\\\{\\\\}&quot;, &#39;&#39;)}<br>&quot;&quot;&quot;<br>)<br>}</pre><h3>Git Parameter</h3><p>This plugin allows you to assign git branch, tag, pull request or revision number as parameter in your builds</p><pre>parameters {<br>gitParameter ( branch: &#39;develop&#39;, branchFilter: &#39;develop&#39;, defaultValue: &#39;&#39;, description: &#39;TAG_VERSION&#39;, name: &#39;TAG_VERSION&#39;, quickFilterEnabled: false, selectedValue: &#39;NONE&#39;, sortMode: &#39;DESCENDING&#39;, tagFilter: &#39;develop-*&#39;, type: &#39;PT_TAG&#39;, listSize: &quot;0&quot; )<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2wlOBKehBOUs-DLu3LMRgQ.png" /></figure><h3>Jenkins Job Example</h3><pre>// Using git within checkout<br>pipeline {<br>    agent any<br>    parameters {<br>        gitParameter name: &#39;TAG&#39;,<br>                     type: &#39;PT_TAG&#39;,<br>                     defaultValue: &#39;master&#39;<br>    }<br>    stages {<br>        stage(&#39;Example&#39;) {<br>            steps {<br>                checkout([$class: &#39;GitSCM&#39;,<br>                          branches: [[name: &quot;${params.TAG}&quot;]],<br>                          doGenerateSubmoduleConfigurations: false,<br>                          extensions: [],<br>                          gitTool: &#39;Default&#39;,<br>                          submoduleCfg: [],<br>                          userRemoteConfigs: [[url: &#39;https://github.com/jenkinsci/git-parameter-plugin.git&#39;]]<br>                        ])<br>            }<br>        }<br>    }<br>}</pre><p>Here it is! You are done!<br>Thank you for taking the time to read my article. I hope you find it helpful.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7f64d07b4d47" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Managing AWS EC2 using Python Boto3]]></title>
            <link>https://islamsalah830.medium.com/managing-aws-ec2-using-python-boto3-54201df3e881?source=rss-3906cef5a55a------2</link>
            <guid isPermaLink="false">https://medium.com/p/54201df3e881</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[lambda]]></category>
            <category><![CDATA[aws-ec2]]></category>
            <category><![CDATA[boto3]]></category>
            <category><![CDATA[aws-automation]]></category>
            <dc:creator><![CDATA[Islam Salah]]></dc:creator>
            <pubDate>Sun, 31 Dec 2023 15:15:30 GMT</pubDate>
            <atom:updated>2023-12-31T15:15:30.967Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iIs2cz1k42ToUU7M5b707A.png" /></figure><p><strong>Amazon Elastic Compute Cloud (Amazon EC2)</strong> provides on-demand, scalable computing capacity in the Amazon Web Services (AWS) Cloud. Using Amazon EC2 reduces hardware costs so you can develop and deploy applications faster. You can use Amazon EC2 to launch as many or as few virtual servers as you need, configure security and networking, and manage storage. You can add capacity (scale up) to handle compute-heavy tasks, such as monthly or yearly processes, or spikes in website traffic. When usage decreases, you can reduce capacity (scale down) again.</p><p><strong>Boto3</strong> is the name of the Python SDK for AWS. It allows you to directly create, update, and delete AWS resources from your Python scripts.</p><ul><li><strong>Launch AWS EC2 Instance:</strong></li></ul><pre>import boto3<br><br>ec2 = boto3.resource(&quot;ec2&quot;)<br>Create_New_Instance = ec2.create_instances(<br>    ImageId=&#39;ami-0a1281ee7d7b7cf15&#39;,<br>    InstanceType=&#39;t3.micro&#39;,<br>    MaxCount=1,<br>    MinCount=1,<br>    TagSpecifications=[<br>        {<br>            &#39;ResourceType&#39;: &#39;instance&#39;,<br>            &#39;Tags&#39;: [<br>                {<br>                    &#39;Key&#39;: &#39;Name&#39;,<br>                    &#39;Value&#39;: &#39;dev-server&#39;,<br>                },<br>                {                    <br>                    &#39;Key&#39;: &#39;environment&#39;,<br>                    &#39;Value&#39;: &#39;development&#39;,<br>                },<br>            ]<br>        },<br>    ],<br>)<br># Print out each instance&#39;s response that is created<br>print(&quot;dev environment instance:&quot;, Create_New_Instance)</pre><ul><li><strong>Stop AWS EC2 running Instance:</strong></li></ul><pre>import boto3<br><br>ec2 = boto3.client(&#39;ec2&#39;)<br><br># Look for running instance that has envirnoment tag with value development<br>instances = ec2.instances.filter(Filters=[{&#39;Name&#39;: &#39;instance-state-name&#39;, &#39;Values&#39;: [&#39;running&#39;]},{&#39;Name&#39;: &#39;environment&#39;,&#39;Values&#39;:[&#39;development&#39;]}])<br>for instance in instances:<br>    id=instance.id<br>    ec2.instances.filter(InstanceIds=[id]).stop()<br>    print(&quot;The following instance has been stopped:- &quot;+instance.id)<br></pre><ul><li><strong>Start AWS EC2 Instance:</strong></li></ul><pre>import boto3<br><br>ec2 = boto3.client(&#39;ec2&#39;)<br><br># Look for running instance that has envirnoment tag with value development<br>instances = ec2.instances.filter(Filters=[{&#39;Name&#39;: &#39;instance-state-name&#39;, &#39;Values&#39;: [&#39;running&#39;]},{&#39;Name&#39;: &#39;environment&#39;,&#39;Values&#39;:[&#39;development&#39;]}])<br>for instance in instances:<br>    id=instance.id<br>    response = ec2.instances.filter(InstanceIds=[id]).start()<br>    print(&quot;The following instance has been started:- &quot;+instance.id)<br>    print(response)</pre><ul><li><strong>Terminate AWS EC2</strong></li></ul><pre>import boto3<br><br>ec2 = boto3.client(&#39;ec2&#39;)<br><br># Look for running instance that has envirnoment tag with value development<br>instances = ec2.instances.filter(Filters=[{&#39;Name&#39;: &#39;instance-state-name&#39;, &#39;Values&#39;: [&#39;running&#39;]},{&#39;Name&#39;: &#39;environment&#39;,&#39;Values&#39;:[&#39;development&#39;]}])<br>for instance in instances:<br>    id=instance.id<br>    response = ec2.instances.filter(InstanceIds=[id]).terminate()<br>    print(&quot;The following instance has been terminated:- &quot;+instance.id)<br>    print(response)<br>    </pre><p>We can add the code to Lambda function or python script and trigger it once we need to do any activity with AWS EC2.</p><p>Here it is! You are done!<br>Thank you for taking the time to read my article. I hope you find it helpful.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=54201df3e881" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to use Python Boto3 to work with AWS S3]]></title>
            <link>https://islamsalah830.medium.com/how-to-use-python-boto3-to-work-with-aws-s3-9bf1cc0ebf96?source=rss-3906cef5a55a------2</link>
            <guid isPermaLink="false">https://medium.com/p/9bf1cc0ebf96</guid>
            <category><![CDATA[aws-sdk]]></category>
            <category><![CDATA[s3-bucket]]></category>
            <category><![CDATA[aws-s3]]></category>
            <category><![CDATA[boto3]]></category>
            <dc:creator><![CDATA[Islam Salah]]></dc:creator>
            <pubDate>Wed, 27 Dec 2023 10:57:01 GMT</pubDate>
            <atom:updated>2023-12-31T14:36:09.376Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*o6W5lgRv1GZCy9hedq1olA.png" /></figure><p><strong>Amazon Web Services (AWS)</strong> has become a leader in cloud computing. One of its core components is S3, the object storage service offered by AWS. With its impressive availability and durability, it has become the standard way to store videos, images, and data. You can combine S3 with other services to build infinitely scalable applications.</p><p><strong>Boto3</strong> is the name of the Python SDK for AWS. It allows you to directly create, update, and delete AWS resources from your Python scripts.</p><h3>Creating a Bucket</h3><p>To start off, you need an S3 Bucket. To create one programmatically, you must first choose a name for your bucket. Remember that this name must be unique throughout the whole AWS platform, as bucket names are DNS compliant. If you try to create a bucket, but another user has already claimed your desired bucket name, your code will fail. Instead of success, you will see the following error: botocore.errorfactory.BucketAlreadyExists.</p><p>You can increase your chance of success when creating your bucket by picking a random name. You can generate your own function that does that for you. In this implementation.</p><p>We can use the uuid module that will help us achieve that:</p><pre>import uuid<br>def create_bucket_name(bucket_prefix):<br>    # The generated bucket name must be between 3 and 63 chars long<br>    return &#39;&#39;.join([bucket_prefix, str(uuid.uuid4())])</pre><ul><li>Creating S3 bucket:</li></ul><pre>import boto3<br>def create_s3_bucket(bucket_name, region=&#39;us-east-1&#39;):<br>    try:<br>        s3 = boto3.client(&#39;s3&#39;, region_name=region)<br>        s3.create_bucket(Bucket=bucket_name)<br>        print(f&quot;S3 bucket &#39;{bucket_name}&#39; created successfully in region &#39;{region}&#39;.&quot;)<br>        return bucket_name<br>    except Exception as e:<br>        print(f&quot;An error occurred while creating the S3 bucket: {e}&quot;)<br>        return None<br>bucket_name = input(&quot;your-bucket-name&quot;)<br>region = &#39;us-east-1&#39;<br>created_bucket = create_s3_bucket(bucket_name, region)</pre><ul><li>Retrieve the list of existing buckets:</li></ul><pre>s3 = boto3.client(&#39;s3&#39;)<br>response = s3.list_buckets()<br><br># Output the bucket names<br>print(&#39;Existing buckets:&#39;)<br>for bucket in response[&#39;Buckets&#39;]:<br>    print(f&#39;  {bucket[&quot;Name&quot;]}&#39;)</pre><ul><li>Uploading file to the created S3 bucket:</li></ul><pre>import boto3<br>def upload_file_to_s3(file_path, bucket_name, s3_key):<br>    try:<br>        s3 = boto3.client(&#39;s3&#39;)<br>        s3.upload_file(file_path, bucket_name, s3_key)<br>        print(f&quot;File &#39;{file_path}&#39; uploaded to S3 bucket &#39;{bucket_name}&#39; with key &#39;{s3_key}&#39;.&quot;)<br>        return True<br><br>    except Exception as e:<br>        print(f&quot;An error occurred while uploading the file: {e}&quot;)<br>        return False<br><br>bucket_name = input(&#39;your-bucket-name:&#39;)<br>local_file_path = input(&#39;Path of local file:&#39;)<br>s3_file_key = input(&#39;File name:&#39;)<br>upload_file_to_s3(local_file_path, bucket_name, s3_file_key)</pre><ul><li>delete S3 bucket(we need to delete its content first):</li></ul><pre>import boto3<br>def delete_s3_bucket(bucket_name):<br>    try:<br>        s3 = boto3.client(&#39;s3&#39;)<br>        bucket = s3.Bucket(&#39;bucket_name&#39;)<br>        for key in bucket.objects.all():<br>            key.delete()<br>        bucket.delete()<br>        print(f&quot;S3 bucket &#39;{bucket_name}&#39; deleted successfully.&quot;)<br>        return True<br><br>    except Exception as e:<br>        print(f&quot;An error occurred while deleting the S3 bucket: {e}&quot;)<br>        return False<br><br>bucket_name = input(&#39;your-bucket-name&#39;)<br>delete_s3_bucket(bucket_name)</pre><p>We can add the code to Lambda function or python script and trigger it once we need to do any activity with S3 bucket.</p><p>Here it is! You are done!<br>Thank you for taking the time to read my article. I hope you find it helpful.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9bf1cc0ebf96" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AWS Container Orchestration ECS vs EKS]]></title>
            <link>https://islamsalah830.medium.com/aws-container-orchestration-ecs-vs-eks-ccc55e53c4d9?source=rss-3906cef5a55a------2</link>
            <guid isPermaLink="false">https://medium.com/p/ccc55e53c4d9</guid>
            <category><![CDATA[aws-container]]></category>
            <category><![CDATA[containers]]></category>
            <category><![CDATA[aws-eks]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[aws-ecs]]></category>
            <dc:creator><![CDATA[Islam Salah]]></dc:creator>
            <pubDate>Sun, 24 Dec 2023 09:08:19 GMT</pubDate>
            <atom:updated>2023-12-24T09:08:19.582Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T66RFguV_3QgwPCdVlIZEQ.png" /></figure><p>With increasing numbers of container compute nodes, teams require tools that offer better resource allocation and resiliency. They need solutions to turn standalone nodes into clusters to manage their containers. They seek a more robust container solution that provides full management of their container workloads in those clusters. At scale, the undifferentiated heavy lifting of operating the container orchestration platform, clusters, and compute nodes can quickly consume even the most proficient teams.</p><p>Building a team with the capabilities required to deliver a highly available, secure, and up-to-date container platform to your internal users is challenging. We saw a similar pattern emerge in the previous decade, as companies adopted virtual machines (VM) and dealt with the management challenges of VM sprawl. Like with that last transformational shift in computing, lack of effective container operations and tooling is a significant barrier to adoption.</p><h3><strong>Amazon Elastic Container Service (ECS):</strong></h3><p>Amazon ECS is a fully managed container orchestration service that simplifies the deployment and management of containers. It leverages AWS infrastructure to provide a reliable and scalable platform for running containerized applications.</p><ul><li><strong>Simple to use:</strong> Users have fewer decisions to make regarding computer, network, and security configurations, while still enjoying its capabilities.</li><li><strong>Seamless integration with other AWS services:</strong> ECS integrates well with other AWS services such as Elastic Load Balancing, Identity and Access Management (IAM), CloudWatch, and more, allowing you to build highly scalable and reliable applications.</li><li><strong>Flexible scaling options:</strong> ECS provides auto-scaling capabilities, allowing you to automatically scale your applications based on demand. You can configure scaling policies to adjust the number of tasks or services running in your ECS cluster.</li></ul><h3>AWS ECS use cases:</h3><ul><li><strong>Microservices architecture:</strong> ECS is well-suited to deploying microservices-based applications. Its flexible scaling options and seamless integration with other AWS services make it a popular choice for building scalable and resilient microservices architectures.</li><li><strong>Monolithic application migration:</strong> If you have an existing monolithic application and want to migrate it to a containerized environment, ECS provides an easy transition path. You can containerize individual components of your application and deploy them on ECS gradually.</li></ul><h3><strong>Amazon Elastic Kubernetes Service (EKS):</strong></h3><p>Amazon EKS is a managed Kubernetes service that simplifies the deployment, scaling, and management of containerized applications using Kubernetes, an open-source container orchestration platform.</p><ul><li><strong>Kubernetes ecosystem:</strong> EKS provides access to the Kubernetes ecosystem, including a range of tools, plugins, and integrations. This allows you to leverage existing Kubernetes expertise.</li><li><strong>High availability and scalability:</strong> EKS automatically manages the Kubernetes control plane, ensuring high availability and scalability for your applications. EKS clusters can span multiple availability zones, providing fault tolerance and enabling you to scale your applications easily.</li><li><strong>Enhanced security and compliance:</strong> EKS integrates with AWS Identity and Access Management (IAM) for access control, allowing you to enforce security best practices.</li></ul><h3>AWS EKS use cases:</h3><ul><li><strong>Kubernetes expertise:</strong> If you already have experience with Kubernetes or want to take advantage of the Kubernetes ecosystem, EKS is a natural choice. EKS provides a managed Kubernetes control plane, allowing you to focus on deploying and managing your applications without worrying about the underlying infrastructure.</li><li><strong>Multi-cloud deployments:</strong> EKS supports multi-region and multi-cloud deployments, allowing you to run Kubernetes clusters across different AWS regions or even on other cloud providers. This flexibility is valuable if you have specific requirements for distributed or hybrid cloud architectures.</li></ul><p>Here it is! You are done!<br>Thank you for taking the time to read my article. I hope you find it helpful.</p><h3><strong>References:</strong></h3><ul><li><a href="https://aws.amazon.com/blogs/containers/amazon-ecs-vs-amazon-eks-making-sense-of-aws-container-services/">Amazon ECS vs Amazon EKS: making sense of AWS container services | Amazon Web Services</a></li><li><a href="https://aws.amazon.com/ecs/">Fully Managed Container Solution - Amazon Elastic Container Service (Amazon ECS) - Amazon Web Services</a></li><li><a href="https://aws.amazon.com/eks/">Amazon EKS Customers | Managed Kubernetes Service | Amazon Web Services</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ccc55e53c4d9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Kubernetes Volume Types]]></title>
            <link>https://islamsalah830.medium.com/kubernetes-volume-types-669c4a12bf99?source=rss-3906cef5a55a------2</link>
            <guid isPermaLink="false">https://medium.com/p/669c4a12bf99</guid>
            <category><![CDATA[emptydir]]></category>
            <category><![CDATA[k8s-persistent-volume]]></category>
            <category><![CDATA[kubernetes-volume-type]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[k8s-hostpath-volumes]]></category>
            <dc:creator><![CDATA[Islam Salah]]></dc:creator>
            <pubDate>Sat, 14 Oct 2023 21:38:23 GMT</pubDate>
            <atom:updated>2023-12-31T14:10:18.715Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/624/0*LNlWAFPMC6rz8YlS.png" /></figure><p>A Kubernetes volume is a directory containing data, which can be accessed by containers in a Kubernetes pod.</p><p>The location of the directory, the storage media that supports it, and its contents, depend on the specific type of volume being used.</p><p>Volumes are defined in the .spec.containers[*].volumeMounts field of the pod template. For each pod and each container image within the pod, you need to specify which volumes it will mount and on which paths (the paths can be different for each container).</p><p>Types of Kubernetes Volumes:</p><ul><li>Ephemeral Volumes</li><li>Persistent Volumes</li></ul><h3><strong>Ephemeral Volumes</strong></h3><p>Simply these volumes follow the Pod’s lifetime and get created and deleted along with the Pod. Pods can be stopped and restarted without being limited to where some persistent volume is available.</p><p>Some application need additional storage but don’t care whether that data is stored persistently across restarts. For example, caching services are often limited by memory size and can move infrequently used data into storage that is slower than memory with little impact on overall performance.</p><p>Types of ephemeral volumes:</p><ul><li>emptyDir: empty at Pod startup, with storage coming locally from the kubelet base directory (usually the root disk) or RAM</li><li>configMap, downwardAPI, secret: inject different kinds of Kubernetes data into a Pod</li><li>CSI ephemeral volumes: similar to the previous volume kinds, but provided by special CSI drivers which specifically support this feature</li><li>generic ephemeral volumes, which can be provided by all storage drivers that also support persistent volumes</li></ul><pre>apiVersion: v1<br>kind: Pod<br>metadata:<br>  name: test-pd<br>spec:<br>  containers:<br>  - image: registry.k8s.io/test-webserver<br>    name: test-container<br>    volumeMounts:<br>    - mountPath: /cache<br>      name: cache-volume<br>  volumes:<br>  - name: cache-volume<br>    emptyDir:<br>      sizeLimit: 500Mi</pre><h3>Persistent Volumes</h3><p>A PersistentVolume (PV) is a piece of storage in the cluster that has been provisioned by an administrator or dynamically provisioned using Storage Classes. It is a resource in the cluster just like a node is a cluster resource. PVs are volume plugins like Volumes, but have a lifecycle independent of any individual Pod that uses the PV. This API object captures the details of the implementation of the storage, be that NFS, iSCSI, or a cloud-provider-specific storage system.</p><p>A PersistentVolumeClaim (PVC) is a request for storage by a user. It is similar to a Pod. Pods consume node resources and PVCs consume PV resources. Pods can request specific levels of resources (CPU and Memory). Claims can request specific size and access modes</p><pre>apiVersion: v1<br>kind: PersistentVolume<br>metadata:<br>  name: foo-pv<br>spec:<br>  storageClassName: &quot;&quot;<br>  claimRef:<br>    name: foo-pvc<br>    namespace: foo<br>  ...</pre><pre>apiVersion: v1<br>kind: PersistentVolumeClaim<br>metadata:<br>  name: foo-pvc<br>  namespace: foo<br>spec:<br>  storageClassName: &quot;&quot; # Empty string must be explicitly set otherwise default StorageClass will be set<br>  volumeName: foo-pv<br>  ...</pre><pre>apiVersion: v1<br>kind: Pod<br>metadata:<br>  name: mypod<br>spec:<br>  containers:<br>    - name: myfrontend<br>      image: nginx<br>      volumeMounts:<br>      - mountPath: &quot;/var/www/html&quot;<br>        name: mypd<br>  volumes:<br>    - name: mypd<br>      persistentVolumeClaim:<br>        claimName: foo-pvc</pre><p>A <strong>hostPath </strong>classified as persistent volume and could be mounts as directory or file from the host node’s filesystem into your pod directly or via PV and PVC</p><pre>apiVersion: v1<br>kind: PersistentVolume<br>metadata:<br>  name: task-pv-volume<br>  labels:<br>    type: local<br>spec:<br>  storageClassName: manual<br>  capacity:<br>    storage: 10Gi<br>  accessModes:<br>    - ReadWriteOnce<br>  hostPath:<br>    path: &quot;/mnt/data&quot;</pre><pre>apiVersion: v1<br>kind: Pod<br>metadata:<br>  name: test<br>spec:<br>  containers:<br>  - image: nginx:1.7.9<br>    name: test<br>    volumeMounts:<br>    - mountPath: /test<br>      name: test-volume<br>  volumes:<br>  - name: test-volume<br>    hostPath:<br>      path: /data</pre><p>Thank you for taking the time to read my article. I hope you find it helpful.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=669c4a12bf99" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Kubernetes Deployment Strategies Types]]></title>
            <link>https://islamsalah830.medium.com/kubernetes-deployment-strategies-types-f4ba7c88eed2?source=rss-3906cef5a55a------2</link>
            <guid isPermaLink="false">https://medium.com/p/f4ba7c88eed2</guid>
            <category><![CDATA[deployment]]></category>
            <category><![CDATA[strategy-deployment]]></category>
            <category><![CDATA[recreate-deployment]]></category>
            <category><![CDATA[rolling-updates]]></category>
            <category><![CDATA[kubernetes]]></category>
            <dc:creator><![CDATA[Islam Salah]]></dc:creator>
            <pubDate>Sat, 14 Oct 2023 12:59:45 GMT</pubDate>
            <atom:updated>2023-10-14T13:01:29.112Z</atom:updated>
            <content:encoded><![CDATA[<p>Kubernetes deployment strategies are the way that pods are updated, downgraded or created into new versions of applications. Kubernetes deployment strategies work by replacing pods of previous versions of your application with pods of the new version. The main benefits of these Kubernetes deployment strategies are that it mitigates the risk of disruptions and downtime of services.</p><p>There are several different types of deployment strategies you can take advantage of depending on your goal. For example, you may need to roll out changes to a specific environment for more testing, or a subset of users/customers or you may want to do some user testing before making a feature ‘Generally Available’. Here’s a summary of some common Kubernetes deployment strategy types:</p><h3>Rolling Deployment</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/721/1*qN9zU8tDxVR4NiM35oMVBA.png" /><figcaption>Rolling Update</figcaption></figure><p>A rolling deployment is the default deployment strategy in Kubernetes. It replaces the existing version of pods with a new version, updating pods slowly one by one, without cluster downtime.</p><p>The rolling update uses a readiness probe to check if a new pod is ready, before starting to scale down pods with the old version. If there is a problem, you can stop an update and roll it back, without stopping the entire cluster.</p><p>To refine your deployment strategy, change the parameters in the spec:strategy section of your manifest file. There are two optional parameters — maxSurge and maxUnavailable:</p><ul><li><strong>MaxSurge</strong> specifies the maximum number of pods the Deployment is allowed to create at one time.</li><li><strong>MaxUnavailable</strong> specifies the maximum number of pods that are allowed to be unavailable during the rollout.</li></ul><pre>apiVersion: apps/v1beta1<br>kind: Deployment<br>metadata:<br>  name: app<br>spec:<br>  replicas: 3<br>  strategy:<br>    type: RollingUpdate<br>    rollingUpdate:<br>      maxSurge: 3<br>      maxUnavailable: 1<br>  template:<br>        metadata:<br>           labels:<br>             app: app<br>        spec:<br>          containers:<br>            - name: app<br>              image: nginx<br>              ports:<br>                - containerPort: 8080</pre><h3>Recreating Deployments</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*a2s3IAeeqGXS0FiE.jpg" /><figcaption>Recreate Deployment</figcaption></figure><p>This is a basic deployment pattern which simply shuts down all the old pods and replaces them with new ones. The Recreate strategy can result in downtime, because old pods are deleted before ensuring that new pods are rolled out with the new version of the application.</p><pre>spec:<br>  replicas: 3<br>  strategy:<br>    type: Recreate</pre><h3>Blue-Green Deployment</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/408/1*I0rPGhm-oy95mIpDx4BnKw.png" /><figcaption>Blue-Green Deployment</figcaption></figure><p>In a Blue-Green deployment within Kubernetes, you maintain two versions of a deployment: ‘Blue’ for the current version and ‘Green’ for the new one. You can use Kubernetes services to manage the traffic between.</p><pre>kind: Deployment<br>metadata:<br>  name: web-app<br>spec:<br>  template:<br>        metadata:<br>           labels:<br>             app: web-app<br>             version: &quot;v1&quot;</pre><pre>kind: Service<br>metadata:<br> name: web-app<br> labels:<br>   app: web-app<br>selector:<br>   app: web-app<br>   version: v1</pre><p>We will create a new deployment and service for new version v2 same to route the traffic to it.</p><h3>Canary Deployments</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/527/1*Gv8JsHXLIwL2Bp3jeNk8Gg.png" /><figcaption>Canary Deployments</figcaption></figure><p>Canary Deployments introduce a new version of the application to a subset of users or traffic. This allows for testing and validation before a full rollout and helps detect issues early.</p><p>For example, in a K8s Cluster with 100 running pods, 80 could be running v1 of the application, with 20 running the new v2 of the application. 80% of the users will be routed to the old version, and 20% will be routed to the new version. For this, we use 2 deployments side-by-side that can be scaled separately.</p><p>There are many other deployment strategies like:</p><ul><li>A/B Testing</li><li>Shadow Deployment</li><li>Feature Toggles</li><li>etc</li></ul><p>These deployment strategy types in Kubernetes offer various ways to manage updating releases, scaling, and testing of applications. The choice of strategy depends on your application’s requirements, your risk tolerance, and your desire for automation and control during the deployment process.</p><p>Thank you for taking the time to read my article. I hope you find it helpful.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f4ba7c88eed2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Migrate an on-premises MySQL database to Amazon RDS MySQL with AWS DMS]]></title>
            <link>https://islamsalah830.medium.com/migrate-an-on-premises-mysql-database-to-amazon-rds-mysql-with-aws-dms-d2ea008f75c7?source=rss-3906cef5a55a------2</link>
            <guid isPermaLink="false">https://medium.com/p/d2ea008f75c7</guid>
            <category><![CDATA[aws-dms]]></category>
            <category><![CDATA[mysql]]></category>
            <category><![CDATA[aws-rds]]></category>
            <category><![CDATA[aws-database-migration]]></category>
            <category><![CDATA[rds-mysql]]></category>
            <dc:creator><![CDATA[Islam Salah]]></dc:creator>
            <pubDate>Sat, 30 Sep 2023 22:00:34 GMT</pubDate>
            <atom:updated>2023-09-30T22:00:34.737Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/743/1*cxhzi5SCxJV66_GqGw6iFQ.png" /></figure><p><strong>AWS DMS Service</strong></p><p>AWS Database Migration Service (AWS DMS) is a managed migration and replication service that helps move your database and analytics workloads to AWS quickly, securely, and with minimal downtime and zero data loss. AWS DMS supports migration between 20-plus database and analytics engines, such as Oracle to Amazon Aurora MySQL-Compatible Edition, MySQL to Amazon Relational Database (RDS) for MySQL, Microsoft SQL Server to Amazon Aurora PostgreSQL-Compatible Edition, MongoDB to Amazon DocumentDB (with MongoDB compatibility), Oracle to Amazon Redshift, and Amazon Simple Storage Service (S3).</p><p><strong>AWS RDS</strong></p><p>Amazon RDS is a fully managed service for running relational databases with AWS. It has support for six different database engines, including open-source options such as MySQL, PostgreSQL, and MariaDB. With Amazon RDS, your database operations are managed by AWS, leaving your team free to focus on innovation. Amazon RDS handles instance failover, data backups, and software updates. Rely on the efficiencies of the AWS Cloud to use a faster, cost-efficient, and more reliable database option.</p><p>This pattern provides guidance for migrating an on-premises MySQL database to Amazon Relational Database Service (Amazon RDS) for MySQL. The pattern discusses the use of AWS Database Migration Service (AWS DMS) . This pattern is primarily for DBAs and solution architects. It can be used in small or large projects as a testing procedure.</p><p><strong>Setps to Migrate on-premises MySQL database to Amazon:</strong></p><p><strong>1- Create a MySQL database instance in Amazon RDS.</strong></p><ul><li>Navigate to the <a href="https://console.aws.amazon.com/rds/home">Amazon RDS console</a>. On the main page, choose Create database to create a new database.</li><li>This initiates the database creation wizard. In the Engine options section, choose MySQL as the Engine type. Then choose the version of MySQL you want to use. Note that AWS DMS supports only MySQL versions 5.5, 5.6, and 5.7.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*KMcggFYYlFkvdF5S.png" /></figure><ul><li>In the Settings section, give your database a name and set the master username and password.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*PuN2i3zwSa6DvklV.png" /></figure><ul><li>When your database is ready to use, its Status is Available.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1007/1*k-KBEvsU__SrROWKwwFkxw.png" /></figure><p><strong>2- Create a replication instance in AWS DMS.</strong></p><ul><li>AWS DMS is a service that copies data from an existing database into a fully managed database on AWS. A replication instance is an Amazon EC2 instance that can host replication tasks within AWS DMS.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*RtVC-myN2NpJHTKx.png" /></figure><ul><li>In the Replication instance configuration section, give your replication instance a name and description. Then choose your instance class. The instance class you use depends on the size of your existing database and the amount of data flowing through it.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/803/0*IcyhVox8IPHS5_gr.png" /></figure><ul><li>In the Replication instance configuration section, you need to choose a VPC for your replication instance. Choose the same VPC in which you provisioned your Amazon RDS database</li></ul><p><strong>3- Create endpoints for a replication task in AWS DMS.</strong></p><ul><li>Create source and target endpoints for a replication task in AWS DMS.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_ar1fU7beZKGrum0.png" /></figure><ul><li>In the endpoint creation wizard, choose to create a Target endpoint. Choose the check box to Select RDS DB instance, and choose your newly created Amazon RDS database in the dropdown. before you save your endpoint, test the connection to ensure that it was configured correctly.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/820/1*Gz6XzVgQ2-hlyyNnN3LlGw.png" /></figure><ul><li>Follow these same steps again to create an endpoint for your source database.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ng4ncuhP1QjeN9_92Sou6g.png" /></figure><p><strong>4- Create a replication task in AWS DMS.</strong></p><ul><li>Replication task is responsible for migrating data from a source database to a target database. In our case, you are moving data from an existing database to your newly created database in Amazon RDS.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*wz3MZ1FVupH-HKG7.png" /></figure><ul><li>In the Task configuration section, set up the parameters of your replication task. Give your task a name, and select the replication instance you created in an earlier module. Then choose the source endpoint for your existing database and your target endpoint for your fully managed database in Amazon RDS.</li></ul><p><strong>5- Complete the migration and clean up the resources.</strong></p><ul><li>After applying the previous steps in this lesson, you have created a new, fully managed MySQL database in Amazon RDS. And to clean up your AWS DMS resources.</li><li>Stop and delete the database migration task to replicate your data.</li><li>Navigate to the <a href="https://console.aws.amazon.com/dms/v2/home#endpointList">Endpoints section</a> of the AWS DMS console. Choose both source endpoint and target endpoint, and then choose Delete.</li><li>Then go to the <a href="https://console.aws.amazon.com/dms/v2/home#replicationInstances">Replication instances</a> section of the AWS DMS console, choose it and then choose Delete.</li><li>Finally, you may want to terminate your source database because it is no longer being used.</li></ul><p>Here it is! You are done!</p><p>Thank you for taking the time to read my article. I hope you find it helpful.</p><p>References that I used:</p><ul><li><a href="https://docs.aws.amazon.com/prescriptive-guidance/latest/patterns/migrate-an-on-premises-mysql-database-to-amazon-rds-for-mysql.html">https://docs.aws.amazon.com/prescriptive-guidance/latest/patterns/migrate-an-on-premises-mysql-database-to-amazon-rds-for-mysql.html</a></li><li><a href="https://docs.aws.amazon.com/dms/latest/userguide/CHAP_Introduction.Components.html">https://docs.aws.amazon.com/dms/latest/userguide/CHAP_Introduction.Components.html</a></li><li><a href="https://aws.amazon.com/tutorials/move-to-managed/migrate-my-sql-to-amazon-rds/">https://aws.amazon.com/tutorials/move-to-managed/migrate-my-sql-to-amazon-rds/</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d2ea008f75c7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deploy Python Application on AWS EC2 and using Amazon RDS as Database Engine]]></title>
            <link>https://islamsalah830.medium.com/create-python-application-on-aws-ec2-and-an-amazon-rds-database-instance-b6ad906ac976?source=rss-3906cef5a55a------2</link>
            <guid isPermaLink="false">https://medium.com/p/b6ad906ac976</guid>
            <category><![CDATA[rds-mysql]]></category>
            <category><![CDATA[database]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[ec2-instance]]></category>
            <dc:creator><![CDATA[Islam Salah]]></dc:creator>
            <pubDate>Sat, 16 Sep 2023 20:16:16 GMT</pubDate>
            <atom:updated>2025-02-11T22:09:28.796Z</atom:updated>
            <content:encoded><![CDATA[<h3>Deploy Python Application on AWS EC2 and using an Amazon RDS as Database Engine</h3><p>Creating a Python backend application on AWS EC2 with an Amazon RDS database instance involves several steps. This guide assumes you have an AWS account . If you haven’t AWS account, you can follow AWS documentation to get started with Creating AWS account.</p><p><a href="https://docs.aws.amazon.com/accounts/latest/reference/manage-acct-creating.html">https://docs.aws.amazon.com/accounts/latest/reference/manage-acct-creating.html</a>(Create AWS Account).</p><p><strong>Amazon Elastic Compute Cloud</strong> (Amazon EC2) offers the broadest and deepest compute platform, with over 600 instances and choice of the latest processor, storage, networking, operating system, and purchase model to help you best match the needs of your workload. We are the first major cloud provider that supports Intel, AMD, and Arm processors, the only cloud with on-demand EC2 Mac instances, and the only cloud with 400 Gbps Ethernet networking. We offer the best price performance for machine learning training, as well as the lowest cost per inference instances in the cloud. More SAP, high performance computing (HPC), ML, and Windows workloads run on AWS than any other cloud.</p><p><strong>Amazon Relational Database Service</strong> (Amazon RDS) is a collection of managed services that makes it simple to set up, operate, and scale databases in the cloud. Choose from seven popular engines — <a href="https://aws.amazon.com/rds/aurora/?pg=ln&amp;sec=hiw">Amazon Aurora with MySQL compatibility</a>, <a href="https://aws.amazon.com/rds/aurora/?pg=ln&amp;sec=hiw">Amazon Aurora with PostgreSQL compatibility</a>, <a href="https://aws.amazon.com/rds/mysql/?pg=ln&amp;sec=hiw">MySQL</a>, <a href="https://aws.amazon.com/rds/mariadb/?pg=ln&amp;sec=hiw">MariaDB</a>, <a href="https://aws.amazon.com/rds/postgresql/?pg=ln&amp;sec=hiw">PostgreSQL</a>, <a href="https://aws.amazon.com/rds/oracle/?pg=ln&amp;sec=hiw">Oracle</a>, and <a href="https://aws.amazon.com/rds/sqlserver/?pg=ln&amp;sec=hiw">SQL Server</a> — and deploy on-premises with <a href="https://aws.amazon.com/rds/outposts/?pg=ln&amp;sec=hiw">Amazon RDS on AWS Outposts</a>.</p><p>Here are the steps to create a Python backend application on AWS EC2 and connect it to an Amazon RDS database:</p><p><strong>1- Create Network Infrastructure:</strong></p><ul><li>create VPC with appropriate CIDR.</li><li>Create public subnet for Application Instance.</li><li>Create private subnet for RDS DB Instance.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/770/0*N1bjzsnnMypo73eX.png" /></figure><p><strong>2- Launch an RDS Instance:</strong></p><ul><li>Navigate to the RDS service.</li><li>Launch a new RDS instance, selecting an appropriate Engine options and instance type.</li><li>Setup DB parameters(DB name, Master username, password, subnet, SG…etc).</li><li>check Monitoring options and additional settings<strong>.</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BG6G8Ao6LIh7y_UbejSnxw.png" /></figure><p><strong>3- Connect to RDS DB to create DB schema:</strong></p><ul><li>Connect to DB server using Endpoint and Master password.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/925/1*GI5q7_86aIR0zjEte3lXMw.png" /></figure><ul><li>Run SQL Queries to create DB schema which containing all needed tables.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u7fMoXl0D-hJee0MtPUxdQ.png" /></figure><p><strong>4- Launch an EC2 Instance for Application server:</strong></p><ul><li>Log in to your AWS Management Console.</li><li>Navigate to the EC2 service.</li><li>Launch a new EC2 instance, selecting an appropriate Amazon Machine Image (AMI) and instance type.</li><li>Ensure that the security group associated with your EC2 instance allows incoming traffic on the required ports (e.g., 80 for HTTP or 443 for HTTPS, 22 for SSH).</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1Fnn7wI37mIqIxYq8uLx8g.png" /></figure><p><strong>5- Connect to EC2 Instance via SSH:</strong></p><ul><li>Connect to Instance using Key pair and public IP.</li><li>Run below steps and command to setup application on the instance:</li></ul><pre>sudo apt update -y<br>sudo yum install python3-pip -y<br>yum install git -y<br>git clone https://github.com/islamsalah2020/WebApp_Python_Flask_Mysql.git<br>cd WebApp_Python_Flask_Mysql/<br>python3 -m venv myvenv<br>source myvenv/bin/activate<br>pip install -r requirements.txt<br>Python3 app.py</pre><ul><li>don’t forget to edit DB Connections endpoint in app.py file with yours.</li></ul><p><strong>6- Connect to your Application:</strong></p><ul><li>Navigate to the browser (public_ip:3000)</li><li>if there is any issue please check your SG rules.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-mKizFd6U3brNvWv9E6VZQ.png" /></figure><p>Here it is! You are done!</p><p>Remember to follow AWS best practices for security, scalability, and cost optimization throughout the process. AWS offers a range of services that can complement your architecture, such as Amazon Elastic Beanstalk, AWS Lambda, and AWS API Gateway, depending on your application’s specific requirements.</p><p>Thank you for taking the time to read my article. I hope you find it helpful.</p><p>Please check my GitHub repo for the Code (<a href="https://github.com/islamsalah2020/WebApp_Python_Flask_Mysql">GitHub Repo</a>).</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b6ad906ac976" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AWS Serverless Using Lambda and DynamoDB]]></title>
            <link>https://islamsalah830.medium.com/aws-serverless-using-lambda-and-dynamodb-865a5501073d?source=rss-3906cef5a55a------2</link>
            <guid isPermaLink="false">https://medium.com/p/865a5501073d</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[dynamodb]]></category>
            <category><![CDATA[aws-lambda]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[serverless]]></category>
            <dc:creator><![CDATA[Islam Salah]]></dc:creator>
            <pubDate>Sun, 21 May 2023 06:45:26 GMT</pubDate>
            <atom:updated>2023-05-21T06:45:26.282Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/654/1*od8poj9eZ_WRpkWIaRtI3w.png" /></figure><p>In this article, I will show you how to create and invoke two serverless AWS Lambda Functions that write and read data to and from a DynamoDB Table.</p><p>AWS offers technologies for running code, managing data, and integrating applications, all without managing servers.</p><p>Serverless technologies feature automatic scaling, built-in high availability, and a pay-for-use billing model to increase agility and optimize costs. These technologies also eliminate infrastructure management tasks like capacity provisioning and patching, so you can focus on writing code that serves your customers.</p><p>There are many AWS Serverless services and we will use some of them in that article:</p><p><strong>AWS Lambda</strong> is a compute service that lets you run code without provisioning or managing servers.</p><p><strong>Amazon DynamoDB</strong> is a fast and flexible nonrelational database service for all applications that need consistent, single-digit millisecond latency at any scale.</p><p><strong>Step 1: Create DynamoDB table</strong><br>1.1 Enter the table name (planets) and primary key (id) and select String for type then click on Create Table.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/815/0*XXjeEq3DOd8HmlxC.png" /></figure><ol><li>2 Your table has been created.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/0*7v2C2oWbK5xzMAiO.png" /></figure><ol><li>3 Create some sample items as below from the console.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/0*hywrGLlCabOIjpZS.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/0*N6Kab5IPoZIe7HOx.png" /></figure><p><strong>Step 2: Create First Lambda Function to insert in DynamoDB Table.</strong></p><p>2.1 Create Lambda function with name (PutNewPlanet) and Runtime Python 3.7.</p><p>2.2 Create IAM role with DynamoDB Full Access Policy (DynamoDB-role-for-lambda-execution) to be able to insert and retrieve from DynamoDB Table.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/0*0a_oQ8zRgkCQVlNA.png" /></figure><p>2.3 Add your python code that we will use to insert new record in DynamoDB Table and then click on Deploy.</p><pre>import json<br>import boto3<br><br>dynamodb = boto3.resource(&#39;dynamodb&#39;)<br>table = dynamodb.Table(&#39;planets&#39;)<br><br>def lambda_handler(event, context):<br>    table.put_item(<br>    Item={&#39;id&#39;: &#39;Venus&#39;, &#39;temp&#39;: &#39;extremally hot&#39;}<br>    )<br>    response = {<br>        &#39;message&#39;: &#39;item added&#39;<br>    }<br>    print (response)<br>    # TODO implement<br>    return {<br>        &#39;statusCode&#39;: 200,<br>        &#39;body&#39;: response<br>    }</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/0*TAoJQSJAleoAsisQ.png" /></figure><p>2.4 Click on Test to create Test Event to trigger Lambda Function.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/0*lqX7uPwOfoRlqv46.png" /></figure><p>2.5 Click on Test to invoke lambda Function and check the output.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/0*LFxK_rHrZTtqL_vb.png" /></figure><p>2.6 Go back to DynamoDB Table and Check the table items.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/0*8VtB6fm8g_e7BnaQ.png" /></figure><p><strong>Step 3: Create Second Lambda Function to retrieve data from DynamoDB Table.</strong></p><p>3.1 Create Lambda function with name (GetItemPlanet) and Runtime Python 3.7.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/0*4nWI9lfY3hhvvMVl.png" /></figure><p>3.2 Add your python code that we will use to get data from DynamoDB Table and then click on Deploy.</p><pre>import json<br>import boto3<br><br>dynamodb = boto3.resource(&#39;dynamodb&#39;)<br>table = dynamodb.Table(&#39;planets&#39;)<br><br>def lambda_handler(event, context):<br>    response = table.get_item(<br>    Key={&#39;id&#39;: &#39;Earth&#39;}<br>    )<br><br>    print (response)<br>    # TODO implement<br>    return {<br>        &#39;statusCode&#39;: 200,<br>        &#39;body&#39;: response<br>    }</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/0*yRWrLV_aXtYlMHez.png" /></figure><p>3.3 Click on Test to create Test Event to trigger Lambda Function same step as 2.4.</p><p>3.4 Click on Test to invoke lambda Function and check the output.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/0*owFkr_l0l4xFw25R.png" /></figure><p>Here it is! You are done!<br>Thank you for taking the time to read my article. I hope you find it helpful.</p><p>Please check my GitHub repo for the Code (<a href="https://github.com/islamsalah2020/AWS_Lambda_Dynamodb.git">GitHub Repo</a>).</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=865a5501073d" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>