<?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 Cagrihankara on Medium]]></title>
        <description><![CDATA[Stories by Cagrihankara on Medium]]></description>
        <link>https://medium.com/@cagrihankara?source=rss-ada54ac239e6------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Y0gDXD9jUX8biho-nPDHew.jpeg</url>
            <title>Stories by Cagrihankara on Medium</title>
            <link>https://medium.com/@cagrihankara?source=rss-ada54ac239e6------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 04:51:04 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@cagrihankara/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[Your First Simple Docker Project: A Step-by-Step Guide for Beginners]]></title>
            <link>https://cagrihankara.medium.com/your-first-simple-docker-project-a-step-by-step-guide-for-beginners-c1e7554a6d0f?source=rss-ada54ac239e6------2</link>
            <guid isPermaLink="false">https://medium.com/p/c1e7554a6d0f</guid>
            <category><![CDATA[containers]]></category>
            <category><![CDATA[dockerfiles]]></category>
            <category><![CDATA[docker-image]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[docker]]></category>
            <dc:creator><![CDATA[Cagrihankara]]></dc:creator>
            <pubDate>Mon, 11 Sep 2023 13:02:07 GMT</pubDate>
            <atom:updated>2023-09-11T13:02:07.467Z</atom:updated>
            <content:encoded><![CDATA[<p>Docker is a powerful tool for containerizing applications, making them easy to develop, package, and deploy consistently across different environments. In this beginner’s guide, we’ll walk you through creating your first simple Docker project, demonstrating how to build and run a Docker container. Let’s get started!</p><h3>Prerequisites</h3><p>Before diving into your first Docker project, make sure you have the following prerequisites in place:</p><ol><li><strong>Docker Installed</strong>: You should have Docker installed on your machine. If you haven’t already, you can find installation instructions for various platforms on the <a href="https://docs.docker.com/get-docker/">Docker website</a>.</li><li><strong>Basic Command-Line Knowledge</strong>: Familiarity with basic command-line operations is helpful, as you’ll be working with Docker through the command line.</li></ol><h3>Step 1: Create a Simple Application</h3><p>For this example, we’ll create a straightforward Node.js application. Create a directory for your project and navigate to it in your terminal.</p><pre>mkdir my-docker-app<br>cd my-docker-app</pre><p>Inside your project directory, create a simple app.js file with the following content:</p><pre>const http = require(&#39;http&#39;);<br><br>const server = http.createServer((req, res) =&gt; {<br>  res.writeHead(200, { &#39;Content-Type&#39;: &#39;text/plain&#39; });<br>  res.end(&#39;Hello, Docker World!\n&#39;);<br>});<br><br>const port = process.env.PORT || 3000;<br>server.listen(port, () =&gt; {<br>  console.log(`Server running on http://localhost:${port}`);<br>});</pre><p>This basic Node.js application sets up a web server that responds with “Hello, Docker World!” when accessed.</p><h3>Step 2: Create a Dockerfile</h3><p>A Dockerfile is a script that defines the instructions to build a Docker image. Create a file named Dockerfile (no file extension) in your project directory and add the following content:</p><pre># Use the official Node.js image from the Docker Hub<br>FROM node:14<br><br># Set the working directory in the container<br>WORKDIR /usr/src/app<br><br># Copy package.json and package-lock.json to the container<br>COPY package*.json ./<br><br># Install application dependencies<br>RUN npm install<br><br># Copy the rest of the application source code to the container<br>COPY . .<br><br># Expose the port your application will run on<br>EXPOSE 3000<br><br># Define the command to run your application<br>CMD [&quot;node&quot;, &quot;app.js&quot;]</pre><p>This Dockerfile sets up a Node.js environment in a container, copies your application code and dependencies, and specifies how to run the application.</p><h3>Step 3: Build the Docker Image</h3><p>With your Dockerfile in place, you can build a Docker image for your application. In your project directory, run the following command:</p><pre>docker build -t my-docker-app .</pre><p>The -t my-docker-app option tags the image with the name &quot;my-docker-app&quot; for easier reference.</p><h3>Step 4: Run the Docker Container</h3><p>Now that you have built your Docker image, you can run a Docker container from it. Use the following command.</p><pre>docker run -p 3000:3000 my-docker-app</pre><p>This command maps port 3000 in the container to port 3000 on your host machine, allowing you to access your application in a web browser.</p><p>If you want to learn about run options, you can visit <a href="https://docs.docker.com/engine/reference/run/">here</a>.</p><h3>Step 5: Access Your Dockerized Application</h3><p>Open your web browser and navigate to http://localhost:3000. You should see &quot;Hello, Docker World!&quot; displayed, indicating that your Dockerized application is running successfully.</p><h3>Conclusion</h3><p>Congratulations! You’ve successfully created your first simple Docker project. You’ve learned how to create a basic Node.js application, write a Dockerfile, build a Docker image, and run a Docker container. Docker provides a powerful and consistent way to package and deploy applications, making it an essential tool in modern software development and deployment.</p><p>In future posts, we’ll explore more advanced Docker topics, including working with multi-container applications, Docker Compose, and container orchestration. Stay tuned for more Docker insights!</p><p>Happy containerizing!</p><p>Thank you so much for reading this article, I hope it has helped simplify the process of your case.</p><p>If you have any questions, please feel free to drop a comment or to write me on LinkedIn, and I’ll be happy to answer it for you.</p><p>If this article helped you out I’d appreciate you letting me know with a few claps or a follow on Medium, thank you.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c1e7554a6d0f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Getting Started with AWS: A Beginner’s Guide]]></title>
            <link>https://cagrihankara.medium.com/getting-started-with-aws-a-beginners-guide-166306fc70ce?source=rss-ada54ac239e6------2</link>
            <guid isPermaLink="false">https://medium.com/p/166306fc70ce</guid>
            <category><![CDATA[introduction-to-aws]]></category>
            <category><![CDATA[aws-cloud]]></category>
            <category><![CDATA[beginners-guide]]></category>
            <category><![CDATA[cloud]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Cagrihankara]]></dc:creator>
            <pubDate>Mon, 11 Sep 2023 12:27:09 GMT</pubDate>
            <atom:updated>2023-09-11T12:27:09.991Z</atom:updated>
            <content:encoded><![CDATA[<p>Are you eager to embark on your journey into the world of cloud computing with Amazon Web Services (AWS)? AWS is the leading cloud platform that provides a vast array of services for building, deploying, and managing applications and infrastructure in the cloud. In this beginner’s guide, we’ll delve deeper into the essentials of AWS and offer a step-by-step approach to help you get started.</p><h3>What is AWS?</h3><p>Amazon Web Services, or AWS for short, is Amazon’s cloud computing platform. It offers an extensive selection of cloud services that cover everything from computing power, storage, and databases to machine learning, analytics, and more. AWS is renowned for its flexibility, scalability, and cost-effectiveness, making it the go-to choice for businesses and individuals seeking to harness the power of the cloud.</p><h3>Creating an AWS Account</h3><p>To begin your AWS journey, the first order of business is to set up an AWS account. Follow these steps to get started:</p><h3>1. Visit the AWS Website</h3><p>Head over to the <a href="https://aws.amazon.com/">AWS website</a> and look for the “Create an AWS Account” button. Click on it to initiate the account creation process.</p><h3>2. Provide Your Information</h3><p>You’ll be prompted to enter your email address, create a secure password, and furnish basic personal information.</p><h3>3. Credit Card Information</h3><p>As part of the sign-up process, you’ll need to provide credit card information. While AWS does offer a Free Tier with limited resources for the first 12 months, having a valid payment method on file is essential to verify your identity.</p><h3>4. Identity Verification</h3><p>AWS may require you to verify your identity through a phone call. Simply follow the instructions provided during this step.</p><h3>5. Choose a Support Plan</h3><p>AWS offers various support plans, including a free basic plan. Choose the plan that aligns with your needs and budget.</p><h3>6. Access Your AWS Account</h3><p>Once your AWS account is set up, you can log in to the AWS Management Console. This is your central control hub for accessing and managing AWS services.</p><h3>Navigating the AWS Management Console</h3><p>The AWS Management Console is where you’ll spend much of your time when working with AWS. Here’s a quick overview of how to navigate it:</p><ul><li><strong>Dashboard</strong>: The dashboard provides an at-a-glance view of your AWS resources, recent activities, and shortcuts to commonly used services.</li><li><strong>Services</strong>: Click on the “Services” dropdown to explore the plethora of AWS services, neatly categorized into Compute, Storage, Database, Security &amp; Identity, and more.</li><li><strong>Regions</strong>: AWS operates in multiple geographical regions across the globe. You can choose a region that’s closest to your physical location or one that best suits your project’s needs.</li></ul><h3>The AWS Free Tier</h3><p>As a new AWS user, you can leverage the AWS Free Tier, which grants you limited, cost-free access to many AWS services for a duration of 12 months. This provides an excellent opportunity to experiment, learn, and build without incurring charges.</p><h3>Next Steps</h3><p>With your AWS account up and running and a basic understanding of the AWS Management Console, you’re poised to start exploring AWS services and embarking on your cloud journey. Consider delving into services such as:</p><ul><li>Amazon EC2 (Elastic Compute Cloud) for creating virtual servers.</li><li>Amazon S3 (Simple Storage Service) for scalable and durable storage.</li><li>AWS Lambda for serverless computing.</li></ul><p>In forthcoming posts, we’ll delve even deeper into specific AWS services, use cases, and best practices, ensuring you’re well-equipped to make the most of AWS’s capabilities.</p><p>Welcome to the thrilling realm of AWS! Happy cloud computing!</p><p>Thank you so much for reading this article, I hope it has helped simplify the process of your case.</p><p>If you have any questions, please feel free to drop a comment or to write me on LinkedIn, and I’ll be happy to answer it for you.</p><p>If this article helped you out I’d appreciate you letting me know with a few claps or a follow on Medium, thank you.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=166306fc70ce" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Creating, Using and Updating AWS IAM Roles with AWS CloudFormation]]></title>
            <link>https://cagrihankara.medium.com/creating-using-and-updating-aws-iam-roles-with-aws-cloudformation-28bc776163b0?source=rss-ada54ac239e6------2</link>
            <guid isPermaLink="false">https://medium.com/p/28bc776163b0</guid>
            <category><![CDATA[cloudformation]]></category>
            <category><![CDATA[aws-cloud]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[cloud]]></category>
            <category><![CDATA[iam-roles]]></category>
            <dc:creator><![CDATA[Cagrihankara]]></dc:creator>
            <pubDate>Mon, 11 Sep 2023 12:00:14 GMT</pubDate>
            <atom:updated>2023-09-11T12:00:14.610Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>What is IAM Role?</strong></p><ul><li>A role is a set of permissions that grant access to actions and resources in AWS. These permissions are attached to the role, not to an IAM User or a group.</li><li>An IAM User can use a role in the same AWS account or a different account.</li><li>An IAM User is similar to an IAM User; role is also an AWS identity with permission policies that determine what the identity can and cannot do in AWS.</li><li>A role is not uniquely associated with a single person; it can be used by anyone who needs it.</li><li>A role does not have long term security credential, i.e., password or security key. Instead, if the user uses a role, temporarily security credentials are created and provided to the user.</li><li>You can use the roles to delegate access to users, applications or services that generally do not have access to your AWS resources.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UpKlXj5Gzk_czi2I8vHtWw.png" /><figcaption>IAM Role</figcaption></figure><h4>Creating IAM Roles with AWS CloudFormation</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cI5PbbiMjZns4K3-DsDIJw.png" /><figcaption>IAM Roles with AWS CloudFormation</figcaption></figure><p>To create an IAM role with CloudFormation, you need to define a resource of the type <a href="https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-iam-role.html">AWS::IAM::Role</a>.</p><p>In this example, we define a role named ExampleRole with a policy that allows EC2 instances to assume this role. The role also has a policy that grants permission to read objects from an S3 bucket resource ExampleBucket.</p><pre>AWSTemplateFormatVersion: 2010-09-09<br><br>Resources:<br>  ExampleBucket:<br>    Type: AWS::S3::Bucket<br><br>  ExampleRole:<br>    Type: AWS::IAM::Role<br>    Properties:<br>      AssumeRolePolicyDocument:<br>        Version: &quot;2012-10-17&quot;<br>        Statement:<br>          - Effect: Allow<br>            Principal:<br>              Service:<br>                - ec2.amazonaws.com<br>            Action:<br>              - sts:AssumeRole<br>      Policies:<br>        - PolicyName: ExampleRolePolicy<br>          PolicyDocument:<br>            Version: &quot;2012-10-17&quot;<br>            Statement:<br>              - Effect: Allow<br>                Action:<br>                  - s3:GetObject<br>                Resource: !Sub arn:aws:s3:::${ExampleBucket}/*</pre><p>The AssumeRolePolicyDocument that is associated with this role. Trust policies define which entities can assume the role. You can associate only one trust policy with a role.</p><p>In this case, we allow the EC2 service to assume the IAM Role by specifying <a href="http://ec2.amazonaws.com/">ec2.amazonaws.com</a> as the principal in the Service field.</p><p>The Policies section defines the inline policy document embedded in the role. In our example, we create a policy named ExampleRolePolicy that grants permission to perform the s3:GetObject action on objects in the example-bucket S3 bucket.</p><p>When you embed an inline policy in a role, the inline policy is used as part of the role’s access permissions policy. The role’s trust policy is created at the same time as the role.</p><p>A complete list of properties can be found in the CloudFormation documentation for the <a href="https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-iam-role.html">AWS::IAM::Role</a> resource type.</p><h4>Using IAM Roles with CloudFormation Resources</h4><p>After creating an IAM role, you can use it with other AWS resources in your CloudFormation templates.</p><p>As an illustration, we can create an EC2 instance and link it to the IAM role that was created earlier:</p><pre>AWSTemplateFormatVersion: 2010-09-09<br><br>Resources:<br>  # ...<br>  ExampleEC2InstanceProfile:<br>    Type: AWS::IAM::InstanceProfile<br>    Properties:<br>      Roles:<br>        - !Ref ExampleRole<br><br>  AppDevSecurityGroup:<br>    Type: AWS::EC2::SecurityGroup<br>    Properties:<br>      GroupDescription: Example Security Group<br>      SecurityGroupIngress:<br>        - IpProtocol: tcp<br>          FromPort: 22<br>          ToPort: 22<br>          CidrIp: 0.0.0.0/0<br><br>  ExamppleEC2Instance:<br>    Type: AWS::EC2::Instance<br>    Properties:<br>      InstanceType: t3.small<br>      ImageId: ami-06b09bfacae1453cb<br>      IamInstanceProfile: !Ref ExampleEC2InstanceProfile<br>      SecurityGroups:<br>        - !Ref ExampleSecurityGroup<br><br>Outputs:<br>  ExampleBucketName:<br>    Value: !Ref ExampleBucket<br>    Description: Name of the Example S3 Bucket<br>  ExampleEC2InstanceIp:<br>    Value: !GetAtt ExampleEC2Instance.PublicIp<br>    Description: Public IP address of the Example EC2 Instance</pre><p>In this example, we define components to create an EC2 instance resource named ExampleEC2Instance.</p><p>We specify the ExampleEC2InstanceProfile to grant the EC2 instance specific permissions via an IAM role. We refer to the previously createdExampleRole IAM role.</p><p>This ensures that the EC2 instance assumes the specified IAM role, inheriting its permissions and policies. By associating IAM roles with resources, you can enforce the principle of least privilege, granting only the necessary permissions to perform specific actions.</p><p>We are using the CloudFormation <a href="https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-ref.html">intrinsic function </a><a href="https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-ref.html">!Ref</a> to return the resource value reference.</p><p>The ExampleSecurityGroup is an Amazon EC2 security group. It acts as a virtual firewall for the EC2 instance, controlling inbound and outbound traffic. This example template allows incoming SSH traffic on port 22 from any IP address (0.0.0.0/0).</p><h4>Updating IAM Roles permissions</h4><p>For every AWS service, you can specify what actions are allowed, which resources those actions can be applied to, and any additional conditions that need to be met in IAM policies.</p><p>The AWS documentation page <a href="https://docs.aws.amazon.com/service-authorization/latest/reference/reference_policies_actions-resources-contextkeys.html">Service Authorization Reference</a> contains the actions, resources, and condition keys for AWS services.</p><p>Let’s update our IAM Role permission to allow our application to put objects in the S3 bucket. Looking at the <a href="https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazons3.html#amazons3-actions-as-permissions">Amazon S3 actions table</a>, we can use s3:PutObject to enable our application to send files to S3:</p><pre>AWSTemplateFormatVersion: 2010-09-09<br><br>Resources:<br>  # ...<br>  AppDevRole:<br>    # ...<br>      Policies:<br>        - PolicyName: ExampleRolePolicy<br>          PolicyDocument:<br>            Version: &quot;2012-10-17&quot;<br>            Statement:<br>              - Effect: Allow<br>                Action:<br>                  - s3:GetObject<br>                  - s3:PutObject #  You can add new action here like this!<br>                Resource: !Sub arn:aws:s3:::${ExampleBucket}/*</pre><h4>Conclusion</h4><p>AWS CloudFormation:</p><ul><li>Simplifies the creation</li><li>Usage and management of IAM Roles</li><li>Providing a streamlined approach to managing access control and permissions for your AWS resources.</li></ul><p>CloudFormation enables you to manage IAM roles over time through stack updates. If you need to modify the permissions or policies of an IAM role, you can update the CloudFormation template, and CloudFormation will handle the necessary updates during stack update operations.</p><p>To learn more about the CloudFormation, click <a href="https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/Welcome.html">here</a>.</p><p>Thank you so much for reading this article, I hope it has helped simplify the process of your case.</p><p>If you have any questions, please feel free to drop a comment or to write me on LinkedIn, and I’ll be happy to answer it for you.</p><p>If this article helped you out I’d appreciate you letting me know with a few claps or a follow on Medium, thank you.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=28bc776163b0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Finding Unused IAM Credentials (AWS Access Keys)]]></title>
            <link>https://cagrihankara.medium.com/finding-unused-iam-credentials-aws-access-keys-1ca56e323602?source=rss-ada54ac239e6------2</link>
            <guid isPermaLink="false">https://medium.com/p/1ca56e323602</guid>
            <category><![CDATA[security]]></category>
            <category><![CDATA[serverless]]></category>
            <category><![CDATA[cloud]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[lambda]]></category>
            <dc:creator><![CDATA[Cagrihankara]]></dc:creator>
            <pubDate>Sat, 25 Mar 2023 19:17:13 GMT</pubDate>
            <atom:updated>2023-03-25T19:17:13.667Z</atom:updated>
            <content:encoded><![CDATA[<p>To increase the security of our AWS account, we need to update IAM user credentials (passwords and access keys) sooner rather than later that are not needed anymore. Updating or removing unused credentials is one of the best practices for IAM. In this article, we will see how to find unused credentials and notify users(admin).</p><blockquote><strong><em>The definition of unused can change and in this article it means a credential that has not been used within a specified period of time.</em></strong></blockquote><p>We will schedule a lambda function using AWS CloudWatch to be invoked periodically. Lambda function will list all the user credentials and will check last used time of credentials and if last used time is more than 45 days, it will notify users with SNS.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PfKOG-7jD_gjlqHBx5mYXw.png" /><figcaption>Architecture</figcaption></figure><p>1- First we will create a Lambda function.</p><p>You can see how to create Lambda function in <a href="https://docs.aws.amazon.com/lambda/latest/dg/getting-started.html">here</a>.</p><p>2- In addition to Lambda function policy we created with Lambda, we will attach following permissions to newly created IAM role.</p><pre>{<br>    &quot;Effect&quot;: &quot;Allow&quot;,<br>    &quot;Action&quot;: [<br>        &quot;iam:ListUsers&quot;,<br>        &quot;iam:ListAccessKeys&quot;,<br>        &quot;iam:GetAccessKeyLastUsed&quot;,<br>        &quot;iam:DeleteAccessKey&quot;,<br>        &quot;iam:DeleteLoginProfile&quot;,<br>        &quot;iam:DeleteUser&quot;<br>    ],<br>    &quot;Resource&quot;: [<br>        &quot;*&quot;<br>    ]<br>}</pre><p>3. We will write our Lambda function code.</p><blockquote>We assume we already have SNS topic and subscription as email and we are going to use in our Lambda function.</blockquote><pre>import json<br>import boto3<br>from datetime import datetime<br>from datetime import timedelta<br>from botocore.exceptions import ClientError<br><br>list_users_to_notify = []<br>list_access_keys_to_notify = []<br>date_now = datetime.now()<br>iam_client = boto3.client(&#39;iam&#39;)<br>sns_client = boto3.client(&#39;sns&#39;)<br>max_idle_days = 45<br>max_items = 50<br><br><br>def lambda_handler(event, context):<br>    <br>    #Retrieve list of users using list_users() method<br>    try:<br>        res_users = iam_client.list_users(<br>            MaxItems=max_items<br>        )<br>        #call a custom function check_credentials() which will check last used time for the given user<br>        check_credentials(res_users)<br>    except ClientError as error:<br>        print(&#39;An error occurred while fetching user list.&#39;, error)<br>        return<br><br>    #We will use pagination using MaxItems, Marker and IsTruncated parameters, because there can be many users<br>    if res_users[&#39;IsTruncated&#39;]:<br>        while res_users[&#39;IsTruncated&#39;]:<br>            marker = res_users[&#39;Marker&#39;]<br>            try:<br>                res_users = iam_client.list_users(<br>                    Marker=marker,<br>                    MaxItems=max_items<br>                )<br>                check_credentials(res_users)<br>            except ClientError as error:<br>                print(&#39;An error occurred while fetching user list.&#39;, error)<br>                return<br>    <br>    return list_access_keys_to_notify<br><br><br>def check_credentials(res_users):<br>    created_date = datetime.now()<br>    last_used_date = datetime.now()<br>    access_key_id = None<br><br>    for user in res_users[&#39;Users&#39;]:<br><br>        # Below we are checking for access keys last usage<br>        try:<br>            res_keys = iam_client.list_access_keys(<br>                UserName=user[&#39;UserName&#39;],<br>                MaxItems=2)<br><br>            if &#39;AccessKeyMetadata&#39; in res_keys:<br>                for key in res_keys[&#39;AccessKeyMetadata&#39;]:<br>                    if &#39;CreateDate&#39; in key:<br>                        created_date = res_keys[&#39;AccessKeyMetadata&#39;][0][&#39;CreateDate&#39;].replace(tzinfo=None)<br>                    if &#39;AccessKeyId&#39; in key:<br>                        access_key_id = key[&#39;AccessKeyId&#39;]<br>                        res_last_used_key = iam_client.get_access_key_last_used(<br>                            AccessKeyId=access_key_id)<br>                        if &#39;LastUsedDate&#39; in key:<br>                            last_used_date = res_last_used_key[&#39;AccessKeyLastUsed&#39;][&#39;LastUsedDate&#39;].replace(tzinfo=None)<br>                        else:<br>                            last_used_date = created_date<br>                difference = date_now - last_used_date<br><br>                if difference.days &gt; max_idle_days:<br>                    response = sns_client.publish(<br>                        TopicArn=&#39;&lt;YourSNSTopicARN&#39;,<br>                        Message=&#39;Ensure credentials unused for 45 days or greater are updated for user: &quot;{0}&quot;. It is recommended that all credentials that have been unused in 45 or greater days be deactivated or removed. If we will use, we should update our access key.&#39;.format(user[&#39;UserName&#39;]),<br>                        Subject=&#39;Access keys need to be updated&#39;,<br>                        MessageStructure=&#39;string&#39;<br>                    )<br>                    list_access_keys_to_notify.append(access_key_id)<br><br>        except ClientError as error:<br>            print(&#39;An error occurred while listing access keys&#39;, error)<br>            return</pre><p>4- Next, we will schedule our Lambda function using Amazon EventBridge rule. As shown below, create a EventBridge scheduled rule to invoke our Lambda function periodically every day at 10 AM UTC.</p><blockquote><em>Select EventBridge service in AWS Console →Click on Rules →Create Rule</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6YpBk6tIK8aAWvKVTOP98A.png" /></figure><blockquote><em>Enter your rule name and description. Select “Schedule” in “Rule type” and next</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VtaTTdaeJKiH681QbRL14Q.png" /></figure><blockquote><em>Select schedule pattern and Cron expression as (0 10 * * ? *)</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m2-cGP-v3JYuCfvY3hFfdw.png" /></figure><blockquote><em>Select AWS service and Lambda function as target → Choose your Lambda function</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wQIxInjzT9sLReWPLOMkhA.png" /></figure><p>Thank you so much for reading this article, I hope it has helped simplify the process of your case.</p><p>If you have any questions, please feel free to drop a comment or to write me on LinkedIn, and I’ll be happy to answer it for you.</p><p>If this article helped you out I’d appreciate you letting me know with a few claps or a follow on Medium, thank you.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1ca56e323602" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introduction to AWS Cloud Development Kit]]></title>
            <link>https://medium.com/purplebox/introduction-to-aws-cloud-development-kit-64c1569162bd?source=rss-ada54ac239e6------2</link>
            <guid isPermaLink="false">https://medium.com/p/64c1569162bd</guid>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[cloudformation]]></category>
            <dc:creator><![CDATA[Cagrihankara]]></dc:creator>
            <pubDate>Thu, 16 Mar 2023 10:28:30 GMT</pubDate>
            <atom:updated>2023-03-16T10:28:30.331Z</atom:updated>
            <content:encoded><![CDATA[<h3>What is AWS CDK (Cloud Development Kit)?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*GInQ5Rzyza6hFOKu" /></figure><p>AWS CDK is an open-source framework that lets you model and provision AWS cloud resources using the programming language of your choice. It enables you to model application infrastructure using TypeScript, Python, Java, or .NET. Behind the scenes, it uses <a href="https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/Welcome.html">AWS CloudFormation</a> to provision resources in a safe and repeatable manner.</p><p>You may have to do manual processes or write special scripts while creating your resources and it can be longer. AWS CDK allows you to use a programming language you know and use the power of that language when creating these resources. Let’s start to use AWS CDK together!</p><h3>AWS CDK Concepts</h3><p>AWS CDK consists of 3 major building blocks:</p><ul><li><a href="https://docs.aws.amazon.com/cdk/v2/guide/apps.html">App</a> — is the root of your construct tree and consolidates all stacks and constructs in one application that can then be used to deploy on AWS Cloud.</li><li><a href="https://docs.aws.amazon.com/cdk/v2/guide/stacks.html">Stack</a> — is similar to a CloudFormation stack. It’s a template that holds the AWS resources in the form of constructs and can be used for deployment.</li><li><a href="https://docs.aws.amazon.com/cdk/v2/guide/constructs.html">Construct</a> — is the basic building block that can contain a single AWS resource or multiple AWS resources combined. You’re free to build and combine AWS resources in your own constructs.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/996/0*mx_RFqzsOu6FrCmQ" /></figure><p>When an AWS CDK application is synthesized, the result is a <a href="https://docs.aws.amazon.com/cdk/v2/guide/apps.html#apps_cloud_assembly">cloud assembly</a>, which contains the generated AWS CloudFormation templates for your stacks including the assets of your application. This package can then be deployed by the <a href="https://docs.aws.amazon.com/cdk/v2/guide/cli.html">AWS CDK CLI</a> to your preferred AWS account and region.</p><h3>Advantages of AWS CDK</h3><p><strong>* Powered by AWS CloudFormation:</strong> AWS CDK allows you to define your resources with code and provision them through AWS CloudFormation. You get all the benefits of CloudFormation. Deployment, rollback, etc.</p><p><strong>* Faster development process:</strong> With AWS CDK, you can use the power of programming language to create resources. Familiar features such as objects, loops, and conditions speed up your development process. In addition, you can develop resources using the AWS CDK in any IDE you want.</p><p><strong>* Customize, share, and reuse constructs:</strong> With AWS CDK, you can customize, share, and reuse constructs within your team. This helps you to build constructs and helps you and your teammates get started faster.</p><p><strong>* No context switching: </strong>AWS CDK allows you to build your cloud application on AWS without leaving the ide environment you are using. Write your runtime code and define your AWS resources with the same programming language.</p><h3>Demo with AWS CDK</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*x26Iu8YvAP_XX1Bw" /></figure><p><strong>Scenario:</strong> We have a developer who wants to be notified when a user uploads a specific file type to a specific AWS S3 bucket. They also want to save the file name to the database. How can we design this project?</p><p><strong>Solution:</strong> We will build a CDK app that consists of S3-triggered AWS Lambda and SNS Topic created by AWS CDK. When an object is put in the AWS S3 bucket, the AWS Lambda function will be triggered and writes the name of the object to the AWS DynamoDB table and then notify the action developer via email.</p><h3>Step 1: How to install and configure AWS CDK?</h3><p><em>Prerequisites: </em>AWS CLI<em>, </em>AWS Account and User<em>, </em>Node.js<em>, </em>IDE for your programming language<em>, </em>AWS CDK Toolkit<em>, </em>your programming language (Python, Java, Go, etc.)</p><p>In our demo, Python is going to be our programming language.</p><p><em>Note: Node.js is always required to use CDK, but all other language prerequisites are only required if building a CDK app in that language.</em></p><p>Install the AWS CDK Toolkit globally using the following Node Package Manager command:</p><pre>npm install -g aws-cdk</pre><p>Run the following command to verify the correct installation and print the version number of the AWS CDK.</p><pre>cdk –version</pre><pre>Alternative: npx aws-cdk –version</pre><p><em>Tip: Alternative means, normally you can check only cdk command because you installed globally. If it does not work you can use “npx aws-cdk ….” commands for your local.</em></p><h3>Step 2: Creating Project — CDK App</h3><p>Each AWS CDK app should be in in its own directory, with its own local module dependencies. You can start with your home directory or what you want. Open your CMD and create your project folder:</p><pre>mkdir s3-trigger-lambda-project</pre><pre>cd s3-trigger-lambda-project</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1015/0*kKgpMjtgikqa1MVw" /></figure><p>Start the application with the “cdk init” command:</p><pre>cdk init app — language python</pre><pre>Alternative: npx aws-cdk init app — language python</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1017/0*rEjVx0UXF03q9E7L" /></figure><p>Tip: If you received a message like “Unable to initialize git repository for your project.” Then follow this:</p><pre>python -m venv .venv</pre><p>After the app has been created, to activate the app’s Python virtual environment follow this command:</p><pre>source .venv/bin/activate</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1014/0*wwHkENvuupNQk-TN" /></figure><p>Install the AWS CDK core dependencies:</p><pre>python -m pip install -r requirements.txt</pre><p>You can list stacks in your app:</p><pre>cdk ls</pre><pre>Alternative: npx aws-cdk ls</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*mtNNLtBeNonGEIvs" /></figure><p><em>Tip: If you receive “The security token included in the request is expired”, you need to configure your AWS account.</em></p><h3>Step 3: Create the application code</h3><p>Open your s3-trigger-lambda-project/s3_trigger_lambda_project/s3_trigger_lambda_project_stack.py file.</p><p>Import what we need for our application to create resources.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*gqhnHFjkmt2O1QQG" /></figure><p>Create new IAM group and IAM user.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/873/0*Avm7Zzob0Pvh5dng" /></figure><p>Add IAM user to the group.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/874/0*EDEctPH2y6mH4WJF" /></figure><p>The following code snippet can be used to create an S3 bucket. In this example, we are using the grand_read_write command to give permisson for AWS Lambda and user.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/874/0*HggWuVUyCawgaFmF" /></figure><p>The following code snippet can be used to create a DynamoDB table.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*-4U3gpo6v6klmjXB" /></figure><p>The following code snippet can be used to create a SNS topic and an email subscription for this topic.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/973/0*GLn3a0l7dt5cDKAt" /></figure><p>The following code snippet can be used to create an S3 bucke. In this example, we are using the environment variables to use in AWS Lambda function.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Lv1dk0itceSZOZTY" /></figure><p>In this step, our code path should be AWS Lambda handler path or our lambda.zip address.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/345/0*TVPWxgELKCcg15V2" /></figure><p>We are using the grand_read_write command to give permission for AWS Lambda and using grand_publish to publish our message from AWS Lambda.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*uDZ1r-rlWcUdgTm4" /></figure><p>The following code snippet can be used to create S3 trigger for AWS Lambda function.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*4ASeQW8S5HUiir-Y" /></figure><p>The following code snippet can be used to create event only for .jpg files.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*nlk9-VzIvGkRwIiR" /></figure><p>The following code is our AWS Lambda function.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/714/0*2BqZVUwmTzK8B8fg" /></figure><h3>Step 4: Build and Deploy Application</h3><p>Synthesize an AWS CloudFormation Template: You need to run this command to create AWS CloudFormation template from AWS CDK stack in your project path:</p><pre>cdk synth</pre><pre>Alternative: npx aws-cdk synth</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*1cz9Q6YrhbST22Qq" /></figure><p>For building application step, you need to use this command:</p><pre>cdk bootstrap</pre><pre>Alternative: npx aws-cdk bootstrap</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*yGDvTSOG52x7mz6r" /></figure><p>For deploying the stack:</p><pre>cdk deploy</pre><pre>Alternative: npx aws-cdk deploy</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Lfwaxv6l_F5Qd_7T" /></figure><h3>Step 5: Test the Application</h3><p>To test the application, you need to upload a file to the S3 bucket from AWS Console or CLI. Then you need to check your email. You should see something like the below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*2MHYVwatNCNt3XSr" /></figure><p>Besides, you should check the DynamoDB table whether the photo name is written.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1016/0*-tdutMj2uBiUCcZV" /></figure><h3>Conclusion</h3><p>In this blog, you have learned what the AWS CDK is and how it can build your project. You’ve read about how the AWS CDK stacks on AWS CloudFormation and what advantages and features it has when you want to use the AWS CDK. Overall, we can say that AWS CDK will create a new bridge between infrastructure and DevOps, enabling infrastructure definitions in many programming languages such as Python, Java, Go, etc. You can access all demo code from <a href="https://github.com/PBCLOUD/prplbx-blog-codes/tree/main/prplbx-sample-aws-cdk-template">here</a>.</p><p>We hope you found our blog post useful. Don’t forget to check out our DevSecOps services! If you want to read more on this topic, feel free to check out the PurpleBox Blog Section.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=64c1569162bd" width="1" height="1" alt=""><hr><p><a href="https://medium.com/purplebox/introduction-to-aws-cloud-development-kit-64c1569162bd">Introduction to AWS Cloud Development Kit</a> was originally published in <a href="https://medium.com/purplebox">PurpleBox Security</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Visualize the AWS Cost and Usage Report (CUR) into Amazon QuickSight]]></title>
            <link>https://cagrihankara.medium.com/visualize-the-aws-cost-and-usage-report-cur-into-amazon-quicksight-6de22d6b9a50?source=rss-ada54ac239e6------2</link>
            <guid isPermaLink="false">https://medium.com/p/6de22d6b9a50</guid>
            <category><![CDATA[amazon-quicksight]]></category>
            <category><![CDATA[aws-quicksight]]></category>
            <category><![CDATA[cloud]]></category>
            <category><![CDATA[data-visualization]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Cagrihankara]]></dc:creator>
            <pubDate>Wed, 11 Jan 2023 11:18:52 GMT</pubDate>
            <atom:updated>2023-01-11T11:36:39.300Z</atom:updated>
            <content:encoded><![CDATA[<p>You need to require better visibility into your AWS usage to help them understand the return on your investment, achieve operational efficiency, and make business decisions that have financial impact. There may be some questions within your organization that need to be answered:</p><ul><li>Which key areas should I focus to optimize my AWS usage and costs?</li><li>How do I track the impact of my cost optimization on my business?</li><li>How do I gain resource level granularity of the AWS services my workloads use?</li></ul><p>You have access to raw cost and usage data through the AWS Cost and Usage (AWS CUR) reports. These reports contain the most comprehensive information about your AWS usage and costs. Financial teams need this data so they have an overview of their monthly, quarterly, and yearly AWS spend, but this data is equally valuable for technical teams who need detailed resource-level granularity to understand which resources are contributing to the spend. AWS Cost Explorer provides a high-level view of costs and usage, using the same dataset that is used to generate the AWS Cost and Usage Reports.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hMrFA6ZiyVbEDwJBJ76aNQ.png" /><figcaption>Architecture of Visualizing AWS Cost and Usage Reports with Amazon QuickSight</figcaption></figure><p><strong>Resolution</strong></p><p>You can ingest and visualize your AWS Cost and Usage Report (CUR) by doing the following:</p><p>1. Create a Cost and Usage Report</p><p>2. Setting up Athena (Cloud formation template)</p><p>3. Setting up IAM policy for QuickSight to access AWS services, in here Amazon Athena</p><p>4. Open the QuickSight console</p><p>5. Setting up QuickSight permissions</p><p>6. Choose Datasets from QuickSight console and choose New Data Set</p><p>7. Choose Athena. This opens the Amazon Athena workgroup and create data source</p><p>8. Create Analyses</p><p>9. Publish your Dashboard</p><h3><strong>Let’s get started</strong></h3><h3><strong>1. Create a Cost and Usage Report</strong></h3><p>You can use the <strong>Cost &amp; Usage Reports</strong> page of the Billing and Cost Management console to create Cost and Usage Reports.</p><p><strong>To create Cost and Usage Reports</strong></p><p>1.<strong> </strong>Sign into the Billing and Cost Management console at <a href="http://console.aws.amazon.com/billing">https://console.aws.amazon.com/billing/home#/</a></p><p>2. On the navigation pane, choose <strong>Cost &amp; Usage Reports</strong>.</p><p>3. Choose <strong>Create report</strong>.</p><p>4. For <strong>Report name</strong>, enter a name for your report.</p><p>5. For <strong>Additional report details</strong>, select <strong>Include resource IDs</strong> to include the IDs of each individual resource in the report.</p><p>6. For <strong>Data refresh settings</strong>, select whether you want the AWS Cost and Usage Reports to refresh if AWS applies refunds, credits, or support fees to your account after finalizing your bill. When a report refreshes, a new report is uploaded to Amazon S3.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/623/1*EetASuH0pMCHcXdzGL1gsQ.png" /></figure><p>7. Choose <strong>Next</strong>.</p><p>8. For <strong>S3 bucket</strong>, choose <strong>Configure</strong>.</p><p>9. In the <strong>Configure S3 Bucket</strong> dialog box, do one of the following:</p><ul><li>Select an existing bucket from the drop-down list and choose <strong>Next</strong>.</li><li>Enter a bucket name and the Region where you want to create a new bucket and choose <strong>Next</strong>.</li></ul><p>10. Review the bucket policy and select <strong>I have confirmed that this policy is correct</strong> and choose <strong>Save</strong>.</p><p>11. For <strong>Report path prefix</strong>, enter the report path prefix that you want prepended to the name of your report.</p><p>12. For <strong>Time granularity</strong>, choose one of the following:</p><ul><li><strong>Hourly</strong> if you want the line items in the report to be aggregated by the hour.</li><li><strong>Daily</strong> if you want the line items in the report to be aggregated by the day.</li><li><strong>Monthly</strong> if you want the line items in the report to be aggregated by month.</li></ul><p>13. For <strong>Report versioning</strong>, skip this because it will be selected after you choose Amazon Athena.</p><p>14. For <strong>Enable report data integration for</strong>, Amazon Athena<strong>.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/626/1*48oih24aMBC8ppz3spEpOA.png" /></figure><p>15. Choose <strong>Next</strong>.</p><p>16. After you have reviewed the settings for your report, choose <strong>Review and Complete</strong>.</p><h3><strong>2. Setting up Athena (Cloud formation template)</strong></h3><p>Now you need to setup Athena using a CloudFormation template. Which is ready in your CUR bucket as a crawler.yaml. This template contains the necessary information to create the resources in Athena, Glue, S3 services.</p><p>First, you need to take Object URL for YAML file in S3 Bucket that you created for Cost and Usage Reports.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8ju6O11HYxHG8SSifRlSJw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9ZDhZpvjO8kyjy7exDZXPQ.png" /></figure><p>Go to CloudFormation console and click on select “Create New Stack” with new resources. Enter the Object URL.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*E0bnlM3jfs5GHYBWRRJjTg.png" /></figure><p>After created stack, all resources you need will be ready to use.</p><blockquote>Note: If you have not use Amazon Athena and it has not query result location, you need to set up this before go to Quicksight. Go to Amazon Athena console and select settings.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YGe5fM_uCfXfm0mi2WE0xg.png" /></figure><blockquote>Note: If you are not using the bucket in a different account, you can follow this. But if you use crawler.yaml in a different account, you need to change the bucket names in this template.</blockquote><h3><strong>3. Setting up IAM policy for QuickSight to access AWS services</strong></h3><p>Go to IAM console and select roles. Search for QuickSight role and select. Add AWSQuicksightAthenaAccess policy which is AWS-managed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LsUpC1nH__ghEFujnnsoaQ.png" /></figure><blockquote>Note: If you need AWSQuickSighS3Policy and AWSQuickSightIAMPolicy, you can add like pictures in the below.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/862/1*ZsGNb_ggUdodR_WRrSYSxg.png" /><figcaption>AWSQuickSightIAMPolicy</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/887/1*xdLevrcsfHbgQmIVWeVVmg.png" /><figcaption>AWSQuickSightS3Policy</figcaption></figure><h3><strong>4. Open the QuickSight console</strong></h3><p>If you have not use QuickSight before, you should open and login with AWS user, etc.</p><h3><strong>5. Setting up QuickSight permissions</strong></h3><p>From the QuickSight home page, select Manage QuickSight.</p><p>Next, click on Security &amp; Permissions from the left-hand side menu and then click on the Manage AWS permissions button to give access to Athena as shown in the screenshot here:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yxBRhbCNWx-cTi0grm-ybg.png" /></figure><h3><strong>6. Choose Datasets from QuickSight console and choose New Data Set</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1XCYfTlH47Z2BYR3j22_vA.png" /></figure><h3><strong>7. Choose Athena. This opens the Amazon Athena workgroup and create data source</strong></h3><p>Choose Athena.</p><p>Enter a data source name and choose your workgroup (if you don’t create workgroup, default is primary ) and validate connection.</p><p>Create data source.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5PSKQM27ardnXhiFygOBAQ.png" /></figure><p>Select your Athena database as database, choose your bucket name as a table to visualize data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CIoEVx1eGz-sR-iCEJ5p4g.png" /></figure><h3><strong>8. Create Analyses</strong></h3><p>After created dataset, you can continue with analyses. On the left panel, choose analyses tab and continue with the create “New analysis” button.</p><blockquote>Note: All graphics and analyses are up to you in this section. There is one example picture in the below. In this example, we selected two fields on_demand cost and usage_start_date. We selected KPI as visual type. We can see the daily cost difference thanks to this example.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FA_stQ3jOBgKaWsuRSGaAg.png" /></figure><p>After finish analyses, you can share our analyses as dashboard.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/258/1*WwMXK_5AW6V6xqzFyRc8xg.png" /></figure><h3><strong>9. Publish Dashboard</strong></h3><p>Go to QuickSight Dashboards and open dashboard that you want to share.</p><p>You can share your dashboard with AWS users on the right top share button.</p><p>You can create a schedule and send email to whoever you want. For instance, if you want to send email daily, you can create a schedule like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/538/1*gA5ABlDAzefWtndA-ksfxQ.png" /></figure><p>You should enter your information to other places like email, schedule name, timezone, etc.</p><p>Here an example of email template:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*xmy-K0r795lxkaYRh3Y39A.png" /></figure><p><strong>References:</strong></p><blockquote><a href="https://docs.aws.amazon.com/quicksight/latest/user/welcome.html">https://docs.aws.amazon.com/quicksight/latest/user/welcome.html</a></blockquote><blockquote><a href="https://aws.amazon.com/premiumsupport/knowledge-center/quicksight-cost-usage-report/">https://aws.amazon.com/premiumsupport/knowledge-center/quicksight-cost-usage-report/</a></blockquote><p>Thank you so much for reading this article, I hope it has helped simplify the process of your case.</p><p>If you have any questions, please feel free to drop a comment or to write me on LinkedIn, and I’ll be happy to answer it for you.</p><p>If this article helped you out I’d appreciate you letting me know with a few claps or a follow on Medium, thank you.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6de22d6b9a50" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AWS S3 Cross-Account Replication]]></title>
            <link>https://cagrihankara.medium.com/aws-s3-cross-account-replication-124841da9d4c?source=rss-ada54ac239e6------2</link>
            <guid isPermaLink="false">https://medium.com/p/124841da9d4c</guid>
            <category><![CDATA[cloud]]></category>
            <category><![CDATA[s3]]></category>
            <category><![CDATA[s3-bucket]]></category>
            <category><![CDATA[replication]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Cagrihankara]]></dc:creator>
            <pubDate>Sat, 07 Jan 2023 15:28:54 GMT</pubDate>
            <atom:updated>2023-01-07T15:28:54.162Z</atom:updated>
            <content:encoded><![CDATA[<p>S3 Cross Account Replication refers to copying the contents of the S3 bucket from one account to another S3 bucket in a different account. Its possible that both the accounts may or may not be owned by the same individual or organization.</p><p><strong>Prerequisites</strong></p><p>1. Create the following S3 buckets in their respective account:</p><blockquote>“source-bucket” in AWS account A</blockquote><blockquote>“destination bucket” in AWS account B</blockquote><p>2. All the buckets — source and destination should have ‘Bucket Versioning’ enabled (This can be set at the time of bucket creation)</p><p><strong>Replication Steps</strong></p><ol><li>In the source bucket we will create a Replication Rule on Bucket Management tab with the following settings:</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/780/1*abrb7eb1DJo5u0_NIWi-bQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/564/1*8JWtFKmjZf0W3BUfbpmBqg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/642/1*5-CQxk9tVo8dVSW2MRodIA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/591/1*ftdqD_EMMKTZkAycfhAgBg.png" /></figure><p>2. You should update source bucket policy:</p><p>This policy allows the destination bucket in account B to list and get objects from the source bucket in account A.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/780/1*uEpHwXjQbgMJ9CwaZyEALA.png" /></figure><p>3. Create a role for cross account replication in the source account</p><ul><li>Navigate to IAM console in the ‘Data’ account (Account A)</li><li>Create a policy. Allows to list and get objects from source and destination buckets. Provide a name to the policy (say ‘cross-account-bucket-replication-policy’) and add policy contents based on the below syntax:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/780/1*_lsAGrbGtFxIKN-5UNfrng.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/847/1*_lnDRjJuG-_W3oC99Sv4SQ.png" /></figure><p>4. You should update destination bucket policy:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/780/1*eGoYxU-sfbvyzrTl7XOZfg.png" /></figure><p>5. If we look at two buckets after replication;</p><p>Bucket in source bucket (account A):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/779/1*4dFVjaeErvo0gQf_j7ioWw.png" /></figure><p>Bucket in destination bucket (account B):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/788/1*CNDx7Wvd1BqfoZOLIkuR5A.png" /></figure><p>Thank you so much for reading this article, I hope it has helped simplify the process of your case.</p><p>If you have any questions, please feel free to drop a comment or to write me on LinkedIn, and I’ll be happy to answer it for you.</p><p>If this article helped you out I’d appreciate you letting me know with a few claps or a follow on Medium, thank you.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=124841da9d4c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Enable CloudWatch Logs for API Gateway]]></title>
            <link>https://cagrihankara.medium.com/how-to-enable-cloudwatch-logs-for-api-gateway-d36c55c50e56?source=rss-ada54ac239e6------2</link>
            <guid isPermaLink="false">https://medium.com/p/d36c55c50e56</guid>
            <category><![CDATA[cloudwatch]]></category>
            <category><![CDATA[cloud]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[logging]]></category>
            <category><![CDATA[api-gateway]]></category>
            <dc:creator><![CDATA[Cagrihankara]]></dc:creator>
            <pubDate>Sat, 07 Jan 2023 14:51:29 GMT</pubDate>
            <atom:updated>2023-01-07T15:58:34.605Z</atom:updated>
            <content:encoded><![CDATA[<h4>How to set up an alarm that particularly monitors throttling (429 — Too many requests) of an AWS API Gateway API?</h4><p>You can monitor API Gateway API by using CloudWatch. CloudWatch collects and processes data from API Gateway into readable, near-real-time metrics. These statistics are recorded for a period of 15 months so you can access historical information and gain a better perspective on how your web application or service is performing. By default, API Gateway metric data is automatically sent to CloudWatch in one-minute periods.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ERMQp7z8fVet19rPePug8Q.png" /><figcaption>Architecture of “Enabling CloudWatch Logs for API Gateway”</figcaption></figure><blockquote><strong>Note:</strong> For status 429, you should enable throttling in API Gateway console like this:</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/780/1*UhDew_yoXgUy90QYW8AU4g.png" /></figure><p>Now we will explain how you can turn on CloudWatch logs for API Gateway REST APIs and we will set up an alarm for throttling with CloudWatch metrics.</p><ol><li><strong>Create Role</strong></li></ol><p>Go to IAM console and choose role section. Select Create Role and select API Gateway as AWS Service.</p><p>By default, you will see AmazonAPIGatewayPushToCloudWatchLogs policy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/780/1*8TxPXgwBDPubSE2EtHkDaA.png" /><figcaption>Role with AmazonAPIGatewayPushToCloudWatchLogs Policy</figcaption></figure><p>Next, enter your role name and create your role.</p><p>Copy your role ARN and continue with next step.</p><p><strong>2. Provide an IAM Role for Your API Gateway Service</strong></p><p>Go to API Gateway console and choose API settings.</p><p>Paste your role ARN you copied step-1.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/779/1*axVppspo5CuchOmr1PcAlA.png" /></figure><p><strong>3. Enable CloudWatch Logs</strong></p><p>Go to stages section and choose your stage you want to enable logs.</p><p>Choose Logs/Tracing tab and select boxes like picture right below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/779/1*E7vmx9T7akORUa-8jESG6A.png" /></figure><blockquote>When you deploy an API, API Gateway creates a log group and log streams under the log group. The log group is named following the API-Gateway-Execution-Logs_{rest-api-id}/{stage_name} format.</blockquote><blockquote>In access logging, you, as an API developer, want to log who has accessed your API and how the caller accessed the API. You can create your own log group or choose an existing log group that could be managed by API Gateway. To specify the access details, you select <a href="https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-mapping-template-reference.html#context-variable-reference">$context</a> variables (expressed in a format of your choosing) and choose a log group as the destination.</blockquote><p><strong>4. Create Metric and Set Up Alarm</strong></p><ul><li>Go to CloudWatch console and choose your log group.</li><li>Choose Metric filters tab and create metric.</li><li>Enter your pattern what you want, but in here we will set alarm for status 429.</li><li>So we will enter Filter pattern like this:</li></ul><p>{ $.status = “429” }</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yXsICEpeQAqGSZvaqeIuVw.png" /></figure><ul><li>Then enter other informations such as name and etc. Metric value is will be 1 for our case.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*b-d8Nxxbix0imIZljAeNWA.png" /></figure><blockquote>Metric Value: The numerical value to publish to the metric each time a matching log is found. For example, if you’re counting the occurrences of a particular term like “Error”, the value will be “1” for each occurrence. If you’re counting the bytes transferred, you can increment by the actual number of bytes found in the log event.</blockquote><ul><li>Go to Alarms section and create alarm.</li><li>Choose metric you created and enter other informations like picture right below to get notify when this error occurred every time.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/686/1*plllPbmYQhExfw515kiFRQ.png" /></figure><ul><li>The next step, you can choose your SNS topic or you can create new one. This is how you get notification for alarm. Email, SMS, etc.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EX_YuKt-f8hmK2iM4syG6A.png" /></figure><p>Now you can go to CloudWatch service and click your log group to view logs.</p><p>Thank you so much for reading this article, I hope it has helped simplify the process of your case.</p><p>If you have any questions, please feel free to drop a comment or to write me on LinkedIn, and I’ll be happy to answer it for you.</p><p>If this article helped you out I’d appreciate you letting me know with a few claps or a follow on Medium, thank you.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d36c55c50e56" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>