<?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 Agnel Nandapurapu on Medium]]></title>
        <description><![CDATA[Stories by Agnel Nandapurapu on Medium]]></description>
        <link>https://medium.com/@agnel?source=rss-eaa1bd04c74d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*mGUI8OSWX3Jnd_72ztT5Tw.jpeg</url>
            <title>Stories by Agnel Nandapurapu on Medium</title>
            <link>https://medium.com/@agnel?source=rss-eaa1bd04c74d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 15 Nov 2026 12:56:03 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@agnel/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[Fundamentals of AWS CloudFormation]]></title>
            <link>https://medium.com/tensult/fundamentals-of-aws-cloudformation-1650db4899f7?source=rss-eaa1bd04c74d------2</link>
            <guid isPermaLink="false">https://medium.com/p/1650db4899f7</guid>
            <category><![CDATA[deployment]]></category>
            <category><![CDATA[aws-cloudformation]]></category>
            <category><![CDATA[template]]></category>
            <category><![CDATA[cloudformation]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Agnel Nandapurapu]]></dc:creator>
            <pubDate>Thu, 06 Jun 2019 06:10:42 GMT</pubDate>
            <atom:updated>2019-12-09T13:18:29.728Z</atom:updated>
            <content:encoded><![CDATA[<h3>Working with AWS CloudFormation</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cY654rxn-MKE964ywWw6Bw.jpeg" /><figcaption>Ref: <a href="https://bit.ly/2QOblTT">https://bit.ly/2QOblTT</a></figcaption></figure><p>In AWS, configuration and provisioning of any resource should be done either through CLI or the console. So when using these interfaces, you have to follow multiple steps to configure resources/architecture. For fewer resources, it won’t be hard to configure, but in the case of large scale deployments, it will be tough to handle the configurations. In this case, CloudFormation comes into the picture. Cloud formation is an AWS service to configure resources using a template. The template is used to define all required configurations to setup architecture in one go.</p><h4>What is Template?</h4><p>It is nothing but a JSON/YAML file. Attributes of the template should be defined as per CloudFormation documentation. CloudFormation documentation clearly explains how to configure resources and attributes in templates. Here I’m mainly discussing the important attributes of the Cloud Formation template. Please refer to this <a href="https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/Welcome.html">link</a> for CloudFormation documentation.</p><p><strong>Main Attributes of Cloudformation Template :</strong></p><ul><li><strong>Parameters:</strong> this attribute is called as inputs to the template, parameters will be referred in many places inside the template.</li><li><strong>Resources:</strong> this attribute is very crucial, this is used to configure AWS resources, without this, we can’t configure any resource in the Cloudformation template.</li><li><strong>Outputs: </strong>Outputs are used to get the values after the execution of the template.</li><li><strong>Mappings: </strong>Mappings are used as pre-define a JSON body which matches a key to a corresponding set of named values.</li><li><strong>Conditions: </strong>these are the statements used to perform certain actions when the statement is true.</li></ul><p>I gave a brief explanation of the main attributes in the CloudFormation template. Now I am going to explain the functionalities of the template to create an AWS ec2 instance.</p><p>While executing the above template, firstly it asks values for parameters. We have only one parameter and that is “EnvType” as I mentioned in allowed values, so we should select either “prod” or “test”.</p><p>At <strong>Conditions</strong> attribute, based on given EnvType we are setting <strong>CreateProdResources </strong>value, if EnvType is “prod” then <strong>CreateProdResources </strong>value will be <strong>“true” </strong>here otherwise the value will be <strong>“false”</strong>.</p><p>If we check MountPoint and NewVolume Resources, they are depending value of <strong>CreateProdResources.</strong></p><ul><li>If <strong>CreateProdResources </strong>is true then MountPoint and NewVolume will be configured.</li><li>If <strong>CreateProdResources </strong>is false then MountPoint and NewVolume will not be configured.</li></ul><p>The above template has three resources, namely, Ec2Instance, MountPoint, and NewVolume.</p><p>If we see elements in <strong>Ec2Instance</strong> resource, <strong>Type </strong>is used to define the type of AWS resource, so here we are creating one Ec2 instance so Type is <strong>AWS::EC2:: Instance.</strong></p><blockquote>Note: cloud formation defined a specific resource type for each resource.</blockquote><blockquote>Note: <strong>AWS:: Region</strong> returns cloud formation template running region.Supppose template is running in us-east-1 region then <strong>AWS:: Region </strong>is us-east-1.</blockquote><p>If we see <strong>ImageId</strong> property, it is fetching the value from the <strong>RegionMap</strong> object in the <strong>Mappings</strong> attribute. It checks keys in RegionMap by <strong>AWS:: Region value. </strong>So ImageId gets the values from RegionMap object in Mapping with associated AMIs to the regions.</p><p>If we see MountPoint, it is referring Ec2Instace for getting the value of InstanceId and referring NewVolume for getting volume.</p><p>Also, if we see a new volume, it is referring Ec2Instace for getting value AvailabilityZone.</p><blockquote>Note: If one resource is depending on another one in the template, in the execution order of template, independent resources run first then dependent resources run.</blockquote><p>So first Ec2Instance will be configured, after NewVolume and MountPoint will be configured.</p><p><strong>Outputs</strong> give values after all resources are configured in the template, the volume gets the value after NewVolume resource creation and if <strong>CreateProdResources</strong> is true.</p><p><strong><em>Conclusion</em></strong></p><p>In the template we used several intrinsic functions to fetch values from other elements, they are Fn:: GetAtt, Fn:: Equals, Fn:: FindInMap. These are Cloud Formation predefined functions that we can use as per our requirement. Please read this <a href="https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference.html">doc</a> for more functions.</p><p>Here, I explained only the functionalities inside the template, but I didn’t show how to execute through the <strong>AWS console, </strong>so please refer to this <a href="https://medium.com/tensult/aws-cloudformation-and-interactive-inputs-399f6769c7e2">link</a> to understand the execution steps of the cloud formation template.</p><p><em>This Blog has been moved from Medium to </em><a href="https://blogs.tensult.com/2019/06/06/working-with-aws-cloudformation/"><em>blogs.tensult.com</em></a><em>. All the latest content will be available there. Subscribe to our </em><a href="https://blogs.tensult.com/newsletter"><em>newsletter</em></a><em> to stay updated.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1650db4899f7" width="1" height="1" alt=""><hr><p><a href="https://medium.com/tensult/fundamentals-of-aws-cloudformation-1650db4899f7">Fundamentals of AWS CloudFormation</a> was originally published in <a href="https://medium.com/tensult">Tensult Blogs</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Centralized  log monitoring using Elastic Stack]]></title>
            <link>https://medium.com/tensult/centralized-log-monitoring-using-elastic-stack-ab154600700?source=rss-eaa1bd04c74d------2</link>
            <guid isPermaLink="false">https://medium.com/p/ab154600700</guid>
            <category><![CDATA[log-monitoring]]></category>
            <category><![CDATA[elasticsearch]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[filebeat]]></category>
            <dc:creator><![CDATA[Agnel Nandapurapu]]></dc:creator>
            <pubDate>Tue, 16 Apr 2019 13:06:37 GMT</pubDate>
            <atom:updated>2019-12-09T13:19:56.504Z</atom:updated>
            <content:encoded><![CDATA[<h3>Centralized log monitoring using Elastic Stack</h3><p><em>This Blog has been moved from Medium to </em><a href="https://blogs.tensult.com/2019/04/16/centralized-log-monitoring-using-elastic-stack/"><em>blogs.tensult.com</em></a><em>. All the latest content will be available there. Subscribe to our </em><a href="https://blogs.tensult.com/newsletter"><em>newsletter</em></a><em> to stay updated.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*8FTkI8hzX2J7zWGk9bI8Ug.jpeg" /><figcaption>Ref: <a href="https://bit.ly/2UFcnXn">https://bit.ly/2UFcnXn</a></figcaption></figure><p>I have implemented this setup for monitoring logs of multiple EC2 instances in an AWS Account. Generally, every instance will generate several logs during runtime, it might be system logs, application logs, etc. so how can we monitor all these logs at one place? I couldn’t find any service for the centralized monitoring for instance logs in AWS, so I have implemented one customized solution for this by using Elastic Stack and AWS services ( Lambda and CloudWatch).</p><blockquote><strong>Note :</strong> To make it simple and understandable, I took apache2 server logs of a single instance but the same process can be done on multiple instances with different logs.</blockquote><h4>Prerequisites :</h4><ol><li>FileBeat is the main application for shipping and filtering the logs, so we need to install FileBeat on the instance. To download and install follow the steps <a href="https://www.elastic.co/guide/en/beats/filebeat/current/filebeat-installation.html">here</a>.</li><li>We use Elasticsearch for storing filtered logs data and here I use AWS Elasticsearch cluster endpoint. To configure AWS Elasticsearch cluster follow the below steps <a href="https://docs.aws.amazon.com/ses/latest/DeveloperGuide/event-publishing-elasticsearch-cluster.html">here</a>.</li><li>AWS Lambda is used for running the script to fetch error logs data from the Elasticsearch index.</li></ol><p><strong>FileBeat Configuration :</strong></p><p>FileBeat is one of the core applications in Elastic Stack and it is used for shipping logs to other Elastic Stack services like Elastic Search and Logstash, etc. As per my implementation, logs should be shipped to Elastic Search. For that, Filebeat configuration should be modified. <strong>filebeat.yml </strong>is the main configuration file of FileBeat. Refer the below image for the location.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OaEJRJ-vbUCPgImeNbJQjg.png" /></figure><p>Once you have opened the file follow the below steps:</p><p><strong>Step 1: Fetch logs from the system:</strong> We need to set paths from where FileBeat should fetch the logs. In the below image we are setting up the path of apache2 server, so FileBeat will get apache2 logs here.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JzLrsvgJIXAVYleLXWzvFQ.png" /></figure><p><strong>Step 2: Filter fetched logs: F</strong>ileBeat can ignore unwanted event messages from logs. Processors perform certain actions as per commands mentioned under them, here we are saying that ignore messages which have “HTTP/1.0\” 200&quot; sentence. Please refer to the below image:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vQy_hu2uNKoNUe4xLmhw6A.png" /></figure><p><strong>Step 3: Send logs to Elastic Search: </strong>For sending logs to Elasticsearch we need to set up below configurations at Elasticsearch output section in filebeat.yml</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1004/1*QS6JeuM4eGFteCnQUhAX0Q.png" /></figure><p>Once all configurations are done, we need to start the FileBeat application, use the below command for the same.</p><pre><strong>~/filebeat-6.6.2-linux-x86_64</strong>$ ./filebeat -e -v -c filebeat.yml</pre><p>Now it will start ingesting apache2 server logs into Elasticsearch cluster index.</p><p>Now that the FileBeats configurations are done, we need to configure Lambda and CloudWatch for generating time-based CloudWatch metrics for error logs.</p><p><strong>Lambda Configuration :</strong></p><p>Lambda is a serverless computing platform to run applications and it is used here to execute the below script. Below script is written for fetching log data based on queries from Elasticsearch and to set custom metric data in CloudWatch. Here I’m fetching error logs data by checking “response_code” and it is written in javascript.</p><p>Whenever Lambda executes the script, Elasticsearch will return error log data and it will generate custom metric data in CloudWatch.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/758f6fdcaff6fbbf71831f4dbdc22096/href">https://medium.com/media/758f6fdcaff6fbbf71831f4dbdc22096/href</a></iframe><blockquote>Note : Attach a role to lambda with below policy to access Elasticsearch</blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5bcba029a57952877347694e389c2bb9/href">https://medium.com/media/5bcba029a57952877347694e389c2bb9/href</a></iframe><p><strong>CloudWatch Configuration :</strong></p><p>Lambda will be executing the script every five minutes. To execute the function we have to configure a CloudWatch rule to trigger the Lambda function. Please refer to the image below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1004/1*y6Xs6J5mn_sSkYBEveL4TQ.png" /><figcaption>cloudwatch_rule</figcaption></figure><p>The script will be continuously executed and it will generate CloudWatch metric data as mentioned in the below image. By setting up alarm on this metric we can get alerts when it reaches a threshold limit so that we can get notifications for error logs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6QfTpZ-ykIQqu4OU7L6StQ.png" /><figcaption><strong>cloudwatch_metric</strong></figcaption></figure><p><strong>Conclusion</strong></p><p>This implementation is done in a single AWS account, using one Elasticsearch cluster and we can ship only the filtered data thereby reducing unnecessary storage space in Elasticsearch. So this is how we ship log data to Elasticsearch using FileBeat and Lambda. Let me know your thoughts in the comments section also try to implement this using multiple accounts.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ab154600700" width="1" height="1" alt=""><hr><p><a href="https://medium.com/tensult/centralized-log-monitoring-using-elastic-stack-ab154600700">Centralized  log monitoring using Elastic Stack</a> was originally published in <a href="https://medium.com/tensult">Tensult Blogs</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Version controlling using Git-flow tags.]]></title>
            <link>https://medium.com/tensult/version-controlling-using-git-flow-tags-57b34c1d6a71?source=rss-eaa1bd04c74d------2</link>
            <guid isPermaLink="false">https://medium.com/p/57b34c1d6a71</guid>
            <category><![CDATA[deployment]]></category>
            <category><![CDATA[gitflow]]></category>
            <category><![CDATA[branching-strategy]]></category>
            <category><![CDATA[best-practices]]></category>
            <category><![CDATA[development]]></category>
            <dc:creator><![CDATA[Agnel Nandapurapu]]></dc:creator>
            <pubDate>Tue, 12 Feb 2019 07:12:44 GMT</pubDate>
            <atom:updated>2019-12-09T13:21:30.023Z</atom:updated>
            <content:encoded><![CDATA[<p><em>This Blog has been moved from Medium to </em><a href="https://blogs.tensult.com/2019/02/12/version-controlling-using-git-flow-tags/"><em>blogs.tensult.com</em></a><em>. All the latest content will be available there. Subscribe to our </em><a href="https://blogs.tensult.com/newsletter"><em>newsletter</em></a><em> to stay updated.</em></p><p>This blog explains step by step process of Git-flow methodology to create versioning in Git. There are so many methods to deploy production code from Git. Generally, one particular branch will be fixed for production deployments, either master branch or another branch. <strong>Git-flow </strong>also uses the master branch for deployments, but it maintains <strong>tags </strong>for every production release, so we can easily switch from one release to another by tags.</p><h4>Installation</h4><p>Git-flow is a small plug-in for Git. It is available on multiple operating systems. For OSX, we can install using CLI command <strong>brew install git-flow</strong>. For Window OS use this <a href="https://git-scm.com/download/win">link</a> to download.</p><p>Git-flow has specific branches, each branch has its own role. So I will explain the purpose of each branch with proper commands. Let’s start the process now, just execute below command after successful installation of the Git-flow plug-in.</p><pre>$ git flow init<br>Initialized empty Git repository in ~/project/.git/<br>No branches exist yet. Base branches must be created now.<br>Branch name for production releases: [master]<br>Branch name for &quot;next release&quot; development: [develop]</pre><pre>How to name your supporting branch prefixes?<br>Feature branches? [feature/]<br>Release branches? [release/]<br>Hotfix branches? [hotfix/]<br>Support branches? [support/]<br>Version tag prefix? []</pre><pre>$ git branch<br>* develop<br> master</pre><h4>Master and Develop branches :</h4><p>Git-flow sets <strong>master</strong> branch for <strong>production </strong>and <strong>develop</strong> branch for <strong>next release, </strong>you can observe that in the above snippet, the master branch is used here for production release history and develop branch for integrating with feature branches.</p><h4>Feature branches :</h4><p>Feature branches are for implementation, suppose if we want to work on a particular feature in the project, then we should create a feature branch.</p><blockquote><strong><em>Note : </em></strong><em>Feature branches should be created from develop branch.</em></blockquote><p>For creating feature branch use below command.</p><p><strong><em>Starting a feature branch :</em></strong></p><pre>$git flow feature start featurebranch_01</pre><pre>Switched to a new branch &#39;feature/featurebranch_01&#39;</pre><pre>Summary of actions:<br>- A new branch &#39;feature/featurebranch_01&#39; was created, based on &#39;develop&#39;<br>- You are now on branch &#39;feature/featurebranch_01&#39;</pre><p>Feature branch is <strong>featurebranch_01. </strong>Now, you can work on the feature branch ( featurebranch_01 ). Once work is completed on the feature branch, then we should merge that feature branch into develop branch. Follow below steps to do that.</p><p><strong><em>Finishing a feature branch :</em></strong></p><pre>$git flow feature finish featurebranch_01</pre><pre>Switched to branch ‘develop’<br>Updating 8705e32..6b59eca<br>Fast-forward<br> xxxxxxx.js | 1 +<br> xxxx.js | 2 ++<br> 2 files changed, 3 insertions(+)<br> create mode 100644 xxxxxxx.js<br>Deleted branch feature/featurebranch_01 (was 6b59eca).</pre><pre>Summary of actions:<br>- The feature branch ‘feature/featurebranch_01’ was merged into ‘develop’<br>- Feature branch ‘feature/featurebranch_01’ has been removed<br>- You are now on branch ‘develop’</pre><p>If you observe the above summary of actions, it has automatically performed three actions. Same way, we can merge as many feature branches to develop as we wish.</p><h4>Release branches :</h4><p>Once develop branch has enough features for a release, then we need to create a release branch.</p><blockquote><strong><em>Note: </em></strong><em>Release branches should be created from develop branch.</em></blockquote><p>Once release branch is created that means new project cycle is started, so every new feature will be considered for the next release, not for current release, so we shouldn’t merge any feature directly to the release branch, we should only add bug fixes and release notes to release branch.</p><p><strong>Starting a release branch :</strong></p><pre>$ git flow release start 0.1.0</pre><pre>Switched to a new branch ‘release/0.1.0’</pre><p>Release branch is 0.1.0. Now it is contained with all features came from develop branch.</p><p><strong>Finishing a release branch :</strong></p><pre>$ git flow release finish ‘0.1.0’</pre><pre>Deleted branch release/0.1.0 (was 6b59eca).</pre><pre>Summary of actions:</pre><pre>- Latest objects have been fetched from ‘origin’</pre><pre>- Release branch has been merged into ‘master’</pre><pre>- The release was tagged ‘0.1.0’</pre><pre>- Release branch has been back-merged into ‘develop’</pre><pre>- Release branch ‘release/0.1.0’ has been deleted</pre><p>If you observe the above summary of actions, the release branch is merged with master and develop branches. the release branch is tagged with “0.1.0” and it is removed.</p><p>This tag “0.1.0” contains the whole package of release branch “0.1.0”. the same way, every release will be stored into tags ex: 0.1.1, 0.1.2 etc… So we can easily track releases using tags.</p><h4>Hotfix Branches :</h4><p>These hotfix branches are used to fix bugs and patches of production releases. Once fixes are completed, it should be merged into both master and develop (or the current release branch), and the master should be tagged with an updated version number.</p><p><strong>Starting a hotfix branch :</strong></p><pre>$ git flow hotfix start hotfixbranch_01</pre><pre>Switched to a new branch &#39;hotfix/hotfixbranch_01&#39;</pre><pre>Summary of actions:<br>- A new branch &#39;hotfix/hotfixbranch_01&#39; was created, based on &#39;master&#39;<br>- You are now on branch &#39;hotfix/hotfixbranch_01&#39;</pre><pre>Follow-up actions:<br>- Bump the version number now!<br>- Start committing your hot fixes<br>- When done, run:</pre><p><strong>Finishing a hotfix branch :</strong></p><pre>$ git flow hotfix finish hotfixbranch_01<br>  Switched to branch &#39;develop&#39;<br>  Merge made by the &#39;recursive&#39; strategy.<br>  xxxx.js | 1 -<br>  1 file changed, 1 deletion(-)<br>  Deleted branch hotfix/hotfixbranch_01 (was e9308a9).</pre><pre>Summary of actions:<br>- Latest objects have been fetched from &#39;origin&#39;<br>- Hotfix branch has been merged into &#39;master&#39;<br>- The hotfix was tagged &#39;hotfixbranch_01&#39;<br>- Hotfix branch has been back-merged into &#39;develop&#39;<br>- Hotfix branch &#39;hotfix/hotfixbranch_01&#39; has been deleted</pre><blockquote><strong><em>Note: To check out into tags, use this command.</em></strong></blockquote><pre>$git checkout tags/0.1.0</pre><p>Finally, we should push the master branch and tags to your repository.</p><pre>$git push <br>$git push --tags</pre><h4>Advantages of Git-Flow:</h4><ul><li>Managing of branching system is very easy to understand and doable.</li><li>All Commands are customized, so we can easily remember commands for a long time.</li><li>If we follow the Procedure properly then there is no chance of getting conflicts between releases.</li><li>Maintaining multiple branches in git is a little complicated, which can be maintained easily using Git-Flow.</li></ul><h4>Conclusion:</h4><p>Git-Flow has removed some complexities in git and made the process very simple and understandable, so even new guys can understand the flow easily. It is customized for the developmentation environment, so it helps developers/programmers for understanding git easily. Tagging concept of Git-Flow is giving an easy way to track the production releases.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=57b34c1d6a71" width="1" height="1" alt=""><hr><p><a href="https://medium.com/tensult/version-controlling-using-git-flow-tags-57b34c1d6a71">Version controlling using Git-flow tags.</a> was originally published in <a href="https://medium.com/tensult">Tensult Blogs</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Advanced features of DynamoDB]]></title>
            <link>https://medium.com/tensult/advanced-features-of-dynamodb-47c13e655ae9?source=rss-eaa1bd04c74d------2</link>
            <guid isPermaLink="false">https://medium.com/p/47c13e655ae9</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[dynamodb]]></category>
            <category><![CDATA[best-practices]]></category>
            <category><![CDATA[nosql]]></category>
            <dc:creator><![CDATA[Agnel Nandapurapu]]></dc:creator>
            <pubDate>Wed, 11 Jul 2018 08:18:38 GMT</pubDate>
            <atom:updated>2019-12-09T13:23:19.750Z</atom:updated>
            <content:encoded><![CDATA[<p><em>This Blog has been moved from Medium to </em><a href="https://blogs.tensult.com/2018/07/11/advanced-features-of-dynamodb/"><em>blogs.tensult.com</em></a><em>. All the latest content will be available there. Subscribe to our </em><a href="https://blogs.tensult.com/newsletter"><em>newsletter</em></a><em> to stay updated.</em></p><p>In this blog I will be explaining the advanced concepts of DynamoDB. If you are not familiar with the service, you can visit my DynamoDB core concepts blog <a href="https://medium.com/tensult/core-concepts-of-amazon-dynamodb-a265a3fc70a">here</a>. I hope this blog will be useful to enhance your knowledge on DynamoDB and which would further add value to your application design processes.</p><h4>Secondary Indices</h4><p><strong>What are indices in DynamoDB?</strong> DynamoDB provides fast access to items in a table by specifying Partition Key values. But if we need to query by attributes other than keys of the table, then secondary indices are useful to make such queries, secondary indices are two types.</p><ul><li>Local Secondary indices.</li><li>Global Secondary indices.</li></ul><p><strong>Why do we need the local secondary index?</strong></p><p>If we need to sort items of the table by any attribute other than tables’s sort key, then we can use local secondary index. While creating local secondary index, we can select a new attribute of the item as sort key but Partition Key remains same as the table.</p><blockquote>We can only create local secondary indices at the time of table creation and once the table is created these indices becomes unmodifiable.</blockquote><p><strong>Why do we need the global secondary index?</strong></p><p>We know that to query a DynamoDB table, we need to provide table Partition Key as a parameter but what if we want to query by some other attribute? This is when we need to use the Global secondary indices. Unlike local secondary index, we can select both Partition and sort keys in global secondary index but sort key is optional. So when we create a global secondary index, we need to specify the new Partition key other than the Partition key of the table and sort key can be same or different as the table’s sort key.</p><p>When we create a global secondary index, we also need to specify the attributes that will be projected into the index and three different options are available here :</p><p><strong>KEYS_ONLY : </strong>Each item in the index consists the source table key values and index key values. <br><strong>INCLUDE : </strong>In addition to the attributes described in KEYS_ONLY, the secondary index will include other non-key attributes that you specify.<br><strong>ALL : </strong>The secondary index includes all the attributes from the source table because all of the table data is duplicated in the index.</p><blockquote>In reality when you create global secondary key, DynamoDB creates a separate table and replicates all the table operations like insert, update and deletion asynchronously.</blockquote><blockquote>We can have upto 5 local and 5 global secondary indices but as local secondary indices have to be created while creating the table so we need to analyse how our query patterns will be before even creating the table.</blockquote><h4>Pagination</h4><p>Pagination is a process of splitting results into separate pages, but DynamoDB handles pagination in slightly different way. DynamoDB processes query requests in two phases. First phase is the <strong>Query phase</strong> and in this phase, DynamoDB fetches records from the table using partition key and optional sort key and the second phase is the <strong>Filter phase</strong> where DynamoDB applies other attribute filters on the data fetched in the first phase.</p><p>DynamoDB provides a pagination parameter called <strong>limit </strong>and when we pass this parameter in query request, it first fetches items matched with key parameters up to a limit value in query phase and then applies attribute filters in filter phase hence the final items returned by DynamoDB after both phases will be less than or equal to the limit value. In Scan operation, during the query phase, DynamoDB directly fetches items up to the limit value and there is no matching of keys in this operation.</p><blockquote>The maximum size of the items fetched in the query phase is limited to 1MB so even if we pass a very large limit value, DynamoDB returns only items that fits into 1MB limit.</blockquote><h4>Conditions</h4><p>We can put conditions while creating or updating items. For example: put item, if it doesn’t already exist or update item if version attribute matches to the given value. To know more about conditions go to the AWS official documentation <a href="https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.ConditionExpressions.html">here</a>.</p><h4>What is hot partition in DynamoDB?</h4><p>DynamoDB makes hardware partitions based on capacity units of the table. Capacity units of the table are distributed equally among all partitions in DynamoDB. If any partition has consumed more capacity units than provisioned capacity units, then that partition is called as hot partition.<br><strong>How to avoid hot partitions? </strong>The main reason of hot partitions is partition key of the table, when a partition key value is getting more requests then obviously the item of that partition key consumes more capacity units, so selecting proper Partition key is important in DynamoDB to avoid hot partitions. Partition key should be unique and random.</p><h4>Encryption At Rest</h4><p>DynamoDB has provided <strong>encryption at rest </strong>feature<strong> </strong>for<strong> </strong>making table data<strong> </strong>more secure from an unauthorised access. DynamoDB encryption is a server side encryption and it is transparent to the user so we don’t have to change the application’s code. Once encryption is enabled on the table, all the data related to that table will be encrypted : the data in the table, local secondary indices, and global secondary indices.</p><p>Encryption will be done using AES-256 encryption. Encryption automatically integrates with AWS Key Management Service for managing the single service default key that is used to encrypt your tables. If a service default key doesn’t exist when you create your encrypted table then DynamoDB automatically creates a new AWS KMS key in your account. This key will be used for the tables that are created in the future.</p><blockquote>Encryption at rest can be enabled only when the table is created. We can’t enable it after the table is created, also once encryption at rest is enabled on the table we can’t disable it back again.</blockquote><h4>TTL</h4><p>Time To Live ( TTL ) is a feature that enables you to clean up items of the table automatically after a specific time. To enable TTL on the table, first we need to choose the name of the TTL attribute then we can use this TTL attribute to specify a timestamp at which point items should be deleted by DynamoDB from your table and DynamoDB never takes any additional charges for deleted items using TTL.</p><blockquote><strong>Note</strong> : DynamoDB deletes expired items within 48 hours after expiration, it depends upon the nature of the workload and the size of the table.</blockquote><h4>Backup</h4><p>DynamoDB provides automated on-demand backup, restore, and point-in-time recovery. We have already written a blog on DynamoDB backup, and if you would like to read it, please click <a href="https://medium.com/tensult/aws-dynamodb-point-in-time-recovery-e8711d6d04cb">here</a>.</p><h4>Access control</h4><p>You might have valid AWS credentials to access DynamoDB resources(tables, indexes, and streams), but until you have appropriate permissions, you cannot access DynamoDB resources. Click <a href="https://medium.com/tensult/integrating-aws-service-control-policy-and-iam-policy-3ce77641dbdf">here</a> to know more about AWS IAM policies.</p><p>In DynamoDB we can constrain users to certain actions while granting permission using IAM policy like allowing users to read certain items and attributes in a table or a secondary index and allowing users to write on certain attributes in a table, based upon the identity of that user.</p><p>We can achieve above scenarios using IAM policy <strong>condition </strong>element, by adding a <strong>condition </strong>element to an IAM policy, you can allow or deny access to items and attributes in DynamoDB tables and indexes. We can then apply this policy to IAM users, groups, or roles to restrict certain services or users. To know more about Access control go to an official documentation <a href="https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/specifying-conditions.html">here</a>.</p><h4><strong>Limits</strong></h4><p><strong>Read &amp; Write Capacity Unit Sizes :</strong></p><p>One read capacity = One read per second (items size upto 4KB )</p><p>One write capacity = One write per second (items size upto 1KB )</p><p><strong>Throughput limits</strong> : Except US East (N. Virginia)region, rest of the regions have the same limits.</p><p><strong>US East (N. Virginia) Region:</strong></p><ul><li>Per table — 40,000 read capacity units and 40,000 write capacity units</li><li>Per account — 80,000 read capacity units and 80,000 write capacity units</li></ul><p><strong>All Other Regions:</strong></p><ul><li>Per table — 10,000 read capacity units and 10,000 write capacity units</li><li>Per account — 20,000 read capacity units and 20,000 write capacity units</li></ul><blockquote><strong>Note :</strong> The throughput limit is at an AWS account level. All the account’s available throughput can be applied to a single table or across multiple tables.</blockquote><p><strong>Table Size :</strong> There is no limitation on table size in terms of the number of items and the number of bytes. Default limit on the Number of tables for AWS Account is 256/region. It is a soft limit so it can be increased by raising <a href="https://docs.aws.amazon.com/general/latest/gr/aws_service_limits.html">Service Limit Increase</a> support case with AWS.</p><p><strong>Item Size </strong>: item size should not exceed 400KB</p><p><strong>Partition Key Size </strong>: All the items with same Partition Key goes to the same partition and the maximum partition size of DynamoDB is 10GB hence we can only store a maximum of 10GB data with a single Partition Key.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=47c13e655ae9" width="1" height="1" alt=""><hr><p><a href="https://medium.com/tensult/advanced-features-of-dynamodb-47c13e655ae9">Advanced features of DynamoDB</a> was originally published in <a href="https://medium.com/tensult">Tensult Blogs</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Core concepts of Amazon DynamoDB]]></title>
            <link>https://medium.com/tensult/core-concepts-of-amazon-dynamodb-a265a3fc70a?source=rss-eaa1bd04c74d------2</link>
            <guid isPermaLink="false">https://medium.com/p/a265a3fc70a</guid>
            <category><![CDATA[features]]></category>
            <category><![CDATA[basics]]></category>
            <category><![CDATA[nosql]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[dynamodb]]></category>
            <dc:creator><![CDATA[Agnel Nandapurapu]]></dc:creator>
            <pubDate>Thu, 21 Jun 2018 13:06:01 GMT</pubDate>
            <atom:updated>2019-12-10T10:43:32.411Z</atom:updated>
            <content:encoded><![CDATA[<p><em>This blog has been moved from medium to </em><a href="https://blogs.tensult.com/2018/06/21/core-concepts-of-amazon-dynamodb/"><em>blogs.tensult.com</em></a><em>. All the latest updates are available there. Subscribe to our </em><a href="https://blogs.tensult.com/newsletter"><em>newsletter</em></a><em> to stay updated.</em></p><p><strong>What is DynamoDB? </strong>DynamoDB is a managed NoSQL database provided by AWS, and it is a highly scalable and reliable database. We can scale from 10 to 1000 transactions per second (tps) in couple of seconds. Since it is a managed service, we don’t need to worry about the underlying hardware, servers or operating system. Data stored in the DynamoDB is redundantly copied across multiple <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-regions-availability-zones.html">Availability Zones</a> so by default it provides protection for data loss due to underlying hardware failures.</p><p>DynamoDB organises data as tables and each table contains several items (rows) and each item has Keys and Attributes (columns). The tables in the DynamoDB are non relational and non schema based. This means table joins are not supported at DB level. For most use cases, we don’t need table joins and those fit really well with DynamoDB.</p><p>Now let us discuss DynamoDB terminology.</p><h4><strong>Tables</strong></h4><p>When we create the table we specify Partition Key and an optional Sort Key, we can’t change these later but rest of the attributes (columns) of item (row) can change. Also each item can have different set of attributes.</p><p><strong>Example</strong></p><p>Let us say we want to store articles from various authors in DynamoDB:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_jqBrxJ4qFDE6rIDofTGdg.png" /><figcaption><strong>Article_Table</strong></figcaption></figure><pre><strong>Table Keys</strong><br>Partition Key : authorId<br>Sort Key : publicationDate</pre><blockquote>Item 1 has mainImage but not mainVideo attribute, where as Item 2 has mainVideo but not mainImage attribute. This is possible in DynamoDB as it is non-schema based.</blockquote><blockquote>Item1 and Item3 have same partition key abc123 and with different sort keys, which is possible in dynamoDB.</blockquote><blockquote>There is no limit on how many items can be stored in a table.</blockquote><h4><strong>Item</strong></h4><p>A DynamoDB item is nothing but a row in the table. We can change any attribute of an item except its keys: partition key or sort key, these keys are an identification for an item; if we have to change these keys, then the only option is to delete an item and create it again.</p><h4>Data Types</h4><p>DynamoDB supports different data types for attributes of an item, they can be mainly categorised into the following:</p><ul><li>Scalar Types : Number, String, Binary, Boolean and Null.</li><li>Document Types : List and Map</li><li>Set Types : Number Set, String Set, and Binary Set.</li></ul><h4><strong>Partition Key</strong></h4><p>This key is mandatory for the DynamoDB table and item. DynamoDB partitions the items using this key, that’s why this key is also called as the partition key and some times is also referred as a <strong>Hash Key</strong>.</p><h4><strong>Sort key</strong></h4><p>This key can be used in conjunction with the Partition key but it is not mandatory. This is useful while querying the data relating a Partition key. We can use several different filter functions on the sort key such as begins with, between etc. Some times it is also referred to as a <strong>Range Key</strong>.</p><h4>Primary Key</h4><p>Primary key is just a combination of both Partition key and Sort Key.</p><h4>Batch APIs</h4><p><strong>BatchGetItem : </strong>This can be used to fetch items from different tables using Partition Key and Sort Key. In a single BatchGetItem call, we can fetch up to 16MB data or 100 items.</p><blockquote>BatchGetItem can be performed only on tables not on secondary indexes.</blockquote><p><strong>BatchWriteItem:</strong> This can be used to delete or put items on one or more tables in DynamoDB in one call. We can write up to 16 MB data, which can be 25 put and delete requests.</p><blockquote>BatchWriteItem cannot update items, for that use UpdateItem API call</blockquote><h4><strong>Query</strong></h4><p>To query table we must pass partition key so selecting proper partition key for the table is important. Query operation will return all items that are matched with partition key of the table. Sort Key is further useful to filter and sort items but it is optional.</p><h4>Scan</h4><p>Scan operation does’t require Partition Key or Sort Key to fetch results from the table. As the name suggests, it scans an entire table to filter results based on attribute values passed as filters.</p><h4><strong>Pagination</strong></h4><p>DynamoDB Query/Scan results return maximum of 1MB response size so if our request matches an items of size more than 1MB, it gets automatically divided into pages. In such cases DynamoDB returns a special response parameter “LastEvaluatedKey” and this can be used to fetch next page results. Please note we need to pass the value of “LastEvaluatedKey” as “ExclusiveStartKey” in the next request to DynamoDB.</p><p>In some cases we might want to fix page size to number such as 10 or 20 results per page. In those cases we can use the “Limit” parameter. Please note if the results matching to the “Limit” is more than 1MB then DynamoDB only returns subset of the results which fits to 1MB limit.</p><h4>Sorting</h4><p>When we use Query/Scan operation on a DynamoDB table, then by default the results are sorted based on Sort Key value of the table. Incase we want that results in reverse order then we need to pass “ScanIndexForward” as “false” in query/scan request parameters. If the data type of Sort key is a number, then the results will be in a numeric order, otherwise, results will be in UTF-8 bytes. By default sort order is ascending. To get results in a descending order, pass “ScanIndexForward” as “false”.</p><h4>How to call DynamoDB APIs programmatically ?</h4><p><a href="https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Programming.html">AWS SDK</a> for DynamoDB is supported for several languages, which can be used to interact with DynamoDB API seamlessly. We can also use DynamoDB using <a href="https://docs.aws.amazon.com/cli/latest/reference/dynamodb/index.html">AWS CLI</a>.</p><h4>Pricing</h4><p>Last but not least… let us see how is DyanamoDB is priced.</p><p><strong>Free Tier :</strong></p><p><strong>Throughput limit : </strong>200 million requests per month ( 25 read and 25 write capacity units)</p><p><strong>Stream limit : </strong>2.5 million read requests per month.</p><p><strong>Storage :</strong> 25GB of indexed data storage.</p><p><strong>Note</strong> : <em>Above free tier does not end after 12 months.</em></p><p>For more information about pricing click <a href="https://aws.amazon.com/dynamodb/pricing/?sc_channel=PS&amp;sc_campaign=acquisition_IN&amp;sc_publisher=google&amp;sc_medium=dynamodb_b&amp;sc_content=sitelink&amp;sc_detail=dynamo%20db%20pricing&amp;sc_category=dynamodb&amp;sc_segment=pricing&amp;sc_matchtype=e&amp;sc_country=IN&amp;s_kwcid=AL!4422!3!78960267061!e!!g!!dynamo%20db%20pricing&amp;ef_id=WemYEwAABJ8@YWET:20180610150205:s">here</a></p><h4>What next?</h4><p>Now that we have learnt basics of DynamoDB, I will be discussing more concepts related to DynamoDB in my future <a href="https://medium.com/tensult/advanced-features-of-dynamodb-47c13e655ae9">blogs</a>. So if you want me to particularly focus on any topic of DynamoDB, then please leave a comment on this blog.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a265a3fc70a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/tensult/core-concepts-of-amazon-dynamodb-a265a3fc70a">Core concepts of Amazon DynamoDB</a> was originally published in <a href="https://medium.com/tensult">Tensult Blogs</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>