<?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 Amit Kumar Basu on Medium]]></title>
        <description><![CDATA[Stories by Amit Kumar Basu on Medium]]></description>
        <link>https://medium.com/@amit.kumarbasu?source=rss-a9b20ee2bc7c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*2gZ3ydzp4tbeGiTCfBGkig.jpeg</url>
            <title>Stories by Amit Kumar Basu on Medium</title>
            <link>https://medium.com/@amit.kumarbasu?source=rss-a9b20ee2bc7c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 08:55:13 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@amit.kumarbasu/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[SnowPro Core Re-Certification Guide]]></title>
            <link>https://medium.com/@amit.kumarbasu/snowpro-core-re-certification-guide-24ebef36e0d8?source=rss-a9b20ee2bc7c------2</link>
            <guid isPermaLink="false">https://medium.com/p/24ebef36e0d8</guid>
            <category><![CDATA[snowprocore]]></category>
            <category><![CDATA[recertification]]></category>
            <category><![CDATA[snowflake]]></category>
            <dc:creator><![CDATA[Amit Kumar Basu]]></dc:creator>
            <pubDate>Wed, 09 Mar 2022 21:29:31 GMT</pubDate>
            <atom:updated>2022-03-09T21:29:31.822Z</atom:updated>
            <content:encoded><![CDATA[<p>I recently had to do the SnowPro Core Re-Certification and wanted to share my experience with anyone planning to re-certify. I found the questions quite different from the SnowPro Core certification which I had taken 2 years back. The materials that I referred 2 years back had had little relevance to the exam. Anyone doing re-certification need to refer these new materials and areas before they do take the certification to clear them comfortably.</p><p>Firstly please refer to the SnowPro Core recertification guide in the below link —</p><p><a href="https://learn.snowflake.com/courses/course-v1:snowflake+CERT-RECERT-GUIDE+A/about">SnowPro Core Recertification Exam Guide</a></p><p>Recertification exam is only for 90 minutes and includes 60 questions. Currently it cost $88 USD and valid for another 2 years.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IfxrTUJjpxPZxja1nRdwpA.png" /></figure><p>From the guidelines there are several training options as shown in the below picture but I used the Self study section.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S-PpLWHXTAiYYX-YoUJC6g.png" /></figure><p>I did all the three items mentioned under Self study —</p><p>SnowPro Core study guide — read through it and did the hands on labs.</p><p>Level Up Series — reviewed the videos and did the final exam. You might get few questions/similar questions from that final exam in the level up series. So that is a must to do.</p><p>Snowflake in 20 mins — Did the hands on Snowsql client tutorial. If you are working on a regular basis using snowsql you can skip this section. There will be question on file size/number of files for ingestion, so knowing this will help with 2–3 questions.</p><p>In addition to the above I would definitely recommend going through the below areas as you will surely get questions from them —</p><ol><li>Please make sure to review the different snowflake editions and features. link below — <a href="https://docs.snowflake.com/en/user-guide/intro-editions.html">https://docs.snowflake.com/en/user-guide/intro-editions.html</a>. You will get several questions where you would need to select the edition which has a certain feature.</li><li>Please review the views in information schema and account usage. Understand the difference in general between Information schema vs account usage table (realtime updates vs not relatime). Which table to use when you want to check sql from x days before etc.</li><li>Please review the details around Partner connect and get a general idea of their expertise like ETL, reporting, data catalog etc. Please review the various downloads available via the console and their use.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yg3RQLaVLX2cyv1xJ8RF9g.png" /></figure><p>4. Please review billing from Snowflake. Other than the standard credits and space usage cost, what all other charges are there for various serverless components. Also review data sharing and zero copy cloning Use Cases. Please go into detail on the type of permissions that get carried over for cloning and review the objects that can be included for sharing.</p><p>Reviewing these components should set up up for success and all the best with your exam! Feel free to leave feedback in the comments section.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=24ebef36e0d8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Create Presto Views in Glue and query using Athena]]></title>
            <link>https://medium.com/@amit.kumarbasu/create-presto-views-in-glue-and-query-using-athena-b6d083b672da?source=rss-a9b20ee2bc7c------2</link>
            <guid isPermaLink="false">https://medium.com/p/b6d083b672da</guid>
            <category><![CDATA[aws-athena]]></category>
            <category><![CDATA[pyspark]]></category>
            <category><![CDATA[boto3-python]]></category>
            <category><![CDATA[aws-glue]]></category>
            <dc:creator><![CDATA[Amit Kumar Basu]]></dc:creator>
            <pubDate>Sat, 29 Jan 2022 18:02:29 GMT</pubDate>
            <atom:updated>2022-02-24T21:33:28.080Z</atom:updated>
            <content:encoded><![CDATA[<p>This blog will depict how to create Presto Views using Glue and then query them using Athena. The scenario which lead to this was that we are migrating existing hive database objects to S3, Glue and Athena combination. Now Hive tables can be seamlessly migrated to Glue and queried via Athena. However, in most circumstances you would have created Hive views and those can’t be migrated exactly the same way as the tables since Athena doesn’t support querying Hive Views. You have the following options —</p><ol><li>Create the views directly using the Athena console. While this is feasible it is quite a manual process if you have a whole bunch of views to be migrated. In most production environments this will not be allowed.</li><li>Create the views programmatically using glue so that the implementation is scalable and can be extended to large numbers of views to be migrated.</li></ol><p>In the next section we will look at building a Glue view for a sample table say EMP_TBL. We will create a view VW_EMP from this table and select EmpID, EmpName and EmpSalary from the table EMP_TBL. This view will then be visible and users will be able to query it via Athena.</p><p>All Code examples are from a Notebook running on EMR.</p><p>Establish connection with boto3 Glue Client — I am using us-east-1, you need to specify your region accordingly in the below code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tRjvELVTN_Mif0tR46Fy3w.jpeg" /></figure><p>Enable SparkSession and Glue</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jl-zZQQ3WfHsxPdDO-O62w.jpeg" /></figure><p>Prepare the query and create the view using below code.</p><p>Catalog is the name of your catalog created in Athena. Schema is the database in which you want to create the view. Rest all is self-explanatory.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bx-AVsM_RdcjsbTxHhLpmQ.jpeg" /></figure><p>Please ensure to use presto specific datatypes else you will get error.</p><p>Conclusion:</p><p>This blogs talks about creating presto views using glue and then querying them in Athena as Athena doesn’t support Hive views.</p><p>Please feel free to follow me for more stories like this.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b6d083b672da" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AWS Data Analytics — Specialty | Certification Preparation]]></title>
            <link>https://medium.com/@amit.kumarbasu/aws-data-analytics-specialty-certification-preparation-6c64df6f4349?source=rss-a9b20ee2bc7c------2</link>
            <guid isPermaLink="false">https://medium.com/p/6c64df6f4349</guid>
            <category><![CDATA[aws-certification]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Amit Kumar Basu]]></dc:creator>
            <pubDate>Tue, 18 Jan 2022 00:23:18 GMT</pubDate>
            <atom:updated>2022-09-22T18:17:42.898Z</atom:updated>
            <content:encoded><![CDATA[<h3>AWS Data Analytics — Specialty | Certification Preparation</h3><p>I have recently completed the Data Analytics Certification and wanted to share my experience and some tips on how to prepare for the certification. This is current as of Jan 2022. Depending on when you are reading this please make sure to check with the AWS Training and Certification for the updated exam blueprint for any changes. Here is the link to get started with the exam blueprint, sample questions and guide —</p><p><a href="https://aws.amazon.com/certification/certified-data-analytics-specialty/">AWS Certified Data Analytics — Specialty Certification (amazon.com)</a></p><p>In this blog I will focus on the learning materials that I referred and some focus areas for each of the sections covered in the exam to give you an idea of the areas to focus during your preparation. AWS has recently launched an improved learning website AWS Skill builder (<a href="https://explore.skillbuilder.aws/learn/signin">AWS Skill Builder</a>). You should definitely go to this website for all your certification preparation. I have used the same extensively and found it to be extremely helpful.</p><p>For the data analytics certification preparation you can directly use the link (<a href="https://explore.skillbuilder.aws/learn/public/learning_plan/view/97/data-analytics-learning-plan">AWS Skill Builder</a>)or Search for data analytics learning plan in the AWS Skill builder to get to the course. Depending on your level of expertise you can use the course accordingly which I have outlined below.</p><p>Level of expertise —</p><p>New to Data Analytics/Not a regular user of Data Analytics services — You would need to go through the entire course.</p><p>Intermediate/Proficient level (Regular to intermittent user of Data Analytics services)- You can directly jump to the below course — <br><strong>Exam Readiness: AWS Certified Data Analytics — Specialty-A2T</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yXGnb4_WyiQC-fhg7aKjlw.jpeg" /></figure><p><strong>Exam Readiness: AWS Certified Data Analytics — Specialty-A2T -</strong></p><p>The above course is just a summary of all the sections covered in the exam in excellent details. I went through this section first and marked out the areas where I need to touch up a bit and went through the corresponding detail sections in the course. For e.g. — I needed to touch up on Kinesis, so went through the below courses to do the same —</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mACy_beWS3osoYWemY1b-Q.jpeg" /></figure><p>You can do the same for the areas you need to brush up. This saved me a lot of time on my preparation and also let me focus on the areas I need to brush up. Moving on the the section wise specifics.</p><p>The exam covers the following sections and percentage split is as follows -</p><p>Domain 1: Collection — 18% <br>Domain 2: Storage and Data Management — 22% <br>Domain 3: Processing — 24% <br>Domain 4: Analysis and Visualization — 18% <br>Domain 5: Security — 18%.</p><p><em>Note:- This might change so check this before your start preparing.</em></p><p>Domain 1: Collection — Outside of your reading of the service and use cases in general the below summary table will be of great help to understand and identify the services for different combinations of scenario.</p><p>Comparison between Kinesis Data Streams, Firehouse, Analytics and MSK on the following —</p><ol><li>Size of message for write and read</li><li>transactions per second</li><li>encryption support</li><li>target delivery services</li><li>message retention</li><li>delivery commitment (at least once, once only etc.)</li><li>scaling mechanism</li><li>Most common errors and their fixes</li></ol><p>Sample Scenario — Application can write messages up to 2MB in size.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/120/1*hd9dlsL3-jfMuxkD8mdLjA.png" /></figure><p>This will rule out Kinesis as it can support max up to 1 MB for write. MSK will most probably be the answer as it supports up to 6 MB.</p><p>Also read about Kinesis Agent in general to have an idea of when it will apply and retry mechanism, aggregation and checkpointing for KCL &amp; KPL.</p><p>Domain 2: Storage and Data Management — Outside of your normal reading of the services and use cases.</p><p>Comparison between S3, RDS, Redshift, OpenSearch a.k.a AWS ElasticSearch, DynamoBD on the following —</p><ol><li>Storage Types</li><li>Data Life Cycle Management (S3 storage tiers and retrieval times , hot/warm/cold for DBMS)</li><li>SQL vs No-SQL vs Object Store</li><li>Encryption Support types</li><li>AWS Service Integrations for data delivery</li><li>Type of Data Asset supported (Datalake vs Data warehouse vs ODS vs OLTP)</li><li>Types of Sql Queries (Simple, Complex, Complex with ML Insights)</li><li>Data Access &amp; Security (Encryption, Row Vs Column level as applicable)</li></ol><p>Sample Scenario — Moving On-Prem Warehouse to Cloud</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/120/1*hd9dlsL3-jfMuxkD8mdLjA.png" /></figure><p>In most cases it will be Redshift (AWS Datawarehouse in Cloud)except if it talks about building a datalake, in that scenario think S3. Look more closely at the question, sometimes it will say least cost, sometimes cost doesn’t matter but speed and agility, sometimes less development or a combination of factors.</p><p>Domain 3: Processing — Outside of your normal reading of the services and use cases.</p><p>Comparison between Glue, EMR, Lambda, AWS Data Pipeline, Kinesis Data Streams, Kinesis Firehose, Kinesis Analytics, MSK</p><ol><li>Real-Time (RT) vs Near Real-Time (NRT) vs Batch</li><li>Serverless vs Server based</li><li>Encryption options in transit</li><li>Target AWS Service integrations</li><li>Scaling options</li></ol><p>You need to have a clear idea of the processing options based on the use case. What all goes with RT vs NRT vs batch? Focus should be given to EMR also and understand the various ways EMR is used like transient Clusters, Use of Spot instances, EMR Security configurations, various encryption options of EBS vs Root vs EMRFS and Intra-cluster communication encryption.</p><p>Sample Scenarios —</p><p>a) If you have to do processing in NRT and do transformation while processing the messages.</p><p>b) Processing of big data in intervals and several times a day.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/120/1*hd9dlsL3-jfMuxkD8mdLjA.png" /></figure><p>a) Think Kinesis firehose as it provide transformation options before writing the data.</p><p>b) Think transient EMR with spot instances for task nodes.</p><p>Domain 4: Analysis and Visualization — Outside of your normal reading of the services and use cases.</p><p>Here focus is mostly QuickSight. A little bit of Kibana but in most cases Kibana will come with RT/NRT processing and visualization so there won’t be much confusion.</p><p>Regarding QuickSight, You need to be thorough regarding the following —</p><ol><li>How to connect to Data Warehouse in a private VPC?</li><li>How to connect to S3 securely?</li><li>Different types of graphs supported and which graph is used for what type of scenarios.</li><li>The ML options provided by Quicksight.</li><li>Different User Access options provided by QuickSight.</li></ol><p>Sample Scenario — Use of anomaly detection scenarios</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/120/1*hd9dlsL3-jfMuxkD8mdLjA.png" /></figure><p>Think of QuickSight anomaly detection rather than Sagemaker based answers.</p><p>Domain 5: Security — Outside of your normal reading of the services and use cases.</p><p>Security questions will cover almost all the services focused on the following —</p><ol><li>Authentication and authorization</li><li>Data protection and encryption techniques</li><li>Data governance and compliance</li></ol><p>For IAM focus on difference between Resource and Identity based policies for access. Have a clear understanding of how VPC provides security. How to interact with AWS services securely (VPC endpoints)? How to access internet from servers in private VPC (NAT gateway)?</p><p>Have a clear understanding of EMR encryption options — Encryption of EMRFS (KMS), EBS (LUKS, Open source HDFS encryption), Root volume encryption. Also intra-cluster encryption option and communication with S3. Also at-rest and in-transit encryption for Kinesis, Redshift and DynamoDB. Have an understanding of encryption option outside of KMS like Cloud HSM (both AWS vs your own On-Prem HSM).</p><p>For Governance, please have thorough idea of Cloudtrail (All API calls), Cloudwatch (logging and alerting), Lakeformation (DataLake governance). Be conversant with other services like Macie to identify and remediate PII attributes.</p><p>Sample Scenarios — All PII data must be encrypted and stored. Also identify any PII data not categorized and identify and alert for any access anamolies.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/120/1*yheANTlqlJtX3jl_-9LVsw.png" /></figure><p>Think S3 with encryption to store data securely. Macie to identify any PII attributes, Cloudtrail to capture any API access requests. Cloudwatch to trigger alerts.</p><p>Hope this gives a good understanding of the preparation required to clear this certification for both new and experienced professionals who are looking to take on this challenge. All the best for your exam!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6c64df6f4349" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Launch an EMR managed scaling cluster with Step Functions]]></title>
            <link>https://medium.com/@amit.kumarbasu/launch-an-emr-managed-scaling-cluster-with-step-functions-bc544babc80f?source=rss-a9b20ee2bc7c------2</link>
            <guid isPermaLink="false">https://medium.com/p/bc544babc80f</guid>
            <category><![CDATA[aws-emr]]></category>
            <category><![CDATA[aws-step-functions]]></category>
            <category><![CDATA[aws-emr-managed-scaling]]></category>
            <dc:creator><![CDATA[Amit Kumar Basu]]></dc:creator>
            <pubDate>Wed, 11 Aug 2021 23:26:45 GMT</pubDate>
            <atom:updated>2021-08-14T01:22:48.298Z</atom:updated>
            <content:encoded><![CDATA[<p>This blog will show how to further improve and optimize your transient EMR cluster using the EMR managed scaling policy for Core and Task instances. There is already a blog showing how to launch a transient cluster using Step Function in aws blogs. We will refer this link and then make the changes needed to the same step function to make use of EMR managed scaling. The blog we will refer is here — <a href="https://aws.amazon.com/blogs/aws/new-using-step-functions-to-orchestrate-amazon-emr-workloads/">https://aws.amazon.com/blogs/aws/new-using-step-functions-to-orchestrate-amazon-emr-workloads/</a></p><p>EMR Managed scaling — Previously if you need to scale your EMR cluster programmatically you would have to define a custom scaling policy using CloudWatch metric to perform the same. AWS has now EMR managed policy wherein EMR takes care of scaling out and in based on the metrics automatically without you needing to specify a scaling policy. We will refer the above blog and get to the Create Cluster section and add the below code after LogUri (shown using the red arrow) to use EMR managed scaling —</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/941/1*m-UkDRQSZyulPRB4h6LjZw.jpeg" /></figure><p>We will add the below code —</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/670/1*IzGaiuFNsOvHGhFKXoBWJg.jpeg" /></figure><p>This is what the the individual metrics mean -</p><p><strong>MaximumCapacityUnits</strong> : This is the upper limit of allowed EC2 capacity in the cluster. It is measured through virtual central processing unit (vCPU) cores or instances for instance groups. It is measured through units for instance fleets.</p><p><strong>MaximumCoreCapacityUnits </strong>: This is the upper limit of the Core units in your cluster. Rest all with be assigned to Task nodes. For e.g. — if you have specified MaximumCapapcityUnits as 10 and MaximumCoreCapacityUnits as 2 then during scaling the remaining 8 scaleout will happen to task nodes.</p><p><strong>MaximumOnDemandCapacityUnits</strong> : This is the maximum number of OnDemand Instances that will be spinup during the scaling. If thsi parametr is not specified it defaults to MaximumCaapacityUnits. So if you plan to used Spot instances, please make sure you have a value for this. For, e.g. — supposed you specify MaximumCapacityUnits as 10 and specify MaximumOnDemandCapacityUnits as 2 then the rest 8 are allocated as spot instances.</p><p><strong>MinimumCapacityUnits </strong>: This is the lower limit of allowed EC2 capacity in the cluster. It is measured through virtual central processing unit (vCPU) cores or instances for instance groups. It is measured through units for instance fleets.</p><p>All the values in the above example is parameterized which can be passed from step functions, CloudWatch or lambda. You can even hard code the values but it is not advised as any change will lead to a code change.</p><p>Conclusion :</p><p>This blogs talks about EMR managed scaling which automatically resizes your cluster based on the workload and gives you the option to use different EC2 instances pricing options easily to optimize your workloads.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bc544babc80f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AWS Cost Management Strategy]]></title>
            <link>https://medium.com/@amit.kumarbasu/aws-cost-management-strategy-955e6b9072f6?source=rss-a9b20ee2bc7c------2</link>
            <guid isPermaLink="false">https://medium.com/p/955e6b9072f6</guid>
            <category><![CDATA[aws-cost-reduction]]></category>
            <category><![CDATA[aws-cost-optimization]]></category>
            <category><![CDATA[aws-cost-management]]></category>
            <dc:creator><![CDATA[Amit Kumar Basu]]></dc:creator>
            <pubDate>Wed, 11 Aug 2021 21:48:51 GMT</pubDate>
            <atom:updated>2021-08-31T21:09:12.088Z</atom:updated>
            <content:encoded><![CDATA[<p>One of the most important thing in the cloud is the benefit of cost you get as you pay for what you use. However, if you don&#39;t have a proper cost management strategy and best practices as you build in cloud it will become expensive quite quickly. Any organization will need to have proper cost management solutions to budget and manage their cost like AWS Budgets, AWS Cost Explorer or third party softwares like Apptio, Cloudability etc. to name a few. In this blog we will talk about the best practices that you need to follow outside of just the Cost management part. The six best practices that needs to be put in place and practiced consistently to make sure your cloud resources are optimized are as follows —</p><ol><li>Right-Sizing</li><li>Appropriate Provisioning</li><li>Purchase-Options</li><li>Geographic Selection</li><li>Optimized Data Transfer</li><li>Managed Services</li></ol><p>We will discuss about each in detail in the next sections.</p><p><strong>1. Right-Sizing —</strong></p><ul><li>Use the lowest cost resource that meet technical requirements. Like use r5a instances vs r5 as it provides the same compute power but at a cheaper price wherever possible.</li><li>Architect for most consistent use of resources rather than spikes and valleys.</li><li>Loosely coupled architecture using SQS, SNS. Lambda and DynamoDB can smooth demand and create more predictability and consistency.</li></ul><p><strong>2. Appropriate Provisioning —</strong></p><ul><li>Provisioning the resources you need and nothing more. Shutdown instances if you don’t need them. Build transient processes and spin-up or down as required.</li><li>Consolidate where possible for greater density and lower complexity. If you are spinning up separate instances to process different files, see of these can be combined together into a single process.</li><li>Use CloudWatch and alarms to monitor usage. Increase or reduce resources based on alarms.</li></ul><p><strong>3. Purchase Options —</strong></p><ul><li>Long running application which are permanent in nature and expected to run for more than 1 yr or longer — Use Reserved Instances</li><li>For Temporary scaling like in EMR — Use Spot Instances</li><li>Always EC2 fleet with combination of Reserved, On-Demand and Spot Instances.</li></ul><p><strong>4. Geographic Selection —</strong></p><ul><li>AWS Pricing vary by region so region selection should include cost comparison among other priorities.</li><li>Consider locating resource remotely if local access is not required to reduce cost.</li></ul><p><strong>5. Optimized Data Transfer —</strong></p><ul><li>Data egress between AWS regions and On-Prem can become significant cost component. Try to have related applications that share data grouped together and avoid cross-region data transfer cost.</li><li>Direct connect most cost-effective given data volume and speed. Have a second VPN connection as backup.</li></ul><p><strong>6. Managed Services/Serverless —</strong></p><ul><li>Use Managed Services or Serverless services to offload administrative work.</li><li>RDS, Redshift, Faregate and EMR are examples of fully managed services that lower complexity and cost.</li><li>Lambda, Glue, Athena, Step Functions are some of the Serverless options to look at.</li></ul><p><strong>Conclusion —</strong></p><p>As mentioned above these six best practices are an excellent way to manage and optimized your cloud infrastructure and services thereby managing your AWS cost. The Cost and Budget tools are essential but these best practices goes a long way in ensuring your infrastructure and services are setup the most optimized way.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=955e6b9072f6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[S3 Logging and Monitoring]]></title>
            <link>https://medium.com/@amit.kumarbasu/s3-logging-and-monitoring-e35d9afad4de?source=rss-a9b20ee2bc7c------2</link>
            <guid isPermaLink="false">https://medium.com/p/e35d9afad4de</guid>
            <category><![CDATA[aws-cloudtrail]]></category>
            <category><![CDATA[aws-s3]]></category>
            <category><![CDATA[aws-s3-security]]></category>
            <dc:creator><![CDATA[Amit Kumar Basu]]></dc:creator>
            <pubDate>Tue, 10 Aug 2021 00:08:07 GMT</pubDate>
            <atom:updated>2021-08-10T00:08:07.870Z</atom:updated>
            <content:encoded><![CDATA[<p>As more and more organizations bring data into S3 to stage, process, consume or archive it is of paramount importance to set the correct level of access and monitoring to make sure that the data is secure. In this blog post, we will cover some of the important features and ways to secure the data in the S3 buckets.</p><p><strong>Bucket Properties :</strong> This section will cover the most commonly used properties of the S3 -</p><p><strong>&lt;bucket-name&gt;</strong> (this is a global namespace but regionally stored)</p><p><strong>Versioning:</strong> <strong>ON/OFF</strong> (as required/ some features turns on version by default like replication)</p><p><strong>Server Access logging:</strong> <strong>ON/OFF</strong> (mostly used for security and access audits, to understand usage and optimize cost by choosing the right storage)</p><p><strong>Encryption: KMS</strong> (group buckets into different KMS groups for isolation e.g. — bucket where third party is writing should have a different KMS key than the bucket where application is accessing)</p><p><strong>Tags:</strong> Apply tags for cost management.</p><p><strong>Object Lock:</strong> For compliance requirements like to hold objects from being archived or deleted due to compliance and other legal needs.</p><p>Additionally, data should be encrypted with 3rd party asymmetric key like gpg before transfer to S3 incase KMS is not supported by the source application sending files. The key is generated On-Prem and stored in AWS secrets manager after base64 encoding and encrypted using KMS CMK. To understand how to use 3rd party key for encryption/decryption refer to my earlier blog — <a href="https://medium.com/@amit.kumarbasu/process-data-encrypted-with-3rd-party-asymmetric-key-in-ec2-or-emr-using-aws-secrets-manager-1939e5e0c1e7">https://medium.com/@amit.kumarbasu/process-data-encrypted-with-3rd-party-asymmetric-key-in-ec2-or-emr-using-aws-secrets-manager-1939e5e0c1e7</a></p><p><strong>Bucket Permission :</strong> This section will cover the most commonly used permissions:</p><p>&lt;bucket-name&gt; (this is a global namespace)</p><p>Block Public Access: <strong>ON</strong></p><p>Bucket Policy : Apply at bucket level</p><p>• ForceSSL</p><p>• DenyUnEncryptedObjectUploads</p><p>This will ensure any unsecured calls and any attempt to upload un-encrypted object into the bucket are denied.</p><p>A Sample bucket policy is below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/385/1*cAydGxVTMmrUPwhUCmmimA.png" /></figure><p><strong>Bucket Metrics:</strong> This section will cover the most common metrics you can monitor —</p><p>There are 2 types of metrics you can monitor with CloudWatch :</p><p>Daily storage metrics (on by default, One report per day and free)</p><ul><li>Number of objects per bucket</li><li>The size of your bucket in bytes</li></ul><p>Requests and data transfer metrics (not on by default)</p><ul><li>Available at 1 min intervals</li><li>Costs extra</li></ul><p>Reports on –</p><ul><li>All GET/HEAD/PUT/DELETE/LIST/POST requests</li><li>4xx/5xx errors</li><li>Bytes downloaded/uploaded</li><li>Latency (first byte &amp; total requests)</li></ul><p>Put in Cloudwatch alarms to alert incase of any event based on the S3 metrics as applicable.</p><p><strong>Server Access Logging:</strong> This section will talk about Server access logging and show details around the information it logs and it usefulness.</p><p>Why enable access logging?</p><ul><li>For security and audit reasons</li><li>Understand your AWS bill vs usage</li><li>User base of the data in the bucket and the type of requests.</li></ul><p>What does it do?</p><ul><li>Tracks request for access to a bucket</li><li>Records information that is useful for tracking</li><li>Request time/requestor IP/ key name/operation/Response codes etc.</li><li>Disabled by default</li><li>Charged for Log storage</li><li>Logs are periodically delivered</li><li>S3 collects logs, consolidates them and uploads them</li><li>Not real time</li></ul><p>Logs are not automatically analyzed — you need to use own analytics engine like</p><ul><li>Hadoop/ELK/Athena/Other 3rd party tools like Splunk</li></ul><p>Sample Server access log showing authorized vs unauthorized access —</p><p>Valid request from root account allowed —</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*ZZcOUSZmAPTXPwXjdGh0WA.png" /></figure><p>Anonymous request denied —</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*SCTxGSMJy5SLiDv5MG7MtA.png" /></figure><p>Order of the fields in the log — Canonical ID, Bucket Name, Date and time of request, IP address the request came from, who requested, unique request ID, operation being performed, Object Key name, Request Uri, http response, error code, bytes sent, object size, time taken in ms, processing time in ms, referrer, User agent, version ID.</p><p>Enable CloudTrail Logs :</p><p>CloudTrail provides visibility into user activity by recording API calls made on your account. CloudTrail records important information about each API calls including Name of the API, Identity of the caller, the time of API call, the request parameters, and the response elements Returned by AWS service.</p><p>It captures calls to all BUCKETS in your account but doesn’t track object level requests by default. Object level request can be configured by using an event selector. Configure under S3 properties</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ND-JYimgbqF026ippVl9WQ.png" /></figure><p>If you go to Cloud watch and go to log groups of CloudTrail and filter you can see the details of each and every request made once KMS is enabled: see below sample —</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3MFispai6ThSmABRrIBrtg.png" /></figure><p>Some high level architectures of using S3 logging and monitoring</p><p>with Cloudwatch —</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kwlnf2hpG7ePM4V2NOOeOA.png" /></figure><p>With Splunk —</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Qqdp6p1YFgXflKzABwJj7A.png" /></figure><p><strong>Conclusion</strong></p><p>The post covered how to use the most common features of S3 to secure the data in the bucket and enable logging and monitoring. It also highlighted the kind of information that is available to set alerts and secure your environment.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e35d9afad4de" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Process data encrypted with 3rd party asymmetric key in EC2 or EMR using AWS Secrets Manager]]></title>
            <link>https://medium.com/@amit.kumarbasu/process-data-encrypted-with-3rd-party-asymmetric-key-in-ec2-or-emr-using-aws-secrets-manager-1939e5e0c1e7?source=rss-a9b20ee2bc7c------2</link>
            <guid isPermaLink="false">https://medium.com/p/1939e5e0c1e7</guid>
            <category><![CDATA[aws-ec2]]></category>
            <category><![CDATA[gnupg]]></category>
            <category><![CDATA[aws-secrets-manager]]></category>
            <category><![CDATA[asymmetric-encryption]]></category>
            <category><![CDATA[aws-emr]]></category>
            <dc:creator><![CDATA[Amit Kumar Basu]]></dc:creator>
            <pubDate>Thu, 05 Aug 2021 01:09:11 GMT</pubDate>
            <atom:updated>2022-10-20T18:44:01.421Z</atom:updated>
            <content:encoded><![CDATA[<p>It is a best practice to ensure that your data is always encrypted whether it is at rest or in motion and that is more relevant when you are moving your data to cloud. You will come across scenarios where the source data systems can support 3rd party encryption keys like gnupg (a.k.a gpg or pgp) but are not yet able to encrypt using KMS. Now to make the encryption secure the 3rd party system will use asymmetric keys which is currently not supported in KMS. This post will talk about how to decrypt data encrypted with asymmetric gpg keys using aws secrets manager.</p><p><strong>Prepare the environment — Install Gnupg and create the public and private keys –</strong></p><p>We would start by launching an EC2 instance. You can either use any of your already running EC2 instances running on Amazon Linux 1 or Linux 2 for executing the demo. We are going to use python-gnupg 0.4.6 for supporting the encryption/decryption process. So launch anEC2 instance or use an existing instance and SSH into the machine.</p><p>Once in the EC2, run the following set of commands –</p><p>1. Update all packages to latest version : sudo yum update -y</p><p>2. Install pip : sudo yum install python-pip -y</p><p>3. Install GnuPG : pip install --user python-gnupg</p><p>4. Install jq : sudo yum install jq -y</p><p>Once installed we will first create a key to be used for encryption and decryption process. Run the following command –</p><p>1. gpg --gen-key</p><p>Select 1 and press enter:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/330/1*rZRYdqcZRuDUAaUQDx4k5w.png" /></figure><p>Keep default and press enter:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/409/1*3NFXfaITKl3Uee_u3guP7w.png" /></figure><p>Keep default and press enter:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/390/1*bW_SvRrQqevqT9-oXp_SwQ.png" /></figure><p>Reconfirm and press enter:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/266/1*1F6u1q_IoYrI-hLK8qmP_A.png" /></figure><p>Fill details as per your need or can use values like in the below snapshot:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/508/1*eDYYkhM910nzumJYFR_BDQ.png" /></figure><p>Enter your passphrase (atleast 8 characters) and your key is now created:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/513/1*0YoOlWC67zpsQUUYymw6FA.png" /></figure><p>Running the following command will list your keys –</p><ol><li>List public key : gpg — —list-keys</li><li>List private key : gpg — —list-secret-keys</li></ol><p>Once the key is created we will now export the keys so that we can encrypt the data and then use private key to decrypt the data –</p><p><strong>Export the Public and Private Key –</strong></p><p>Export the public key into a file named public.key:</p><p>1. gpg — — export -a “TestKey” &gt; public.key</p><p>Note: Share the public key with 3rd party or vendor who needs to encrypt the data before transferring.</p><p>Export the private key into a file named private.key:</p><p>2. gpg — —export-secret-key -a “TestKey” &gt; private.key</p><p>Note: The private key shouldn’t be shared with anyone.</p><p>Since the key generated is asymmetric it can’t be housed in KMS. So we will store this private key in AWS secrets manager before using it for decryption. Now AWS secrets manager stores any key as a string which causes the key to loose its shape. So, if you just directly import the key into AWS secrets manager you won’t be able to use the key later once you export it for decrypting. Also we would need both keys public and the private to import the key into the gnupg and then use for decrypting. So, we need to merge the public.key and private.key into a single file. Let’s call it fullgpg.key. To ensure that the keys stays usable we need to encode the key into base64.</p><p>To encode the key using base64 run the following command:</p><p>3. base64 fullgpg.key &gt; encoded_gpg.key</p><p>The encoded and the plain text key will look like below –</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/565/1*gNUfuQKDfpfpX54r6Skpug.png" /></figure><p><strong>Importing the encoded gpg key into AWS secrets manager –</strong></p><p>Copy the content of the encoded_fullgpg.key and let’s go to AWS secrets manager to create the key:</p><p>1. Sign in to the AWS Secrets Manager console at <a href="https://console.aws.amazon.com/secretsmanager/">https://console.aws.amazon.com/secretsmanager/</a>.</p><p>2. On either the service introduction page or the <strong>Secrets</strong> list page, choose <strong>Store a new secret</strong>.</p><p>3. On the <strong>Store a new secret</strong> page, choose <strong>Other type of secret</strong>.</p><p>4. Under<strong> Specify the key/value pairs to be stored in this secret </strong>mention the details as in the below snapshot:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/365/1*YqYw-zdzlhGc_QIiOKKs6Q.png" /></figure><p>5. Give the Key a name and keep the tags blank for now. Click Next.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*XMBstfZ604mjDokAlye-5g.png" /></figure><p>1. In this tutorial, skip configuring rotation, so choose Disable automatic rotation, and then choose Next.</p><p>2. Choose Store.</p><p>Creating Key using AWS CLI — For creating the key using CLI you need to first key a json file in a key value pair to store the key in the secrets manager. Run the following commands to create the json file –</p><p>1. echo -en ‘{\n “testkey”: “‘ &gt; secretmgr.json</p><p>2. awk ‘$1=$1’ ORS=’ ‘ encoded_fullgpg.key &gt;&gt; secretmgr.json</p><p>3. echo -en ‘“\n}’ &gt;&gt; secretmgr.json</p><p>4. sed -i ‘s/ “/”/g’ secretmgr.json</p><p>The json file will look like below –</p><p>Beginning of the file -</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/390/1*VxnJSU9Fi3fJaNSUJ6jEjQ.png" /></figure><p>End of the file –</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/396/1*u0HZhMU2X8aOSbNHRHjYrg.png" /></figure><p>Once the json file secretmgr.json is created you can then create the key by using the below command –</p><p>aws secretsmanager create-secret — —name testkey \</p><p>— —description “this is a test key” \</p><p>— —secret-string file://secretmgr.json</p><p><strong>Encrypt the data using public key –</strong></p><p>Let’s create a file in our home directory and save it as txt file or you can use a file which you already have. We are going to encrypt the file now. Created a file by the name hello.txt. To encrypt it run the following command –</p><p>gpg — always-trust -e -r “TestKey” -o hello.pgp hello.txt</p><p>If you list the files you will see the below –</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/478/1*k_CWJsKrn7ywhlTRRm498g.png" /></figure><p>Remove the hello.txt file so that once you decrypt you will get the hello.txt file and can verify the content of the file.</p><p>If you look at the content of the hello.pgp file you will see that it is encrypted -</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*3_qpXnChevbq7I3pvm8svA.png" /></figure><p><strong>Remove the Keys from the gpg store –</strong></p><p>Now that we have the file encrypted and the full key stored in the secrets manager we will delete the public and private keys from the gpg database on the EC2 instance.</p><p>To remove the secret key use below command:</p><p>1. gpg –delete-secret-key “TestKey”</p><p>To remove the public key use below command:</p><p>2. gpg –delete-key “TestKey”</p><p><strong>Decrypt the encrypted file –</strong></p><p>To successfully access the secrets manager from the ec2 instance make sure the role that is attached to the ec2 instance has the following policy attached to it:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*zVlF5g5vD_bYlwAA3fHIxA.png" /></figure><p><strong>Extract secret from AWS secrets manager:</strong></p><p>Using AWS CLI we will extract the secret from the Secrets Manager and strip all non-related items and store only the encoded value in a file — run the below command:</p><p>1. aws secretsmanager get-secret-value — — secret-id Gpgtestkey \</p><p>— —query ‘SecretString’ — —output text | jq ‘.testkey’ | cut -b \</p><p>2- | tr -d ‘“‘ |sed ‘s/ /\n/g’ &gt; fullgpg_encoded.asc</p><p>The above command gets the secret from the Secrets Manager strips out the SecretString and then takes out the secret value only using the jq and the &lt;key_value&gt;. It then stores it in a file fullgpg_encoded.asc.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/556/1*_vDAvOQHBKVpklinWKs6uw.png" /></figure><p>However the value is still base64 encoded, so can’t be imported into gnupg yet.</p><p><strong>Decode the key using base64</strong></p><p>Run below command you can decode the private key:</p><p>1. base64 — —d fullgpg_encoded.asc &gt; fullgpg_decoded.asc</p><p><strong>Import decoded key into gpg</strong></p><p>Using below command you can import the key into gpg.</p><p>2. gpg — —import fullgpg_decoded.asc</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*TM32VclIZfsYdCxdD-K4JQ.png" /></figure><p>Now the private key is successfully imported into gnupg and you are good to go ahead and decrypt the files encrypted by the public key at the beginning. You can put all of these steps into either a shell or python script (python calls are slightly different) and automate it so there is no manual intervention required.</p><p><strong>Decrypt the File</strong></p><p>Run the below command to get the decrypted file back:</p><p>gpg — —batch — —passphrase &lt;passphrase created during key creation&gt; hello.pgp</p><p><strong>Cleaning Up</strong></p><p>When you are done with the above, please terminate the EC2 instance and ensure that the attached EBS volume is also removed. Delete the secret from the secrets manager, since secret manager doesn’t allow to delete secret immediately put the scheduled deletion at 7 days which is the minimum.</p><p><strong>Conclusion</strong></p><p>The post covered how to use 3rd party Gnupg asymmetric key to encrypt and decrypt files in EC2 or EMR using AWS secrets manager. You can combine the above steps into a shell or python script to automate the decryption of the files using the encoded secret in aws secrets manager. You can use this approach with transient clusters as you launch your overnight batches and micro batches without having to worry about the decryption process for gpg encrypted files. This way your data stays secure and provides a reliable way to decrypt them before processing. As you terminate the cluster or your EC2 instances the keys are destroyed form the instance but is securely available in the secrets manager to be used as needed.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1939e5e0c1e7" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>