<?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 Wajahat Ali Abid on Medium]]></title>
        <description><![CDATA[Stories by Wajahat Ali Abid on Medium]]></description>
        <link>https://medium.com/@wajahataliabid?source=rss-e3bae3492fdf------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*nSZEXwSTfs8wmL2XFNK_jA.jpeg</url>
            <title>Stories by Wajahat Ali Abid on Medium</title>
            <link>https://medium.com/@wajahataliabid?source=rss-e3bae3492fdf------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 20:43:11 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@wajahataliabid/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[Yet another implementation for Slack Commands]]></title>
            <link>https://medium.com/onebyte-llc/yet-another-implementation-for-slack-commands-a74d1b103f84?source=rss-e3bae3492fdf------2</link>
            <guid isPermaLink="false">https://medium.com/p/a74d1b103f84</guid>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[lambda]]></category>
            <category><![CDATA[slack-commands]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Wajahat Ali Abid]]></dc:creator>
            <pubDate>Mon, 19 Sep 2022 09:29:27 GMT</pubDate>
            <atom:updated>2022-09-19T13:24:15.702Z</atom:updated>
            <content:encoded><![CDATA[<h3>Yet Another Implementation for Slack Commands</h3><h3>Overview</h3><p>We’re using Slack for communication within our team. Using Slack slash commands, we also handle common day-to-day tasks like triggering deployments on different servers based on requirements. For a long time, that remained our primary use case, so we had a single AWS Lambda function taking care of this job. However, with the growing team and business, we felt the need to handle several other tasks this way. Thus, we created a few more Lambda functions that handled different tasks but the behavior among different Lambda functions wasn’t consistent, since each function was maintained separately.</p><h3>General Idea</h3><p>We decided to create a single Lambda function that will be solely used for handling all the slash command requirements. The commands will follow a similar structure as normal shell commands do. Some examples are as follows</p><ul><li><strong><em>help</em></strong>: List down all the slash commands with usage</li><li><strong><em>help deploy</em></strong>: List down help text for deploy commands, including all the options it takes and flags</li><li><strong><em>deploy</em></strong>: Deploy for a specific client</li></ul><p>Some examples of Slack slash commands are as follows (assuming our slash command is /example)</p><pre>/example help</pre><pre>/example help deploy</pre><pre>/example help deploy --client test-client --branch master</pre><p>We can limit users who can issue a command as well as channels where the command can be issued from by using a very simple configuration:</p><pre>{</pre><pre>   &quot;command&quot;: &quot;deploy&quot;</pre><pre>   &quot;users&quot;<em>:</em> [</pre><pre>      &quot;example.user&quot;</pre><pre>   ],</pre><pre>   &quot;channels&quot;: [</pre><pre>      &quot;channel_id&quot;</pre><pre>   ]<br></pre><pre>}</pre><h3>Implementation</h3><p>We implemented this solution in Python with the help of some useful packages from the open-source community. Some of these packages are as follows:</p><ul><li><a href="https://fastapi.tiangolo.com/">Fast API</a>: For the implementation of the main API</li><li><a href="https://mangum.io/">Mangum</a>: For the integration of Aws Lambda, and the API Gateway with the FastApi</li><li><a href="https://python-jenkins.readthedocs.io/en/latest">Python Jenkins</a>: For interacting with the Jenkins server that handles deployments</li><li><a href="https://docs.python.org/3/library/argparse.html">Argparse</a>: For handling argument parsing</li></ul><p>The way our implementation worked was as follows:</p><ul><li>The user sends a command via Slack</li><li>Lambda function verifies if: the command exists, the user is allowed to run the command, the command is allowed to be run from the specified channel, and the command has all the required parameters and responds appropriately</li><li>Execute the command and send the response back to the Slack channel</li><li>Offload the long-running commands to the Ecs container (e.g, database backup or restore)</li></ul><p>The general architecture of this solution is as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KHEL-ZYdsmPf44WQ6bfPcw.png" /></figure><p>This helps us implement new Slack commands really quickly. All the error handling is similar across the different commands, so we don’t need to handle the errors separately for every new command.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a74d1b103f84" width="1" height="1" alt=""><hr><p><a href="https://medium.com/onebyte-llc/yet-another-implementation-for-slack-commands-a74d1b103f84">Yet another implementation for Slack Commands</a> was originally published in <a href="https://medium.com/onebyte-llc">OneByte</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Auto-scaling and Load Balancing a Web Application]]></title>
            <link>https://medium.com/onebyte-llc/auto-scaling-and-load-balancing-a-web-application-da2b8a352d74?source=rss-e3bae3492fdf------2</link>
            <guid isPermaLink="false">https://medium.com/p/da2b8a352d74</guid>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[autoscaling]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[load-balancing]]></category>
            <category><![CDATA[haproxy]]></category>
            <dc:creator><![CDATA[Wajahat Ali Abid]]></dc:creator>
            <pubDate>Wed, 12 Aug 2020 06:32:33 GMT</pubDate>
            <atom:updated>2020-08-12T06:32:33.016Z</atom:updated>
            <content:encoded><![CDATA[<h3>Overview</h3><p>Load balancing in cloud computing is the process in which workloads and computing resources are distributed across more than one server. The workload is divided among two or more servers, network interfaces, hard drives and other computing resources which result in better utilization and system response time, whereas, auto-scaling is a way to automatically scale up or down the number of compute resources that are being allocated to your application based on its needs at any given time.</p><p>There are a number of ways to auto-scale and load balance your applications using a wide range of tools available. In this example, We’ll demonstrate auto-scaling and layer 4 load balancing of a Web API using nothing but open source tools.</p><p>The basic architecture of the implementation looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uJoeRkrd-3swumkfbYkdWw.jpeg" /><figcaption>Load Balancing using HA Proxy</figcaption></figure><h3>Explanation of Architecture</h3><p>At the center of the system lies <a href="http://www.haproxy.org/">HA Proxy</a> which is free, and <a href="https://github.com/haproxy/haproxy">open source</a> software that provides a high availability load balancer and proxy server for TCP and HTTP-based applications that spreads requests across multiple servers. While on the right side is the auto scaler script, which is responsible for launching or destroying docker containers based on the auto-scaling matrix. Whenever a new docker container is launched by the script, the HA Proxy is notified about it. HA Proxy then adds this container to its load balancing group. In case a docker container is removed from the group, HA Proxy removes the container from its load balancing group.</p><h3>Environment Setup</h3><p>To setup this environment, you need to have the following components installed on your system.</p><ol><li>HA Proxy</li><li>Docker</li><li>Python</li></ol><h3>Steps</h3><h4>1. Build Docker Image</h4><pre>docker build -t ha-python ./api</pre><h4>2. Configure HA Proxy</h4><p>Add the following text in the ha proxy configuration file (/etc/haproxy/haproxy.cfg).</p><pre>frontend flask_frontend<br>    	bind 		*:80<br>    	mode 		http<br>    	default_backend flask_backend</pre><pre>backend flask_backend<br>    	balance 	roundrobin</pre><h4>3. Run the autoscaler script</h4><p>Install the required dependencies by running the command</p><pre>python3 -m pip install -r requirements.txt</pre><p>Give script execution permissions</p><pre>sudo chmod +x ./autoscaler.py</pre><p>Run the script by running the command</p><pre>./autoscaler.py</pre><p>Open localhost in the browser, and you’ll be greeted with the following response</p><pre>{<br>    &quot;host&quot;: &quot;095dd8b087c0&quot;,<br>    &quot;message&quot;: &quot;Hello&quot;<br>}</pre><p>Where 095dd8b087c0 is the hostname of the docker container. Install the <a href="https://www.cyberciti.biz/faq/stress-test-linux-unix-server-with-stress-ng/">stress</a> tool and run the command to impose stress on the cpu</p><pre>stress -c 2</pre><p>This will raise the system CPU usage and now each time you open localhost, you’ll see a different host in the response.</p><p>Source code to this is available <a href="https://github.com/WajahatAliAbid/haproxy-docker-loadbalancer-autoscaler">here</a>. You can reach out to me via <a href="/service/mailto:wajahatckl@gmail.com">Email</a>, <a href="https://twitter.com/wajahatAliAbid">Twitter</a> and <a href="https://www.linkedin.com/in/wajahataliabid/">LinkedIn</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=da2b8a352d74" width="1" height="1" alt=""><hr><p><a href="https://medium.com/onebyte-llc/auto-scaling-and-load-balancing-a-web-application-da2b8a352d74">Auto-scaling and Load Balancing a Web Application</a> was originally published in <a href="https://medium.com/onebyte-llc">OneByte</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deploy Go Function on AWS Lambda]]></title>
            <link>https://medium.com/@wajahataliabid/deploy-go-function-on-aws-lambda-a2881eaecbe1?source=rss-e3bae3492fdf------2</link>
            <guid isPermaLink="false">https://medium.com/p/a2881eaecbe1</guid>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[go]]></category>
            <category><![CDATA[aws-lambda]]></category>
            <dc:creator><![CDATA[Wajahat Ali Abid]]></dc:creator>
            <pubDate>Tue, 02 Jul 2019 11:15:51 GMT</pubDate>
            <atom:updated>2019-07-02T11:15:51.456Z</atom:updated>
            <content:encoded><![CDATA[<h3>Deploying Go function on AWS Lambda</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*xjamRAifIsQKnm6FE6Akdw.jpeg" /><figcaption>Go with AWS Lambda</figcaption></figure><p>It is quite simple to deploy the go function on the AWS Lambda using <a href="https://github.com/aws/aws-lambda-go">AWS Lambda Go</a>. I&#39;ll demonstrate the lambda function using a simple request as input for lambda and return OK response for this example.</p><h3>Steps</h3><p>Get the aws lambda tool using.</p><pre>go get -u github.com/aws/aws-lambda-go/cmd/build-lambda.zip</pre><p>Create your lambda function.</p><pre>// main.go<br> package main<br> <br> import (<br>   &quot;fmt&quot;<br>  &quot;github.com/aws/aws-lambda-go/lambda&quot;<br> )<br> <br> type Request struct {<br>  ID float64 `json:&quot;id&quot;`<br>  Value string `json:&quot;value&quot;`<br> }<br> <br> type Response struct {<br>  Message string `json:&quot;message&quot;`<br>  Ok bool `json:&quot;ok&quot;`<br> }<br> <br> func Handler(request Request) (Response, error) {<br>  return Response{<br>    Message: fmt.Sprintf(&quot;Process Request ID %f&quot;, request.ID),       <br>    Ok: true,<br>   }, nil<br> }<br> <br> func main() {<br>  // Make the handler available for Remote Procedure Call by AWS Lambda<br>  lambda.Start(Handler)<br> }</pre><p>Build your lambda function for linux</p><pre>GOOS=linux go build -o main</pre><p>Set required permission for execution</p><pre>sudo chmod +x main</pre><p>Zip the build using command line (You can use any tool to zip the build file)</p><pre>zip -9 main.zip main</pre><p>Upload to lambda and test using the following event argument.</p><pre>{<br> &quot;id&quot;: 123,<br> &quot;value&quot;: &quot;This is a test value&quot;<br>}</pre><p>It gives us the following response.</p><pre>{<br> &quot;message&quot;: &quot;Process Request ID 123.000000&quot;,<br> &quot;ok&quot;: true<br>}</pre><h3>Further Reading</h3><ul><li><a href="https://docs.aws.amazon.com/lambda/latest/dg/welcome.html">What is AWS Lambda</a></li><li><a href="https://docs.aws.amazon.com/lambda/latest/dg/lambda-introduction-function.html">Working with AWS Lambda Functions</a></li><li><a href="https://docs.aws.amazon.com/lambda/latest/dg/programming-model-v2.html">AWS Lambda Programming Model</a></li><li><a href="https://docs.aws.amazon.com/lambda/latest/dg/deploying-lambda-apps.html">AWS Lambda Applications</a></li><li><a href="https://github.com/aws/aws-lambda-go">AWS Lambda Go Repository</a></li></ul><p>TLDR; The link to my <a href="https://github.com/WajahatAliAbid/aws-lambda-go-demo">repository</a> with same code.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a2881eaecbe1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Entity Framework Core 2.1: Data Seeding]]></title>
            <link>https://medium.com/@wajahataliabid/entity-framework-core-2-1-data-seeding-part-1-40c5b6b08b3c?source=rss-e3bae3492fdf------2</link>
            <guid isPermaLink="false">https://medium.com/p/40c5b6b08b3c</guid>
            <category><![CDATA[microsoft]]></category>
            <category><![CDATA[entity-framework-core]]></category>
            <category><![CDATA[csharp]]></category>
            <category><![CDATA[aspnetcore]]></category>
            <dc:creator><![CDATA[Wajahat Ali Abid]]></dc:creator>
            <pubDate>Mon, 30 Jul 2018 23:38:20 GMT</pubDate>
            <atom:updated>2018-09-02T10:11:58.955Z</atom:updated>
            <content:encoded><![CDATA[<p>Microsoft released version 2.1 of Entity Framework Core recently adding quite a lot of improvements to what was already really good. They achieved this by adding builtin support for data seeding and <a href="https://en.wikipedia.org/wiki/View_(SQL)">views</a>. Before this update, you had to work around for data seeding but now you can seed data using what’s known as <a href="https://docs.microsoft.com/en-us/ef/core/managing-schemas/migrations/index">migrations</a>. Those who are unfamiliar with migrations; migrations allow us to create database using <a href="https://docs.microsoft.com/en-us/ef/core/get-started/aspnetcore/new-db">Code First</a> approach. You create your models and <a href="https://msdn.microsoft.com/en-us/library/system.data.entity.dbcontext(v=vs.113).aspx">Database Context</a> class then using either package manager or command line, you can ask entity framework to create migration for you. These migrations will later be used to apply changes to database, or will keep it in sync with your data model while preserving existing data in database.</p><p>The topic I want to discuss right now is Data Seeding in Entity Framework Core which allows us to provide initial data to populate a database. Entity Framework Core can decide what insert, update or delete operations should be applied when applying migrations.</p><p>Let’s consider the example of a simple Blog. First we define model classes.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7e7890f1487e7d6037b97c6f83cdc48d/href">https://medium.com/media/7e7890f1487e7d6037b97c6f83cdc48d/href</a></iframe><p>Alongside Blog and Post class, we also added BlogContext class which is sub-class of DbContext. In the method OnModelCreating of BlogContext, we call HasData method on each entity which allows us to seed data into the database. Afterwards we add migration, Entity Framework Core generates a class for us which converts all the constraints defined in model classes to be applied to database tables. When you run add-migration InitDatabase -o Data/Migrations in the package manager console, Entity Framework Core will generate the following class for us.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/26dc61da3e8a874bebe5704f45ecea1a/href">https://medium.com/media/26dc61da3e8a874bebe5704f45ecea1a/href</a></iframe><p>When migration is applied, the Up method is executed and database tables are created. If we decide to remove the migration and then Down method is executed, and both tables are deleted. Notice there are InsertData method calls on migrationBuilder in the class Entity Framework Core has generated for us. This is because we called HasData on entity builder in our BlogContext class. The following class will be generated if we update the value of url in blog to new Blog{ BlogId=1,url=&quot;www.example.com&quot;} and add another migration.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/69a673a93149e0c640325505cf381317/href">https://medium.com/media/69a673a93149e0c640325505cf381317/href</a></iframe><p>It will call the UpdateData on migration builder to update the value of url of the blog in database. This enables us to seed data easily in the database with the use of migrations.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=40c5b6b08b3c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Asp.net Core 2.1: Custom Configuration Files]]></title>
            <link>https://medium.com/@wajahataliabid/asp-net-core-2-1-custom-configuration-files-b3aaf0c7b003?source=rss-e3bae3492fdf------2</link>
            <guid isPermaLink="false">https://medium.com/p/b3aaf0c7b003</guid>
            <category><![CDATA[microsoft]]></category>
            <category><![CDATA[aspnetcore]]></category>
            <category><![CDATA[csharp]]></category>
            <category><![CDATA[mvc]]></category>
            <dc:creator><![CDATA[Wajahat Ali Abid]]></dc:creator>
            <pubDate>Thu, 26 Jul 2018 22:14:50 GMT</pubDate>
            <atom:updated>2018-12-05T11:52:56.571Z</atom:updated>
            <content:encoded><![CDATA[<p>Problem with Incomplete/Misleading Documentation</p><p>Just like any other developer, when I face any problem, first thing I do is Google my query or search up on Stack Overflow. When I don’t get satisfactory answer, I read the documentation just in case I missed anything last time I read. When I fail to find the solution to that problem in documentation as well, I resort to publishing my own post on Stack Overflow knowing I’ll get a response in a matter of few hours at maximum.<br>This time as well, I was working with Asp.net core project. Usually Asp.net core initially has two JSON files appsettings.json and appsettings.Development.json I wanted to include a new JSON file where I can keep some of the content regarding contents of one of the page. So I looked it up on Stack Overflow. Found a solution that apparently worked for time being. It basically asked to call original method introduced in Asp.net core 1.0 to add new JSON file.</p><pre>public static IWebHostBuilder CreateWebHostBuilder(string[] args)<br>        {<br>            var environment = Environment.GetEnvironmentVariable(&quot;ASPNETCORE_ENVIRONMENT&quot;);<br>            var configuration = new ConfigurationBuilder()<br>                .SetBasePath(Directory.GetCurrentDirectory())<br>                .AddJsonFile(&quot;appsettings.json&quot;, optional: false, reloadOnChange: true)<br>                .AddJsonFile($&quot;appsettings.{environment}.json&quot;, optional: true, reloadOnChange: true)<br>                .AddJsonFile(&quot;mydata.json&quot;, optional: false, reloadOnChange: false)<br>                .Build();<br>            return WebHost.CreateDefaultBuilder(args)<br>                .UseConfiguration(configuration)<br>                .UseStartup&lt;Startup&gt;();<br>        }</pre><p>Even though I did it using this way, it felt kind of off. I wondered why should I use this when I have to specify Asp.net core Environment Variable which is already available through DI in previous versions of Asp.net core. And why should I specify which configuration files to add when they are already added by CreateDefaultBuilder method. I decided to look into documentation for it. I was almost sure I’ll find the solution I want. But what I got was.</p><pre>var builder = new ConfigurationBuilder()<br>           .SetBasePath(Directory.GetCurrentDirectory())<br>           .AddJsonFile(&quot;appsettings.json&quot;);<br>Configuration = builder.Build();</pre><p>I decided why shouldn’t I look at helper methods provided by Asp.net core and thanks to help of Visual Studio Intellisense I was able to find just what I needed.</p><pre>public static IWebHostBuilder CreateWebHostBuilder(string[] args) =&gt;<br>               WebHost.CreateDefaultBuilder(args)<br>                .ConfigureAppConfiguration(options =&gt;<br>                {<br>                    options.AddJsonFile(&quot;mydata.json&quot;, optional: false, reloadOnChange: false);<br>                })<br>                .UseStartup&lt;Startup&gt;();</pre><p>This way I do not need to add the configuration files added by CreateDefaultBuilder method. I can simply say I want to include this JSON file in my configuration file list and that’s all, helping me utilize the helper methods provided by Asp.net core to their fullest. Making my code easier to read and understand.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b3aaf0c7b003" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>