<?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 Syed Muhammad Wajeeh on Medium]]></title>
        <description><![CDATA[Stories by Syed Muhammad Wajeeh on Medium]]></description>
        <link>https://medium.com/@syedmuhammadwajeeh?source=rss-8551dab35add------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*AwrhpruSuGT3jiCNwmqwbg.png</url>
            <title>Stories by Syed Muhammad Wajeeh on Medium</title>
            <link>https://medium.com/@syedmuhammadwajeeh?source=rss-8551dab35add------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 23:13:34 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@syedmuhammadwajeeh/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[How to manage your AWS Organization with SCPs, Budgets, and Lambda — Python]]></title>
            <link>https://medium.com/@syedmuhammadwajeeh/how-to-manage-aws-organization-with-scps-and-lambda-fbc6fbdb490b?source=rss-8551dab35add------2</link>
            <guid isPermaLink="false">https://medium.com/p/fbc6fbdb490b</guid>
            <category><![CDATA[aws-budgets]]></category>
            <category><![CDATA[aws-cloudformation]]></category>
            <category><![CDATA[aws-organizations]]></category>
            <category><![CDATA[aws-lambda]]></category>
            <category><![CDATA[scp]]></category>
            <dc:creator><![CDATA[Syed Muhammad Wajeeh]]></dc:creator>
            <pubDate>Sun, 17 Jul 2022 03:29:58 GMT</pubDate>
            <atom:updated>2022-07-18T09:18:19.040Z</atom:updated>
            <content:encoded><![CDATA[<p>Before diving deep into AWS Organization, it&#39;s essential to understand its usage and the use case where it is to be implemented. AWS Organization is an AWS service that helps you to achieve consolidated billing and manage your AWS Accounts based on your requirements.</p><p>For a high-level overview of AWS Organization, it has a root account that adds/invites the AWS accounts to its organization&#39;s hierarchy.</p><p>An AWS Organization comprises a lot of elements, but for this use case, you need to know these three:<br><strong>1. Organization Unit:</strong> An Organization Unit can be referred to as a department in a traditional hierarchy of any organization. <br><strong>2. SCP:</strong> A Service Control Policy is a set of permissions attached directly to an Organization Unit or an AWS account <br><strong>3. Management Account:</strong> A root account that applies SCPs, monitors billing, and migrates AWS Accounts to different OUs</p><blockquote>To understand the difference between SCP, Inline Policy, and Permission Boundary, refer to <a href="https://medium.com/@syedmuhammadwajeeh/everything-about-scp-vs-permission-boundary-vs-inline-policy-5fb8159565d0">here</a></blockquote><p>There have been diverse use cases to span your AWS Organization but this one in particular covers the high level of dissecting your AWS Organization into two OUs: <br><strong>1. Administrators OU: </strong>This Organization Unit comprises all of the AWS Accounts with an inherited AdministratorFullAccess SCP<br><strong>2. Reserved OU:</strong> This Organization Unit comprises all of the AWS Accounts that will be with the violated budget limitation and IAM ReadOnlyAccess SCP</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*acfJMVDIR_4BmjRLZrP-6g.png" /><figcaption><strong>AWS Organization&#39;s Hierarchy</strong></figcaption></figure><p>Following this use case, an AWS account can be created by providing three following parameters in the &quot;create AWS account&quot; option of AWS Organization: <br><strong>Account Name:</strong> Data Team<em> (ANY)</em><br><strong>Email Address:</strong> datateam@test.com <em>(valid ones ONLY)</em><br><strong>IAM role name:</strong> OrganizationAccountAccessRole <em>(modifiable)</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XdF6YV5vZcX6uf_d1qyggg.png" /></figure><p>Once the AWS account is created, the actual case study comes into play. It is referenced and dissected in the diagram below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4jNaJWW8E-XETfM7BWrC3g.png" /><figcaption><strong>High-Level Overview</strong></figcaption></figure><p><strong>Elaboration on High-level Diagram:</strong><br>The Root account creates an AWS Account — referenced as Data Team in the Organization&#39;s Hierarchy. On the AWS Account creation, it is associated with a string known as <em>&quot;Account ID&quot;</em> and the trusted entity role that is generally <em>&quot;OrganizationAccountAccessRole.&quot;</em></p><p>The Lambda uses the workflow&#39;s six parameters (discussed later) to start its execution. In the workflow, as shown, Lambda creates a temporary session that relies on the Security Token Service (STS) to assume a role in the newly created AWS Account (Data Team). This assumed role allows the creation of an IAM User with AdministratorFullAccess rights, a monthly cost budget with an SNS topic, and a CloudFormation Stack.</p><p><strong>Code and its parameters:</strong><br>The code snippet can be found <a href="https://drive.google.com/file/d/1grR0wse9NzLQivmcunPKlGk5rc0EFp_C/view?usp=sharing">here</a>, and it relies on the following parameters to execute its needful part. <br><strong>Account ID:</strong> the string of numbers that is associated with the Account <em>(DataTeam)</em><br><strong>Budget-Value:</strong> the monthly budget in $ for your AWS Account <br><strong>Email: </strong>the email that you used to create for your AWS Account<em> (could be ANY)</em><br><strong>RoleName: </strong>the role name that you associated with your AWS Account during the creation <br><strong>Senders Email: </strong>the email of the individual that you want to notify if the AWS Account exceeds the budget limitation<strong><br>ReservedOUs-ID: </strong>the string of characters that can be found beneath the OUs name</p><blockquote>Make sure that you have assigned the role with the required permissions to execute this task.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*D9QEQmxW51dCYuQhCNWNiA.png" /></figure><p>Earlier, I mentioned the resources that would be created with the assumed role, but their interlinkage needs some enlightenment. Therefore to shed some light on it: once an IAM User with the AdministratorRights is made, it will have a monthly budget restriction; the referenced sender email will be notified on the 50, 70, and 100% consumption of the budget. Once the budget reaches 100%, a budget action will be triggered, which will rely on a CF Stack to remove the AWS Account from an Administrator&#39;s OU and move it into the Reserved OU, restricting its access to ReadOnly.</p><blockquote>Make sure to blacklist specific actions on your Administrator OU: deleting/modifying the budget, the stack, and the lambda function with their particular resource ARNs. (ones related to the Stack)</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/685/1*juUHE70JP6ys0A_Kt7QInw.png" /><figcaption><strong>Account Migration to Reserved OU from Admin OU</strong></figcaption></figure><p><strong>Conclusion:</strong><br>This use-case can be very helpful when you have to manage your AWS Account with custom SCPs, and you can also integrate Jira API, which sends an API call to the API Gateway. This API Gateway can be integrated into the Lambda function as a trigger to assist with the queries. Alternatives to AWS Organization exist, like AWS Control Tower, but it is all about your requirements.</p><p>Feel free to drop a message for any questions at: <em>syedmuhammadwajeeh@gmail.com</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fbc6fbdb490b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Everything about SCP Vs. Permission Boundary Vs. Inline Policy]]></title>
            <link>https://medium.com/@syedmuhammadwajeeh/everything-about-scp-vs-permission-boundary-vs-inline-policy-5fb8159565d0?source=rss-8551dab35add------2</link>
            <guid isPermaLink="false">https://medium.com/p/5fb8159565d0</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[aws-inline-policy]]></category>
            <category><![CDATA[aws-permission-boundary]]></category>
            <category><![CDATA[aws-iam-best-practices]]></category>
            <category><![CDATA[aws-scp]]></category>
            <dc:creator><![CDATA[Syed Muhammad Wajeeh]]></dc:creator>
            <pubDate>Sun, 17 Jul 2022 00:32:52 GMT</pubDate>
            <atom:updated>2022-07-18T10:28:14.476Z</atom:updated>
            <content:encoded><![CDATA[<p>While AWS encourages the best Identity and Access Management practices on their part, it is vital to understand how these concerns and best practices can shield from the mishaps that are caused to the deployed infrastructure in the AWS Cloud. Therefore, this article covers an insightful overview of the three types of policies and their role in your AWS infrastructure.</p><p>For a high-level overview, let&#39;s dissect the three in layman&#39;s terms:<br><strong>1. SCP:</strong> SCP stands for Service Control policies applicable on the Organization Unit/Account Level. <br><strong>2. Permission Boundary:</strong> they are applicable on the User Groups and IAM Users Level.<br><strong>3. Inline Policy: </strong>they are applicable on the User Groups and IAM Users Level — Inline policies are directly attachable to the IAM Users.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/872/1*MOXknEuGLoGIP6dQqObY_g.png" /></figure><p>The diagram shows that SCP is a super-set containing the PM and IP, whereas IP is a subset of PM.</p><p>Now that the high-level difference is clear, let&#39;s discuss an example that covers the case with the application of three of them.</p><p><strong>Use-Case:</strong> A BI developer and QA Engineer works for the Data Department and requires separate IAM users with their required policies to do the needful.</p><p>From the problem statement, the SCP will play a role in assigning a super-set to the Data Department. The permission boundary will play a role in further narrowing down the permissions, and lastly, the inline policy will make the permissions explicit for the use case.</p><p><strong>So, what exactly is an SCP, and how can you apply an SCP?<br></strong>SCP, as already discussed, is a Service Control Policy applied on the Organization Unit and Account level. SCPs are used when you must maintain your Organization&#39;s hierarchy by dissecting it into different departments. It is achieved within the AWS Service named AWS Organization.</p><p>By enabling SCPs in AWS Organization and applying them to individual Organization Units or AWS Accounts directly, the SCPs explicitly restrict the access or implicitly allow it based on the JSON permissions mentioned in the custom SCP.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ju2G5ciaPXr94PVuiPjruA.png" /><figcaption><strong>Implicit Allow on Data-Specific AWS Services</strong></figcaption></figure><p>For instance, this SCP explicitly blocks two actions: <em>&quot;Anyone to leave the Organization or to terminate an EC2 instance.&quot; </em>The other one allows:<em> &quot;specific actions on EC2, S3, RDS.&quot;</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/320/1*J5fTJrLqF9gyM4AkjNpKIQ.png" /><figcaption><strong>Explicit Deny</strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/323/1*be-5yvVO3QTQg4mc9XM4KQ.png" /><figcaption><strong>Explicit Allow</strong></figcaption></figure><blockquote>Explicit deny is blacklisting, and Explicit allow is whitelisting. Unless explicitly denied, an AWS service stays implicity allowed.</blockquote><p><strong>What is a Permission Boundary and its link with Inline Policy?</strong><br>In the case of Permission Boundary, it&#39;s the boundary that&#39;s an explicit definition of the pool of AWS Services that an IAM User can access.<br>To define a permission boundary, head over to any of your IAM Users, navigate to the section shown below, and attach the needful AWS services.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dqw--8twOy45IbUgXAp54A.png" /><figcaption><strong><em>EC2 Read-Only Permission Boundary</em></strong></figcaption></figure><p>With a Read-Only Permission Boundary, even if the user is attached an EC2-Full Access, it would not be able to access the EC2 and create any instance or perform any EC2 actions.</p><p>And lastly, the inline policies are used when you want to attach policies specific to an IAM User. These are custom policies that can be specific to the requirements.</p><p><strong>Conclusion:<br></strong>Since you wouldn&#39;t want to risk any mishap to the production servers with an accidental termination, it&#39;s recommended to structure your Organization&#39;s hierarchy so that transparency can be ensured and access can be limited.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5fb8159565d0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to create AWS on-demand backup for restore]]></title>
            <link>https://medium.com/@syedmuhammadwajeeh/how-to-create-aws-on-demand-backup-for-restore-bf438ec81341?source=rss-8551dab35add------2</link>
            <guid isPermaLink="false">https://medium.com/p/bf438ec81341</guid>
            <category><![CDATA[backup]]></category>
            <category><![CDATA[vault]]></category>
            <category><![CDATA[restore]]></category>
            <category><![CDATA[iam-roles]]></category>
            <category><![CDATA[aws-s3]]></category>
            <dc:creator><![CDATA[Syed Muhammad Wajeeh]]></dc:creator>
            <pubDate>Thu, 14 Jul 2022 12:46:03 GMT</pubDate>
            <atom:updated>2022-07-15T17:36:11.097Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*kEmQkixc2C6xrFpgNHgfrA.png" /></figure><p>Have you ever wondered if the files stored in the S3 bucket can recover if accidentally manipulated, moved, or deleted? This article covers how to recover the dataset to a certain point.</p><p>AWS offers AWS Backup, which allows you to create backup vaults on a schedule or on-demand of the data so that you can restore their original state.</p><p>AWS Backup is like a traditional restore point in Windows.</p><p>Let’s dive into doing the needful.</p><p><strong>Step 1:</strong> Search for <em>“AWSBackupDefaultServiceRole”</em> and attach the following policies.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fIgMYd7OJSXn5KC5lCxeLg.png" /></figure><p><strong>Step 2:</strong> Create an on-demand backup by heading over to the AWS Backup <br>dashboard.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lU1V2zmrmbttT1zD8-QO6A.png" /></figure><p>For this use case, we will create an on-demand backup of S3.</p><blockquote>It is recommended to create a backup vault to segregate your backups with the future backup points.</blockquote><p><strong>Resource type:</strong> S3<br><strong>Bucket name:</strong> &lt;your-bucket-name&gt;<br><strong>Backup vault:</strong> &lt;your-backup-vault&gt;<br><strong>Role: </strong>&lt;default-role&gt;</p><blockquote>It is essential to have the bucket ACL enabled in-order for the backup to work</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1004/1*0KbIlHGnoJ6ooxUqXOJ5UQ.png" /></figure><p><strong>Step 3:</strong> In our case: 1 hour from now, the job will initiate. The status will be completed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Pi5aG1w2N0HQc901Q-UliQ.png" /></figure><p><strong>Step 4: </strong>Head over to the bucket and delete any <em>file</em> from the bucket that you want to recover back in time.</p><blockquote>Make sure to copy its S3 URI before deleting so that you can recover a particular file</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_PEKiQ1FgmFITRu-IW9GTg.png" /></figure><p><strong>Step 5:</strong> Navigate to the AWS Backup and head over to the respective backup vault you created. A restore point will be made.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WhnvHI12VBR1EFQ5_g_Ojg.png" /></figure><p>Click on the backup vault. Select the backups available and from the drop-down, click restore.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*29j4r-1q5JlJFKPJG8yUcw.png" /></figure><p>Paste the copied S3 URI for an item level restore. You can provide multiple URIs for recovery and choose a preferred destination.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1003/1*UzhEt-MO89r9j07HXhfn6Q.png" /></figure><p><strong>Step 6: </strong>A restore job will be created and shall recover the file to its prescribed path in the S3 bucket.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zGIfnr2cpTLd9nJNZY1Guw.png" /></figure><p><strong>Conclusion:</strong><br>Backup and Restore can be very beneficial when you have to manipulate data or, in the case of accidental deletes, you can’t risk losing the data. AWS Backup creates frequent restore points for deleted files and allows effective recovery in no time.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bf438ec81341" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to pull data from an SFTP directory — Python and AWS Lambda]]></title>
            <link>https://medium.com/@syedmuhammadwajeeh/how-to-pull-data-from-an-sftp-directory-python-and-aws-lambda-83a6e77a9fcd?source=rss-8551dab35add------2</link>
            <guid isPermaLink="false">https://medium.com/p/83a6e77a9fcd</guid>
            <category><![CDATA[paramiko]]></category>
            <category><![CDATA[aws-lambda]]></category>
            <category><![CDATA[aws-s3]]></category>
            <category><![CDATA[aws-s3-with-python]]></category>
            <category><![CDATA[sftp]]></category>
            <dc:creator><![CDATA[Syed Muhammad Wajeeh]]></dc:creator>
            <pubDate>Thu, 14 Jul 2022 11:56:14 GMT</pubDate>
            <atom:updated>2022-07-15T17:28:05.175Z</atom:updated>
            <content:encoded><![CDATA[<h3>How to pull data from an SFTP directory — Python and AWS Lambda</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/678/1*7jjLBSiM3EDOgD3XCWt1nA.png" /></figure><p>You must have encountered the use-cases of pushing data into the SFTP directory but never about pulling data from it. Therefore, this article entails all the details to help you achieve it.</p><p>Before we begin, there are particular prerequisites:<br><strong>1.</strong> SFTP server with an accessible directory<br><strong>2.</strong> Access to AWS Lambda <br><strong>3.</strong> Paramiko library for Python</p><p>To accomplish this, the dissection of steps are as follows:<br><strong>Step 1: Create a Layer in Lambda for Paramiko library <br></strong>Paramiko library is compatible with Python programming language, which allows establishing secure-shell connections. In particular, a connection with the SFTP Client.</p><p>You can download the paramiko library from the following drive link <a href="https://drive.google.com/file/d/1vYJwE8H_ckw7Mry0s8myJJNqCj7P4D0Z/view?usp=sharing">here</a>.</p><blockquote><em>“This zipped file has a pre-configured directory structure to avoid any inconvenience with compatibility and import module errors.”</em></blockquote><p>Once you’ve downloaded the .zip file, head over to the Lambda Layers and create a new layer with the following details and create it:<br><strong>Name:</strong> paramiko<br><strong>Architecture: </strong>x86_64<br><strong>Compatible runtimes: </strong>Python 3.6, 3.7, 3.8, 3.9</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/999/1*bt5NkDIRYnSNv_pqQ1201A.png" /></figure><p><strong>Step 2: Create an IAM Role with S3 write-permissions <br></strong>To do the needful, create a custom policy with write-permissions to S3 and attach it to an IAM role for AWS Lambda.</p><p><strong>2.1:</strong> Create a custom policy with the <em>“putobject”</em> action and the <em>“resource-ARN”</em> of your destination bucket.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1001/1*AMYGB2w-IDOeUpV_ugThyA.png" /></figure><p><strong>2.2:</strong> Create a new AWS Service Role and attach the previously created custom policy to the AWS Lambda service.</p><p><strong>Step 3:</strong> Create a Lambda Function with the following configurations: <br><strong>Runtime: </strong>Python 3.6<br><strong>Architecture: </strong>x86_64<br><strong>Execution Role:</strong> &lt;role-created-earlier&gt;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wgdxpTa0FHanjZKsKjE_pg.png" /></figure><p><strong>Step 4: </strong>Use the provided code <a href="https://drive.google.com/file/d/17W9MmogTLw2AFj_alUBAHPsckT98yvv8/view?usp=sharing">snippet</a> and paste it into the code section. Populate the values with your relevant information like this:<br><strong>HostName:</strong> 100.0.0.0/32<br><strong>Username:</strong> MySFTPUser<br><strong>Password: </strong>MySFTPPassword<br><strong>RemoteDirectory:</strong> /mySFTPDirectory/<br><strong>S3Directory:</strong> /myS3Bucket/myS3Bucketfolder</p><p>General Configuration changes:<br><strong>Timeout: </strong>3 minutes 0 seconds</p><p>These are all the changes required to pull data from an SFTP directory. You can test it for the dev environment and leverage its practicality.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Vshemglbf2OvkZzve3JDoQ.png" /></figure><p><strong>Conclusion:<br></strong>With the assistance of paramiko and boto3 library, we can leverage the SFTP client-connectivity via SSH protocol and AWS Services API calls.</p><blockquote><em>You can test this environment with the help of creating an SFTP using the AWS Transfer Family service at the cost of </em><strong><em>0.3$ per hour</em></strong><em> and populate files on the S3 directory from your local machine and then migrate them to a different bucket via the Lambda function.</em></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=83a6e77a9fcd" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>