<?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 Pooja Shrestha on Medium]]></title>
        <description><![CDATA[Stories by Pooja Shrestha on Medium]]></description>
        <link>https://medium.com/@pooja_shrestha?source=rss-5ce4611115dc------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*J0S-iA9x5YrYtJ0rjGm-Pg.jpeg</url>
            <title>Stories by Pooja Shrestha on Medium</title>
            <link>https://medium.com/@pooja_shrestha?source=rss-5ce4611115dc------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 14:22:45 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@pooja_shrestha/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[Resume Data Extraction Using AWS AI Services]]></title>
            <link>https://awstip.com/resume-data-extraction-using-aws-ai-services-6fde69a351c8?source=rss-5ce4611115dc------2</link>
            <guid isPermaLink="false">https://medium.com/p/6fde69a351c8</guid>
            <category><![CDATA[aws-lambda]]></category>
            <category><![CDATA[aws-textract]]></category>
            <category><![CDATA[aws-comprehend]]></category>
            <category><![CDATA[dynamodb]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Pooja Shrestha]]></dc:creator>
            <pubDate>Thu, 25 Dec 2025 19:54:51 GMT</pubDate>
            <atom:updated>2025-12-30T12:13:44.414Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iee6OmY3W3O_TcAM5bi--w.png" /><figcaption>Generated with Google Gemini</figcaption></figure><p>If you have been applying for jobs on company sites or job portals, you might have used the option where, if we upload our resume, the fields are automatically filled. The feature has been such that, if the option is not there on some portals, it comes off as an inconvenience. Now imagine a recruiter trying to manage data from hundreds of resumes.</p><p>Extracting data from resumes is a very time-consuming task when done manually. With AWS, we can build a resume parsing pipeline using fully managed services. In this blog, we will build a simple resume parser that, when provided a resume, returns the values for the specified fields.</p><p>Services used:</p><ol><li>S3</li><li>Lambda</li><li>Textract</li><li>Comprehend</li><li>DynamoDB</li></ol><p>Here is the architecture of the system:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LhnfJzONWml2a96rrGSswQ.png" /></figure><p><strong>Step 1: Create an S3 bucket for storing the resumes</strong></p><ul><li>Go to S3 and create a bucket with a unique name.</li><li>Enable “Block all public access”.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_E0gWwgDrnHabynbk5LTiQ.png" /></figure><p><strong>Step 2: Create a DynamoDB table to store the resume data</strong></p><ul><li>Enter ‘ResumeID’ as a partition key while creating the table.</li><li>Enter ‘Name’ as a Sort key (optional).</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zN4ATEdSj7hgQQxTFH3yMQ.png" /></figure><p><strong>Step 3: Create an IAM Role for Lambda</strong></p><ul><li>Go to IAM. Select Roles and then Create Role.</li><li>Select Lambda in the use case, as we are attaching this role to a Lambda. Attach the following policies:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*k88HjGdB2H0uAVXosLYB1A.png" /></figure><p>The custom policy is as:</p><pre>{<br>    &quot;Version&quot;: &quot;2012-10-17&quot;,<br>    &quot;Statement&quot;: [<br>        {<br>            &quot;Sid&quot;: &quot;Statement1&quot;,<br>            &quot;Effect&quot;: &quot;Allow&quot;,<br>            &quot;Action&quot;: [<br>                &quot;s3:GetObject&quot;<br>            ],<br>            &quot;Resource&quot;: &quot;*&quot;<br>        },<br>        {<br>            &quot;Sid&quot;: &quot;Statement2&quot;,<br>            &quot;Effect&quot;: &quot;Allow&quot;,<br>            &quot;Action&quot;: [<br>                &quot;textract:AnalyzeDocument&quot;,<br>                &quot;textract:DetectDocumentText&quot;<br>            ],<br>            &quot;Resource&quot;: &quot;*&quot;<br>        },<br>        {<br>            &quot;Sid&quot;: &quot;Statement3&quot;,<br>            &quot;Effect&quot;: &quot;Allow&quot;,<br>            &quot;Action&quot;: [<br>                &quot;comprehend:DetectEntities&quot;,<br>                &quot;comprehend:DetectKeyPhrases&quot;<br>            ],<br>            &quot;Resource&quot;: &quot;*&quot;<br>        },<br>        {<br>            &quot;Sid&quot;: &quot;Statement4&quot;,<br>            &quot;Effect&quot;: &quot;Allow&quot;,<br>            &quot;Action&quot;: [<br>                &quot;dynamodb:PutItem&quot;<br>            ],<br>            &quot;Resource&quot;: &quot;*&quot;<br>        }<br>    ]<br>}</pre><p>The policy above is a simple custom policy generated using the AWS Policy Generator. We can make several improvements to the policy, such as implementing a least-privilege approach.</p><p><strong>Step 4: Create a Lambda Function</strong></p><ul><li>Runtime — Python 3.12</li><li>Role: Role we created earlier</li></ul><pre>import boto3<br>import json<br>import uuid<br>import os<br>import logging<br>import urllib<br><br># Set up logging for better debugging in CloudWatch<br>logger = logging.getLogger()<br>logger.setLevel(logging.INFO)<br><br># Initialize clients outside the handler for connection reuse<br>s3 = boto3.client(&#39;s3&#39;)<br>textract = boto3.client(&#39;textract&#39;, region_name=&#39;us-east-1&#39;)<br>comprehend = boto3.client(&#39;comprehend&#39;)<br>dynamodb = boto3.resource(&#39;dynamodb&#39;)<br><br># Environment variables<br>TABLE_NAME = os.environ.get(&#39;TABLE_NAME&#39;, &#39;resumes&#39;)<br>table = dynamodb.Table(TABLE_NAME)<br><br>def lambda_handler(event, context):<br>    try:<br>        # Get uploaded file info<br>        bucket = event[&#39;Records&#39;][0][&#39;s3&#39;][&#39;bucket&#39;][&#39;name&#39;]<br>        raw_key = event[&#39;Records&#39;][0][&#39;s3&#39;][&#39;object&#39;][&#39;key&#39;]<br>    <br>        key = urllib.parse.unquote_plus(raw_key)<br>        logger.info(f&quot;Processing file: s3://{bucket}/{key}&quot;)<br><br>        # Validate file extension<br>        allowed_ext = (&#39;.pdf&#39;, &#39;.jpg&#39;, &#39;.jpeg&#39;, &#39;.png&#39;, &#39;.tiff&#39;)<br>        if not key.lower().endswith(allowed_ext):<br>            return {&quot;error&quot;: f&quot;Unsupported file extension: {key}&quot;}<br><br>        # Textract text extraction<br>        # Note: detect_document_text only works for single-page files (images/PDFs). <br>        # For multi-page PDFs, you&#39;d need start_document_analysis (asynchronous).<br><br>        logger.info(f&quot;Textract started&quot;)<br><br>        response = textract.detect_document_text(<br>            Document={&#39;S3Object&#39;: {&#39;Bucket&#39;: bucket, &#39;Name&#39;: key}}<br>        )<br><br>        full_text = &quot;&quot;<br>        for block in response.get(&quot;Blocks&quot;, []):<br>            if block[&quot;BlockType&quot;] == &quot;LINE&quot;:<br>                full_text += block[&quot;Text&quot;] + &quot; &quot;<br><br>        if not full_text.strip():<br>            return {&quot;error&quot;: &quot;No text extracted from document.&quot;}<br><br>        # NLP using Comprehend (Handle UTF-8 byte limit)<br><br><br>        logger.info(f&quot;Comprehend started&quot;) <br><br>        truncated_text = full_text.encode(&#39;utf-8&#39;)[:4900].decode(&#39;utf-8&#39;, &#39;ignore&#39;)<br>        <br>        entities_resp = comprehend.detect_entities(<br>            Text=truncated_text,<br>            LanguageCode=&#39;en&#39;<br>        )<br>        entities = entities_resp.get(&#39;Entities&#39;, [])<br><br>        logger.info(f&quot;Comprehend - keyphrase started&quot;)<br><br>        # Key phrase is optional. More details in the description<br>        key_phrases = comprehend.detect_key_phrases(<br>             Text=truncated_text,<br>             LanguageCode=&quot;en&quot;<br>         )[&quot;KeyPhrases&quot;]<br><br>        # Extract the text strings from the Comprehend response<br>        # Each phrase comes back as a dictionary; we just want the &#39;Text&#39;<br>        # Exclude if key_phrases is not used<br>        phrases_list = [phrase[&#39;Text&#39;] for phrase in key_phrases]<br><br>        # Extract fields using helper functions<br>        name = extract_name(entities)<br>        skills = extract_skills(full_text)<br>        experience_summary = extract_experience_summary(full_text)<br><br>        logger.info(f&quot;Helpers started&quot;)<br><br>        # Store in DynamoDB<br>        resume_id = str(uuid.uuid4())<br>        item = {<br>            &quot;ResumeID&quot;: resume_id,<br>            &quot;Name&quot;: name,<br>            &quot;Skills&quot;: skills,<br>            &quot;KeyConcepts&quot;: phrases_list, # exclude if key_phrases is not used<br>            &quot;ExperienceSummary&quot;: experience_summary,<br>            &quot;S3Key&quot;: key,<br>            &quot;ProcessedTimestamp&quot;: str(context.aws_request_id) # Useful for tracking<br>        }<br>        <br>        table.put_item(Item=item)<br>        logger.info(f&quot;Successfully processed {key} with ID {resume_id}&quot;)<br><br>        return {<br>            &quot;statusCode&quot;: 200,<br>            &quot;body&quot;: json.dumps({&quot;status&quot;: &quot;Success&quot;, &quot;ResumeID&quot;: resume_id, &quot;Name&quot;: name})<br>        }<br><br>    except Exception as e:<br>        logger.error(f&quot;Error: {str(e)}&quot;)<br>        return {&quot;statusCode&quot;: 500, &quot;body&quot;: json.dumps({&quot;error&quot;: str(e)})}<br><br># Helper functions<br><br>def extract_name(entities):<br>    for entity in entities:<br>        if entity[&#39;Type&#39;] == &#39;PERSON&#39; and entity[&#39;Score&#39;] &gt; 0.8:<br>            return entity[&#39;Text&#39;]<br>    return &quot;Name Not Found&quot;<br><br>def extract_skills(text):<br>    skill_keywords = [<br>        &quot;python&quot;, &quot;java&quot;, &quot;aws&quot;, &quot;docker&quot;, &quot;kubernetes&quot;, &quot;lambda&quot;, <br>        &quot;react&quot;, &quot;node&quot;, &quot;sql&quot;, &quot;git&quot;, &quot;ci/cd&quot;, &quot;javascript&quot;, &quot;c++&quot;<br>    ]<br>    text_lower = text.lower()<br>    found = [skill for skill in skill_keywords if skill in text_lower]<br>    return list(set(found))<br><br>def extract_experience_summary(text):<br>    text_lower = text.lower()<br>    start_idx = text_lower.find(&quot;experience&quot;)<br>    if start_idx == -1:<br>        return &quot;Experience section not explicitly found.&quot;<br>    <br>    # Return a snippet of the experience section<br>    return text[start_idx:start_idx+500].strip() + &quot;...&quot;</pre><p>Here, we have limited the type of files that will be accepted. Only files with the following extensions are supported: .pdf, .jpg, .jpeg, .png, and .tiff. After the file is accepted, Amazon Textract is called. Textract extracts the textual contents from the resume. The texts are beautified by the function. The raw outputs from the Textract can be viewed in CloudWatch. If the formatting is to be modified, the lambda function is where we go. If Textract fails to detect, it gives an error.</p><p>After the texts are extracted, Amazon Comprehend performs the processing on the data. Here, we have used logic with helper functions.</p><p>Regarding the key phrases in the function, if we aim for specific skills, explicitly mentioning them, as in the extract_skills function, is helpful. Otherwise, key phrases can be used. Key phrases, however, give us a lot more keywords than just skills, so we can filter the function accordingly for just the skill-related keywords.</p><p>While parsing the resumes, it may sometimes require a significant amount of processing time and even cause timeouts. In such cases, we need to increase the timeout period in Lambda and increase the memory for faster processing.</p><p><strong>Step 5: Add an S3 event trigger to automate the Lambda run</strong></p><ul><li>Go to your S3 bucket</li><li>Go to Properties</li><li>Create event notifications</li><li>On the event type, select ‘PUT’</li><li>For Destination: Lambda function and select the Lambda created earlier</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SwhrTXxqZtSwSbDHUAELYw.png" /></figure><p><strong>Step 6: Test</strong></p><ul><li>Upload a resume to S3 and verify the data in DynamoDB.</li><li>Although CloudWatch is not specifically mentioned, it is used regularly for logging and debugging purposes.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QYtrUGe5wKOQcABqhrcvQw.png" /></figure><p>Here, while only of the skills that we’ve explicitly mentioned matched, there were 147 <a href="https://docs.aws.amazon.com/comprehend/latest/APIReference/API_DetectKeyPhrases.html">key_phrases</a> detected.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LIE6tZw_EMIq8g2tW8ry_w.png" /></figure><p>Multiple key phrases but no skills matched.</p><p>We have now built a simple resume parser. There can be multiple enhancements, such as the ability to handle multiple-paged documents, support for various file types, and filtered key phrases, among others.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6fde69a351c8" width="1" height="1" alt=""><hr><p><a href="https://awstip.com/resume-data-extraction-using-aws-ai-services-6fde69a351c8">Resume Data Extraction Using AWS AI Services</a> was originally published in <a href="https://awstip.com/">AWS Tip</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a Serverless AI Image Analyzer]]></title>
            <link>https://awstip.com/building-a-serverless-ai-image-analyzer-4eb2789830b0?source=rss-5ce4611115dc------2</link>
            <guid isPermaLink="false">https://medium.com/p/4eb2789830b0</guid>
            <category><![CDATA[aws-lambda]]></category>
            <category><![CDATA[rekognition]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[serverless]]></category>
            <dc:creator><![CDATA[Pooja Shrestha]]></dc:creator>
            <pubDate>Tue, 11 Nov 2025 01:09:36 GMT</pubDate>
            <atom:updated>2025-11-11T07:48:00.291Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*k_m-qg_KffeO-wBb0kQGDQ.jpeg" /></figure><p>While browsing through the internet, on several instances, you might have seen texts like ‘may be an image of 3 people’ or ‘may be a black and white image’ when the images cannot be loaded. Those texts can depend on metadata fed in, patterns of previous images, or can be generated by AI. Automatic image recognition models are used for such use cases. In this blog, we will build a simple analyzer, which, when given an image, will provide labels for the image based on visual analysis.</p><p>Here, we utilize Amazon Rekognition as the primary AI engine.</p><p>“<a href="https://docs.aws.amazon.com/rekognition/latest/dg/what-is.html"><em>Amazon Rekognition</em></a><em> is an image and video analysis service that makes it easy to add advanced computer vision capabilities to your applications.</em>”</p><p>Services we will be using:</p><ol><li>AWS S3</li><li>AWS IAM</li><li>AWS Lambda</li><li>Amazon DynamoDB</li><li>AWS API Gateway</li><li>Amazon Rekognition</li></ol><p>Here is the architecture of the system:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*14vjUar25Y55rg2kpe6HlA.png" /></figure><p>This architecture automates the process of analysing images uploaded by the user. It can be utilized in various applications, including image labeling, object detection, content moderation (such as flagging content on social media), facial analysis, and more.</p><p>It is also an example of an event-driven system. The system automatically responds when an image is uploaded, eliminating the need for manual computation, infrastructure management, or analysis.</p><p><strong>Step 1: Create an S3 bucket for storing the images</strong></p><ul><li>Go to S3 and create a bucket with a unique name.</li><li>Enable “Block all public access”</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*adaud0nV014mquGnYBZxNw.png" /></figure><p><strong>Step 2: Create a DynamoDB table for storing analysis results</strong></p><ul><li>Enter ‘imageName’ as a partition key while creating the table.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YibvSvnKPlhI4Lr72TBRPA.png" /></figure><p><strong>Step 3: Create an IAM Role for Lambda</strong></p><p>We are creating this role for Lambda (which we will create later) to enable it to access other AWS services.</p><ul><li>Go to IAM. Select Roles and then Create Role.</li><li>Select Lambda in the use case, as we are attaching this role to a Lambda.</li><li>Attach the following policies:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-1h228FnRThiRqgsWCs_ww.png" /></figure><p>Here, the permissions enable Lambda to:</p><ol><li>DynamoDB access — save analysis output</li><li>Rekognition access — call the API and run the detection process</li><li>S3 access — read the images uploaded to S3</li><li>CloudWatch access — log the execution details</li></ol><p><strong>Step 4: Create a Lambda Function</strong></p><ul><li>Runtime — Python 3.12</li><li>Role: Role we created earlier</li></ul><p>Code:</p><pre>import json<br>import boto3<br>import os<br><br>rekognition = boto3.client(&#39;rekognition&#39;)<br>dynamodb = boto3.resource(&#39;dynamodb&#39;)<br>table = dynamodb.Table(&#39;#Table we created earlier&#39;)<br><br>def lambda_handler(event, context):<br>    # Extract bucket and file name from the S3 event<br>    # Analyse CloudWatch logs for more insights<br>    bucket = event[&#39;Records&#39;][0][&#39;s3&#39;][&#39;bucket&#39;][&#39;name&#39;]<br>    key = event[&#39;Records&#39;][0][&#39;s3&#39;][&#39;object&#39;][&#39;key&#39;]<br><br>    # Call Rekognition<br>    response = rekognition.detect_labels(<br>        Image={&#39;S3Object&#39;: {&#39;Bucket&#39;: bucket, &#39;Name&#39;: key}},<br>        MaxLabels=10,<br>        MinConfidence=80<br>    )<br><br>    # Extract labels<br>    labels = [label[&#39;Name&#39;] for label in response[&#39;Labels&#39;]]<br><br>    # Store in DynamoDB<br>    table.put_item(<br>        Item={<br>            &#39;imageName&#39;: key,<br>            &#39;labels&#39;: labels,<br>        }<br>    )<br><br>    return {<br>        &#39;statusCode&#39;: 200,<br>        &#39;body&#39;: json.dumps({&#39;message&#39;: &#39;Image processed&#39;, &#39;labels&#39;: labels})<br>    }</pre><p><strong>Step 5: Add an S3 event trigger to automate the Lambda run</strong></p><ul><li>Go to your S3 bucket</li><li>Go to Properties</li><li>Create event notifications</li><li>On the event type, select ‘All object create events’</li><li>For Destination: Lambda function and select the Lambda created earlier</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HOaEvTNce1bxe6L_r5s7yw.png" /></figure><p><strong>Step 6: Create a Lambda function to retrieve the results from the API call</strong></p><ul><li>Runtime — Python 3.12</li><li>Role: Role we created earlier</li></ul><p>Code:</p><pre>import json<br>import boto3<br><br>dynamodb = boto3.resource(&#39;dynamodb&#39;)<br>table = dynamodb.Table(&#39;#DynamoDB table we created earlier&#39;)<br><br>def lambda_handler(event, context):<br>    image_name = event[&#39;queryStringParameters&#39;][&#39;imageName&#39;]<br>    response = table.get_item(Key={&#39;imageName&#39;: image_name})<br>    if &#39;Item&#39; in response:<br>        return {<br>            &#39;statusCode&#39;: 200,<br>            &#39;body&#39;: json.dumps(response[&#39;Item&#39;])<br>        }<br>    else:<br>        return {<br>            &#39;statusCode&#39;: 404,<br>            &#39;body&#39;: json.dumps({&#39;error&#39;: &#39;Image not found&#39;})<br>        }</pre><p><strong>Step 7: Create an API for fetching results</strong></p><ul><li>Go to API Gateway and select Create API</li><li>Select Rest API</li><li>Select the Create method and create a GET method</li><li>Enable the Lambda proxy integration and select the second Lambda that we created for results</li><li>Deploy API (I have created a dev stage for the API)</li><li>Copy the API endpoint</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KhiOhYTo2wxxs9aXkHaAbw.png" /></figure><ul><li>The API endpoint can now be called:</li></ul><pre>GET https://&lt;api-id&gt;.execute-api.&lt;region&gt;.amazonaws.com/dev?imageName=photoname.jpg</pre><p><strong>Step 7: Test</strong></p><ul><li>Upload an image to the S3 bucket</li><li>I have uploaded an image of a cat here</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VbaAANhx2FPhrxUrSeI8Pw.png" /></figure><ul><li>The lambda will be triggered. The execution can be monitored by CloudWatch</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dE6M4ev-1bImgMguolsbEw.png" /></figure><ul><li>Check the DynamoDB for new items</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vHgq7Y2oafKdHb51AXDTkA.png" /></figure><ul><li>Call the API to fetch the results</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JnCl-IAqXrRAcj5gtLHr6g.png" /></figure><p>We have now received our analysis via our fully serverless demo AI service. We could possibly create a site where users can upload images and view the results. For more insights, we can experiment with other methods in Rekognition, adjust the number of labels, confidence levels, and more.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4eb2789830b0" width="1" height="1" alt=""><hr><p><a href="https://awstip.com/building-a-serverless-ai-image-analyzer-4eb2789830b0">Building a Serverless AI Image Analyzer</a> was originally published in <a href="https://awstip.com/">AWS Tip</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hands-On with EC2 CloudWatch Metrics: Alarms, Dashboards, and Insights]]></title>
            <link>https://medium.com/@pooja_shrestha/hands-on-with-ec2-cloudwatch-metrics-alarms-dashboards-and-insights-c6eb7791eb61?source=rss-5ce4611115dc------2</link>
            <guid isPermaLink="false">https://medium.com/p/c6eb7791eb61</guid>
            <category><![CDATA[cloudwatch]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[cloudwatch-agent]]></category>
            <dc:creator><![CDATA[Pooja Shrestha]]></dc:creator>
            <pubDate>Mon, 27 Oct 2025 03:02:52 GMT</pubDate>
            <atom:updated>2025-10-27T03:03:56.581Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1020/1*3DlLviBkSrSx4cFpTr9dQQ.png" /><figcaption>Image generated by Gemini</figcaption></figure><p><strong>Amazon</strong> <strong>CloudWatch</strong></p><p>Amazon CloudWatch is an AWS component that provides monitoring for AWS resources and customer applications running on Amazon infrastructure.</p><p><strong>CloudWatch Alarms</strong></p><p>The CloudWatch Alarms feature allows us to monitor CloudWatch metrics and receive notifications when they fall outside of the levels (high or low thresholds) that you configure. We can attach multiple Alarms to each metric, and each one can have multiple actions.</p><p>A CloudWatch Alarm is always in one of three states: OK, ALARM, or INSUFFICIENT_DATA. When the metric is within the range that you have defined as acceptable, the Monitor is in the OK state. When it breaches a threshold, it transitions to the ALARM state. If the data needed to make the decision is missing or incomplete, the monitor transitions to the INSUFFICIENT_DATA state.</p><p>When beginning our AWS journey, we generally start learning with EC2, as it is easier to compare it with our original idea of a server. In this blog, we learn the basics of monitoring our server’s resource utilization.</p><p><strong>Step 1</strong>:</p><p>Create an EC2 instance where we want to monitor logs and metrics.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EIyvKYKaY8jjgyn_utiM0g.png" /><figcaption>EC2 instance created with default settings</figcaption></figure><p><strong>Step 2</strong>:</p><p>On the <strong>Monitoring </strong>tab, we can see various data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XA1VKWotG3DABGm2G_AbkQ.png" /><figcaption>Default monitoring metrices</figcaption></figure><p>One of the data visualized is CPU Utilisation. Let’s suppose we want a heads-up whenever our CPU utilization reaches 100%. In this case, we utilize CloudWatch Alarms.</p><p>Note: While working on real-time projects, we do not want to wait till our utilization reaches 100% for obvious reasons.</p><p><strong>Step 3:</strong></p><p>Connect to your instance and update.</p><p><strong>Step 4:</strong></p><p>I have used Amazon Linux 2 AMI for this instance, and it does not have the stress tool installed by default; we will need to install some packages.</p><pre>sudo amazon-linux-extras install epel -y<br>yum install stress -y</pre><p>The stress tool will be used to simulate EC2 metrics. Once we create the CloudWatch Alarm, we shall return to SSH and trigger CPUUtilization using it.</p><p><strong>Step 5:</strong></p><p>Go to <strong>CloudWatch</strong>. Select the All alarms tab in the <strong>Alarm </strong>section. Click on <strong>Create alarm</strong>. These alarms watch these metrics and send notifications to email or trigger some events, which can automatically handle the situation.</p><p><strong>Step 6:</strong></p><p>Click on <strong>Select metric. </strong>Since we will be monitoring EC2, select the EC2 namespace.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eo8ALCw9RM27AMtRZgUrEQ.png" /></figure><p>Select the Per-Instance Metrics. We can find other categories by which we can choose to filter our data.</p><p>Search for the instance ID and select the metrics you want to trigger the alarm. Here, we select CPU utilization.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*P-fbMvka13qCxaRmj2NSKw.png" /></figure><p><strong>Step 7:</strong></p><p>Now, choosing the condition:</p><p><strong>Static</strong>: You choose a CloudWatch metric for the alarm to watch, and the threshold for that metric. The alarm goes to ALARM state when the metric breaches the threshold for a specified number of evaluation periods. Predictable.</p><p><strong>Anomaly</strong>: You can create an alarm based on CloudWatch anomaly detection, which analyzes past metric data and creates a model of expected values. The expected values take into account the typical hourly, daily, and weekly patterns in the metric, which is non-predictable.</p><p><strong>Step 8:</strong></p><p>Now, we create an SNS topic and add an email endpoint so that when the condition is met, we can receive an email.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Gb5Np4NJP7G8QXH75JOvsw.png" /></figure><p><strong>Step 9:</strong></p><p>Give a name and description to the alarm. Review the given information and create the alarm.</p><p>As we created an SNS topic earlier and provided an email for the notification, the email address will have received an email to confirm the subscription to the topic.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NflVWpFvMEzHQE27Eb1F1A.png" /></figure><p><strong>Step 10:</strong></p><p>Now, we connect to our EC2 instance and enter the following command to stress the instance and increase CPU utilisation manually.</p><pre>sudo stress - cpu 10 -v - timeout 400s</pre><p>Now, open another terminal and hit the command “top”.</p><p><em>The top command is used to show the Linux processes.</em></p><p>Here, we can see various data from our instance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PlR3m_P_FFAVezZhGXu2yg.png" /></figure><p>After the CPU hits the threshold, we receive an email notification with the details of the alarm.</p><p>This is the metric AWS provides by default.</p><p><strong>CloudWatch Agent</strong></p><p>The metrics measured by default don’t add to the pricing. The pricing is usually decided based on the frequency of monitoring. For advanced monitoring, the interval in which the data/logs CloudWatch collects will be shorter. CloudWatch can collect the logs from the application in our EC2 instance. We can group these logs into Log groups based on their similarity. Later, we can export these logs to S3 or upload them wherever we need.</p><p>For CloudWatch to collect these logs, it needs an agent in an EC2 instance that is pointed to these logs. This agent is called CloudWatch Agent. We usually install this agent in an EC2 instance.</p><p>Now,</p><p>To access CloudWatch from EC2, we need to give the EC2 instance permission. For this, attach CloudWatchAgentServerPolicy to the role we create.</p><ul><li>Search for IAM</li><li>From the left navigation, select ‘Roles’</li><li>Click on ‘Create role’</li><li>Select ‘AWS Service’ and ‘EC2’ as we are creating a role for our instance</li><li>Select the policies to attach to this role</li><li>Select ‘CloudWatchAgentServerPolicy’ and ‘CloudWatchFullAccess’</li><li>Save the Role</li><li>Attach the role to the instance we previously created.</li></ul><p>Now, let’s install the Apache server in our instance.</p><pre>sudo su<br>yum update -y<br>yum install httpd -y<br>systemctl start httpd</pre><p>Install the CloudWatch agent.</p><pre>sudo yum install amazon-cloudwatch-agent</pre><p>Check the status of the agent.</p><pre>sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -m ec2 -a status</pre><p>We can then see if the agent is running or not.</p><p>If we see the status to be stopped, we can enter the following code:</p><pre>sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl \<br>  -a fetch-config \<br>  -m ec2 \<br>  -s \<br>  -c file:/opt/aws/amazon-cloudwatch-agent/bin/config.json</pre><p><em>/opt/aws/amazon-cloudwatch-agent/bin/config.json</em> is the path to our CloudWatch Agent config file, which has the information on the metrics to be collected, CloudWatch namespace, collection intervals, etc.</p><p>The command above takes the configuration details from the JSON file and starts the agent.</p><p>Now, let’s run the wizard.</p><pre>/opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-config-wizard</pre><p><strong>collectd </strong>is a daemon that collects system and application performance metrics periodically and provides mechanisms to store the values in a variety of ways.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*imRgqwb_XvBY5d-lyiJ_aA.png" /></figure><p>Here, we have added the path of the Apache access log to our log path and given it the name pooja-access. Similarly, we added an error log as well.</p><p>Now, we can go to CloudWatch Log groups and see that the logs have been created.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JoL9JHaTnFVpxfl3iHV-nA.png" /></figure><p>The log groups’ retention period is set to ‘Never expire’, but this can be configured according to the requirement.</p><p>After installing the agent, we can view the metrics as:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gExJwg_bPcDgGkkq4VWGJQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JEQdYFKfqxkZvGuTQMSkrQ.png" /></figure><p><strong>CloudWatch Dashboard</strong></p><p><strong>Step 1:</strong></p><p>Go to Dashboards on CloudWatch and click on Create Dashboard.</p><p><strong>Step 2:</strong></p><p>Select your preferred widget.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mfBYYvlIjlh0LFSrNgf1vA.png" /></figure><p>After selecting the preferred widget as Alarm status, we will be prompted to choose the alarm created.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q5JNIhnkxZL6X-LvwcXVoA.png" /></figure><p>I also selected another widget for disk and memory usage. Now, the dashboards look like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ojIYQq25EzCpwi8m-caYHg.png" /></figure><p>So, in this way, we can monitor the default metrics provided by AWS and also perform advanced monitoring of our instances.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c6eb7791eb61" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Proactive EC2 Management: Sending Automated Notifications with Cloud Custodian and c7n-mailer]]></title>
            <link>https://awstip.com/proactive-ec2-management-sending-automated-notifications-with-cloud-custodian-and-c7n-mailer-ce6d68a01042?source=rss-5ce4611115dc------2</link>
            <guid isPermaLink="false">https://medium.com/p/ce6d68a01042</guid>
            <category><![CDATA[cloud-custodian]]></category>
            <category><![CDATA[automate]]></category>
            <category><![CDATA[ec2]]></category>
            <category><![CDATA[c7n-mailer]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Pooja Shrestha]]></dc:creator>
            <pubDate>Mon, 16 Sep 2024 10:27:21 GMT</pubDate>
            <atom:updated>2024-09-17T18:44:39.375Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Background:</strong></p><p>This is a continuation of this article:</p><p><a href="https://awstip.com/organization-wide-ec2-governance-efficient-instance-management-with-cloud-custodian-9951b25a6339">Organization-wide EC2 governance: Efficient Instance Management with Cloud Custodian</a></p><h4>c7n-mailer</h4><p>It is an extension of Cloud Custodian that enables email, and other messaging notifications based on policy actions. It is usually used with Cloud Custodian policies to notify stakeholders when certain events or actions occur.</p><p>Learn more about it <a href="https://cloudcustodian.io/docs/tools/c7n-mailer.html">here</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*19qv1nhFJ9Y755UN2pOxfw.png" /></figure><h4>Procedure:</h4><p><strong>1. Installation</strong></p><pre>pip install c7n-mailer</pre><p><strong>2. Set up the mailer configuration.</strong></p><p>The mailer config file holds the settings for how Cloud Custodian sends the notifications. This configuration defines the connection to AWS services, the notification delivery options, and other settings required for the mailer to function properly.</p><p><em>Sample mailer.yml</em>:</p><pre>queue_url: https://sqs.us-east-1.amazonaws.com/&lt;management-account-id&gt;/quese-name<br>role: arn:aws:iam::&lt;management-account-id&gt;:role/CloudCustodian<br>from_address: name@example.com</pre><p><strong>3. Run the mailer:</strong></p><pre>c7n-mailer --config mailer.yml</pre><p>A lambda function is created in the management account after executing the command.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/723/1*P1bghV3YMqgqEsuChj2TwQ.png" /><figcaption>Lambda function created</figcaption></figure><p><strong>4. Modify the custodian policy</strong></p><p>We want the owner of the EC2 instance to be notified if their instance has been running for more than four hours. So, we need to add the notification aspect in the running mark.</p><p><em>Updated policy:</em></p><pre>policies:<br><br>- name: ec2-running-mark<br>  resource: ec2<br>  comments: |<br>    Marks EC2 instances that have been running for more than 5 hours for deletion. <br>  mode:<br>      type: periodic<br>      schedule: &quot;cron(15 08,12 * * ? *)&quot;<br>      role: CloudCustodian<br>  filters:<br>      - type: value<br>        key: State.Name<br>        value: running<br>      - type: instance-age<br>        op: greater-than<br>        hours: 5<br>  actions:<br>    - type: mark-for-op<br>      tag: deletionmark<br>      op: stop<br>      hours: 1<br>    - type: notify<br>      template: default<br>      subject: &quot;EC2 running for too long - [custodian-alert {{ account_id }} / {{ region }}]&quot;<br>      to:<br>        - resource-owner<br>      owner_absent_contact:<br>        - admin@example.com<br>      transport:<br>        type: sqs<br>        queue: arn:aws:sqs:us-east-1:&lt;management-id&gt;:queue-name<br><br>- name: ec2-tag-compliance-unmark<br>  resource: ec2<br>  comments: |<br>    If &#39;postpone&#39; tag is added to the instance, deletion mark will be removed.<br>  mode:<br>      type: periodic<br>      schedule: &quot;cron(10 09,13 * * ? *)&quot;<br>      role: CloudCustodian<br>  filters:<br>    - &quot;tag:postpone&quot;: present<br>  actions:<br>    - type: remove-tag<br>      tags:<br>        - deletionmark<br><br>- name: ec2-tag-compliance-stop<br>  resource: ec2<br>  comments: |<br>    Deletes the instances with delete mark previously if no action is taken.<br>  mode:<br>      type: periodic<br>      schedule: &quot;cron(15 09,13 * * ? *)&quot;<br>      role: CloudCustodian<br>  filters:<br>    - type: marked-for-op<br>      tag: deletionmark<br>      op: stop<br>    - &quot;tag:postpone&quot;: absent<br>  actions:<br>    - stop</pre><p>Along with the policy, we will also need to update the mailer configuration.</p><p><em>mailer.yml</em></p><pre>queue_url: https://sqs.us-east-1.amazonaws.com/&lt;management-account-id&gt;/quese-name<br>role: arn:aws:iam::&lt;management-account-id&gt;:role/CloudCustodian<br>from_address: name@example.com<br>contact_tags: [&quot;owner&quot;]<br>org_domain: example.com</pre><p>Here, we have added <strong>contact_tags</strong> and <strong>org_domain </strong>fields.</p><p>According to the custodian policy, the owner is notified if the lambda process finds an instance running for more than four hours. The tag ‘owner’ is used as a reference to identify the resource owner. Here, <strong>contact_tags</strong> refers to the tag and <strong>org_domain</strong> appends the domain to the owner tag.</p><p>For example, the owner is ‘<em>pooja.shrestha’</em>. With ‘<em>example.com’</em> as the domain, mail will be sent to ‘<em>pooja.shrestha@example.com</em>’.</p><p>We have implemented auto-tag for the EC2 instances with the following policy:</p><pre>policies:<br>  - name: ec2-auto-tag-owner<br>    resource: ec2<br>    mode:<br>      type: cloudtrail<br>      role: arn:aws:iam::&lt;management-account-id&gt;:role/CloudCustodian<br>      events:<br>        - source: ec2.amazonaws.com<br>          event: RunInstances<br>          ids: &quot;responseElements.instancesSet.items[].instanceId&quot;<br>    filters:<br>      - &quot;tag:owner&quot;: absent<br>    actions:<br>      - type: auto-tag-user<br>        tag: owner</pre><p>If confused about the implementation, here is a similar policy implementation details:</p><p><a href="https://awstip.com/automating-resource-governance-auto-tagging-aws-resources-with-cloud-custodian-86529d419a1f">Automating resource governance: Auto-tagging AWS resources with Cloud Custodian</a></p><p><strong>5. Update the mailer config and run the custodian policy</strong></p><p>To update the policy in the mailer lambda:</p><pre>c7n-mailer --config mailer.yml --update-lambda</pre><p>Run the custodian policy across accounts with:</p><pre>c7n-org run -c accounts.yml -s output -u policy.yml</pre><p><strong>6. Manage permission policies</strong></p><blockquote>How c7n-mailer works:<strong><br>- </strong>Cloud Custodian Policy: A Cloud Custodian policy generates events (e.g., when a resource violates a rule) and sends a notification to an SNS or SQS queue.<br>- c7n-mailer: The c7n-mailer listens for messages from SNS or SQS, processes the message, and sends notifications via email or Slack based on configured templates.</blockquote><p>Now since we are working on multiple accounts, c7n-mailer with the SQS trigger is set up on the management account. The policy functions are set up on the member account.</p><p>When a function is run in the member, it sends the message to the SQS of the management account.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xr7ljTwDNji-L0i0-qNVeA.png" /></figure><p>So, in the SQS queue, we will need to provide access to the role of member account. The policy looks like this:</p><pre>{<br>  &quot;Version&quot;: &quot;2012-10-17&quot;,<br>  &quot;Id&quot;: &quot;__default_policy_ID&quot;,<br>  &quot;Statement&quot;: [<br>    {<br>      &quot;Sid&quot;: &quot;__owner_statement&quot;,<br>      &quot;Effect&quot;: &quot;Allow&quot;,<br>      &quot;Principal&quot;: {<br>        &quot;AWS&quot;: [<br>          &quot;arn:aws:iam::&lt;management-id&gt;:root&quot;,<br>          &quot;arn:aws:iam::&lt;member1-id&gt;:role/CloudCustodian&quot;,<br>          &quot;arn:aws:iam::&lt;member2-id&gt;:role/CloudCustodian&quot;,<br>          &quot;arn:aws:iam::&lt;member3-id&gt;:role/CloudCustodian&quot;<br>        ]<br>      },<br>      &quot;Action&quot;: &quot;SQS:*&quot;,<br>      &quot;Resource&quot;: &quot;arn:aws:sqs:us-east-1:&lt;management-id&gt;:queue-name&quot;<br>    }<br>  ]<br>}</pre><p><em>Note: Separate policies can be created for the management account and member accounts so that member accounts can be provided with the least privilege. The above sample policy is for test purposes only.</em></p><p>Trust policy for the CloudCustodian role:</p><pre>{<br>    &quot;Version&quot;: &quot;2012-10-17&quot;,<br>    &quot;Statement&quot;: [<br>        {<br>            &quot;Effect&quot;: &quot;Allow&quot;,<br>            &quot;Principal&quot;: {<br>                &quot;Service&quot;: [<br>                    &quot;sqs.amazonaws.com&quot;,<br>                    &quot;lambda.amazonaws.com&quot;<br>                ],<br>                &quot;AWS&quot;: &quot;arn:aws:iam::&lt;management-id&gt;:root&quot;<br>            },<br>            &quot;Action&quot;: &quot;sts:AssumeRole&quot;<br>        }<br>    ]<br>}</pre><p><strong>7. Test the mailer</strong></p><p>Now, whenever the lambda is triggered and finds any instance running for more than four hours, an email is sent to the instance owner.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/887/1*Sp8pRSjTuMtQavkQ_QyNtQ.png" /><figcaption>Example mail</figcaption></figure><p>The mail template can be customized with jinja2 templates. The given example has a default template format.</p><p>Now, when the owners are notified. They can choose either to stop/terminate the instance or postpone the process.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ce6d68a01042" width="1" height="1" alt=""><hr><p><a href="https://awstip.com/proactive-ec2-management-sending-automated-notifications-with-cloud-custodian-and-c7n-mailer-ce6d68a01042">Proactive EC2 Management: Sending Automated Notifications with Cloud Custodian and c7n-mailer</a> was originally published in <a href="https://awstip.com/">AWS Tip</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Organization-wide EC2 governance: Efficient Instance Management with Cloud Custodian]]></title>
            <link>https://awstip.com/organization-wide-ec2-governance-efficient-instance-management-with-cloud-custodian-9951b25a6339?source=rss-5ce4611115dc------2</link>
            <guid isPermaLink="false">https://medium.com/p/9951b25a6339</guid>
            <category><![CDATA[c7n-org]]></category>
            <category><![CDATA[cloud-custodian]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[governance]]></category>
            <category><![CDATA[ec2]]></category>
            <dc:creator><![CDATA[Pooja Shrestha]]></dc:creator>
            <pubDate>Wed, 11 Sep 2024 13:57:10 GMT</pubDate>
            <atom:updated>2024-09-11T13:57:10.941Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Scenario:</strong></p><p>An organization has sandbox accounts allocated for each department. Members frequently create EC2 instances for various tasks. However, they sometimes forget to stop or terminate the instance after use, leading to unnecessary costs. You are responsible for ensuring the unused instances are stopped to avoid these expenses.</p><p><strong>To be done:</strong></p><p>An estimated period is set for the usual tasks to be completed. Say, four hours. Instances are periodically checked at specific intervals to determine if any instances have been running for more than four hours. If there are such instances, they should be stopped.</p><p>But, what if the instance is in use? A tag should be added to the instance that postpones the action. Else, it will be stopped. Terminating instances is a bit risky. The termination action can be scheduled weekly either manually or through added custodian policy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*19qv1nhFJ9Y755UN2pOxfw.png" /></figure><h4>c7n-org</h4><p>c7n-org is an extension for <strong>Cloud Custodian</strong> that allows for multi-account and multi-cloud governance. It helps in managing Cloud Custodian policies across multiple accounts from a centralized location.</p><p>Learn more about it <a href="https://cloudcustodian.io/docs/tools/c7n-org.html">here</a>.</p><h4>Procedure</h4><p><strong>1. Installation</strong></p><pre>pip install c7n-org</pre><p><strong>2. List the accounts</strong></p><p>Accounts, where we want to run Custodian policies, should be listed in a YAML file.</p><p>I generated the list of my accounts with the following code:</p><pre>#!/usr/bin/env python<br><br>import boto3<br><br>#### ---------------- Variables ------------------<br>ROOT_OU_ID = &quot;&lt;ROOT_OU_ID&gt;&quot;  #update the root ou id<br>ORG_UNIT_LIST = [ &quot;Shared&quot;, &quot;Security&quot;, &quot;Network&quot;, &quot;Developement&quot;, &quot;Production&quot; ]<br>TARGET_REGION = &quot;us-east-1&quot;<br>#### ------------------------------------------<br><br>def get_active_accounts_in_ou(ou_name):<br>    &quot;&quot;&quot;List all the active member accounts under the given organisation unit&quot;&quot;&quot;<br>    org_client = boto3.client(&#39;organizations&#39;)<br>    try:<br>        response = org_client.list_organizational_units_for_parent(ParentId=ROOT_OU_ID)<br>        ou = next((ou for ou in response[&#39;OrganizationalUnits&#39;] if ou[&#39;Name&#39;] == ou_name), None)<br>        if ou:<br>            response = org_client.list_accounts_for_parent(ParentId=ou[&#39;Id&#39;])<br>            active_accounts_in_ou = [{&#39;id&#39;: account[&#39;Id&#39;], &#39;name&#39;: account[<br>                &#39;Name&#39;]} for account in response[&#39;Accounts&#39;] if account[&#39;Status&#39;] == &#39;ACTIVE&#39;]<br>            return active_accounts_in_ou<br>        else:<br>            print(f&quot;Organizational unit &#39;{ou_name}&#39; not found.&quot;)<br>    except org_client.exceptions.InvalidInputException as err:<br>        return None, f&quot;Invalid input: {str(err)}&quot;<br>    except org_client.exceptions.ServiceException as err:<br>        return None, f&quot;An error occurred: {str(err)}&quot;<br><br>def get_all_active_accounts():<br>    &quot;&quot;&quot;List all the active member accounts under the organisation&quot;&quot;&quot;<br>    try:<br>        org = boto3.client(&#39;organizations&#39;)<br>        response = org.list_accounts()<br>        results = response[&quot;Accounts&quot;]<br>        while &quot;NextToken&quot; in response:<br>            response = org.list_accounts(NextToken=response[&quot;NextToken&quot;])<br>            results.extend(response[&quot;Accounts&quot;])<br>        active_accounts = [{&#39;id&#39;: account[&#39;Id&#39;], &#39;name&#39;: account[<br>            &#39;Name&#39;]} for account in results if account[&#39;Status&#39;] == &#39;ACTIVE&#39;]<br>        return active_accounts<br>    except org.exceptions.ServiceException as err:<br>        print(f&quot;An error occurred: {str(err)}&quot;)<br>    except Exception as err:<br>        print(f&quot;An unexpected error occurred: {str(err)}&quot;)<br><br>def generate_accounts_yml_file(accounts, file, target_region):<br>    &quot;&quot;&quot;Generate custodian accounts yaml file&quot;&quot;&quot;<br>    header_yml = &quot;&quot;&quot;<br>accounts:&quot;&quot;&quot;<br><br>    account_yml = &quot;&quot;&quot;<br>- account_id: &#39;{account_id}&#39;<br>  name: {account_name}<br>  regions:<br>  - {account_region}<br>  role: arn:aws:iam::{account_id}:role/AssumingRole<br>  vars:<br>    cc1: support@gmail.com<br>    cc2: &#39;&#39;&quot;&quot;&quot;<br>    with open(file, &quot;w&quot;, encoding=&quot;utf-8&quot;) as account_yml_file:<br>        print(f&quot;Generating {file} ...&quot;)<br>        account_yml_file.write(header_yml)<br>        print(&quot;Generating custodian accounts yml file&quot;)<br>        for account in accounts:<br>            print(account)<br>            account_yml_file.write(<br>                account_yml.format(<br>                    account_id=account[&#39;id&#39;],<br>                    account_name=account[&#39;name&#39;],<br>                    account_region=target_region<br>                )<br>            )<br><br>if __name__ == &quot;__main__&quot;:<br>    generate_accounts_yml_file(get_all_active_accounts(), &quot;all_accounts.yml&quot;, TARGET_REGION)<br>    for ou_name in ORG_UNIT_LIST:<br>        file_name = f&quot;{ou_name}_ou_accounts.yml&quot;<br>        generate_accounts_yml_file(<br>            get_active_accounts_in_ou(ou_name), file_name.lower(), TARGET_REGION)</pre><p><em>Code source: </em><a href="https://gist.github.com/Tharsan05/7059b57a49822fa57bc1fe4ca64adfc5#file-gen-org-account-files-py"><em>https://gist.github.com/Tharsan05/7059b57a49822fa57bc1fe4ca64adfc5#file-gen-org-account-files-py</em></a></p><p>If you do not want the policy to be applied to all the accounts, you can remove the unwanted ones from the list.</p><blockquote><em>Sample accounts.yml file:</em></blockquote><pre>accounts:<br><br>  - account_id: &quot;123456xxxxxx&quot;<br>    name: account-name<br>    role: arn:aws:iam::&lt;memeber-account-id&gt;:role/AssumingRole<br>    regions:<br>    - us-east-1<br>  - account_id: &quot;123456xxxxxx&quot;<br>    name: account-name<br>    role: arn:aws:iam::&lt;memeber-account-id&gt;:role/AssumingRole<br>    regions:<br>    - us-east-1<br>  - account_id: &quot;123456xxxxxx&quot;<br>    name: account-name<br>    role: arn:aws:iam::&lt;memeber-account-id&gt;:role/AssumingRole<br>    regions:<br>    - us-east-1</pre><p>Here, the ‘AssumingRole’ role should permit the management account to assume the member account.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/566/1*5rdZHgV_cdXF7NmgPYVzqw.png" /><figcaption>Trust policy for the role ‘AssumingRole’</figcaption></figure><p><strong>3. Write the policy</strong></p><pre>policies:<br><br>- name: ec2-running-mark<br>  resource: ec2<br>  comments: |<br>    Marks EC2 instances that have been running for more than 5 hours for deletion. <br>  mode:<br>      type: periodic<br>      schedule: &quot;cron(15 08,12 * * ? *)&quot;<br>      role: CloudCustodian<br>  filters:<br>      - type: value<br>        key: State.Name<br>        value: running<br>      - type: instance-age<br>        op: greater-than<br>        hours: 5<br>  actions:<br>    - type: mark-for-op<br>      tag: deletionmark<br>      op: stop<br>      hours: 1<br><br>- name: ec2-tag-compliance-unmark<br>  resource: ec2<br>  comments: |<br>    If &#39;postpone&#39; tag is added to the instance, deletion mark will be removed.<br>  mode:<br>      type: periodic<br>      schedule: &quot;cron(10 09,13 * * ? *)&quot;<br>      role: CloudCustodian<br>  filters:<br>    - &quot;tag:postpone&quot;: present<br>  actions:<br>    - type: remove-tag<br>      tags:<br>        - deletionmark<br><br>- name: ec2-tag-compliance-stop<br>  resource: ec2<br>  comments: |<br>    Deletes the instances with delete mark previously if no action is taken.<br>  mode:<br>      type: periodic<br>      schedule: &quot;cron(15 09,13 * * ? *)&quot;<br>      role: CloudCustodian<br>  filters:<br>    - type: marked-for-op<br>      tag: deletionmark<br>      op: stop<br>    - &quot;tag:postpone&quot;: absent<br>  actions:<br>    - stop</pre><p>The role ‘CloudCustodian’ should be in every member account and should have permission to assume the Lambda role.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/538/1*yVCQxTa6-v2bmkiDHO1N6Q.png" /><figcaption>Trust policy for the role ‘CloudCustodian’</figcaption></figure><p><strong>4. Run the policy</strong></p><ul><li>Validate the policy</li></ul><pre>custodian validate policy.yml</pre><ul><li>Run</li></ul><pre>c7n-org run -c accounts.yml -s output -u policy.yml</pre><p>When this command is run, it creates a lambda function with the CloudWatch events (Eventbridge) as a trigger. The function is run at the mentioned schedule.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LW0dlLWdJZk3A9yfwpH1pg.png" /><figcaption>3 functions created for 3 policies in a member account</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/598/1*FYd_wlGhNl1ws2T5jd0cDw.png" /><figcaption>ec2 running mark</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/625/1*YtwPqxIErFS2j_MJwVdMsA.png" /><figcaption>postpone tag added</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xyuWZsXnvjg_NPjz-bI1Fw.png" /><figcaption>Lambda log</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/638/1*4aahW59JLSJ71cmkwxHQjg.png" /><figcaption>deletion mark removed by the lambda function</figcaption></figure><p>If the ‘postpone’ tag is not found, the instance will be stopped.</p><p>Now, for the ‘postpone’ tag to be added, the owner of the tag should be notified. For the process, Cloud Custodian has a mailing extension: <strong><em>c7n-mailer</em></strong>.</p><p><strong>The mailer function will be discussed in the next part for the use case outlined here.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9951b25a6339" width="1" height="1" alt=""><hr><p><a href="https://awstip.com/organization-wide-ec2-governance-efficient-instance-management-with-cloud-custodian-9951b25a6339">Organization-wide EC2 governance: Efficient Instance Management with Cloud Custodian</a> was originally published in <a href="https://awstip.com/">AWS Tip</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Automating resource governance: Auto-tagging AWS resources with Cloud Custodian]]></title>
            <link>https://awstip.com/automating-resource-governance-auto-tagging-aws-resources-with-cloud-custodian-86529d419a1f?source=rss-5ce4611115dc------2</link>
            <guid isPermaLink="false">https://medium.com/p/86529d419a1f</guid>
            <category><![CDATA[amazon-s3]]></category>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[cloud-custodian]]></category>
            <category><![CDATA[tagging]]></category>
            <dc:creator><![CDATA[Pooja Shrestha]]></dc:creator>
            <pubDate>Mon, 09 Sep 2024 08:43:20 GMT</pubDate>
            <atom:updated>2024-09-09T16:32:37.945Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Scenario:</strong></p><p>You work in a large organization where multiple teams share a common AWS sandbox environment for testing and experimentation. Lately, you have been incurring high costs in the sandbox and most of the resources responsible for the amount seem unused or unnecessary. You are assigned the responsibility of clearing up resources but want to make sure they are not required anymore. The best approach is to reach out to the resource owners for confirmation. To streamline this process, you enforced a policy to add an <em>owner</em> tag during the creation of new resources. However, enforcing tags consistently through the AWS Console isn’t always feasible, as not all resources can be tagged at the time of creation.</p><p>While going through a similar situation, I stumbled upon <strong>Cloud Custodian</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BB3Tb4WXl3BHVLBAumUeEg.png" /></figure><p>Here’s how I implemented Cloud Custodian to auto-tag resources. It —</p><ol><li>Saved other members from the tedious task of adding the ‘owner’ tags every time while creating new resources</li><li>Made it convenient for me to quickly identify the resource owner and contact them for additional details</li></ol><h4>Steps:</h4><p><strong>1. Custodian Installation:</strong></p><pre>$ python -m venv custodian<br>$ source custodian/bin/activate<br>(custodian) $ pip install c7n</pre><p><strong>2. Write the policy:</strong></p><p>A custodian policy is written in a YAML file. The policy usually consists of a resource the policy is to act upon, the filters that identify and select the resources that meet the specific conditions, and the action that is to be taken on the filtered resources.</p><p>Check out the <a href="https://www.cloudcustodian.io/docs/">documentation</a> to get started.</p><p>For my use case, the policy is as:</p><pre>policies:<br>  - name: s3-auto-tag-owner<br>    resource: s3<br>    mode:<br>      type: cloudtrail<br>      role: custodian-role<br>      events:<br>        - source: s3.amazonaws.com<br>          event: CreateBucket<br>          ids: &quot;requestParameters.bucketName&quot;<br>    filters:<br>      - type: value<br>        key: &quot;tag:owner&quot;<br>        value: absent<br>    actions:<br>      - type: auto-tag-user<br>        tag: owner</pre><p>Here, the policy is in cloudtrail mode. It runs custodian in AWS lambda and is triggered by cloudtrail events. Learn more about the aws modes <a href="https://cloudcustodian.io/docs/aws/aws-modes.html">here</a>.</p><p>For a lambda to be created to run the policy, an IAM role needs to be created with appropriate policies attached.</p><p>The issue with implementing this policy was that the Custodian doesn’t give the option to mention multiple resources at once. <a href="https://github.com/cloud-custodian/cloud-custodian/issues/5258"><em>Issue</em></a>.</p><p><strong>3. Validate the policy</strong></p><p>To see if the policy is valid, run:</p><pre>custodian validate policy.yml</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/873/1*McllhIOsOiWb0Wmd7t6iPQ.png" /></figure><p><strong>4. Dry run</strong></p><p>A dry run allows us to see what actions would be taken without actually making any changes.</p><pre>custodian run --dry-run -s output policy.yml</pre><p><strong>5. Run the policy</strong></p><pre>custodian run policy.yml -s output</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/998/1*QGfKV6Rt2e_1AfxR8eyMSg.png" /></figure><p>Upon executing the command, a lambda is created that is triggered when a S3 bucket is created.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ObngkFRPZ7M9PJgF8BosCQ.png" /></figure><p>Now, whenever you create a new bucket, a tag with the key ‘owner’ is automatically added to the bucket with the value being the username (IAM or the Identity center).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/884/1*fyvQ78RAGsB8JfNk8oLyzA.png" /></figure><p>This implementation has significantly eased the process of identifying resource owners, and we are now exploring additional ways to use Cloud Custodian for more efficient resource management.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=86529d419a1f" width="1" height="1" alt=""><hr><p><a href="https://awstip.com/automating-resource-governance-auto-tagging-aws-resources-with-cloud-custodian-86529d419a1f">Automating resource governance: Auto-tagging AWS resources with Cloud Custodian</a> was originally published in <a href="https://awstip.com/">AWS Tip</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Connecting AWS CodePipeline Updates to Zoom Chat: A Step-by-Step Guide]]></title>
            <link>https://awstip.com/connecting-aws-codepipeline-updates-to-zoom-chat-a-step-by-step-guide-599e63eb32e0?source=rss-5ce4611115dc------2</link>
            <guid isPermaLink="false">https://medium.com/p/599e63eb32e0</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[aws-lambda]]></category>
            <category><![CDATA[zoom]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[aws-codepipeline]]></category>
            <dc:creator><![CDATA[Pooja Shrestha]]></dc:creator>
            <pubDate>Fri, 17 May 2024 06:18:54 GMT</pubDate>
            <atom:updated>2024-05-25T17:48:51.906Z</atom:updated>
            <content:encoded><![CDATA[<p>Tired of being glued to the CodePipeline console for the deployment updates? This guide will walk you through the steps to get real-time notifications about pipeline executions directly in your Zoom channel.</p><p>From helping to quickly identify and address pipeline failures to reducing context switching, this integration helps improve focus, keep the team informed, and foster better collaboration and, ultimately overall communication and efficiency.</p><h4><strong>Procedures:</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*x_buldFfffCwc2Oz59S8UQ.png" /></figure><p><strong>Step 1: Configure Zoom Incoming Webhooks</strong></p><p>First, we should set up an incoming webhook in Zoom where AWS CodePipeline can send notifications.</p><ul><li>Sign in to your Zoom account and navigate to the <a href="https://marketplace.zoom.us/">Zoom Marketplace</a>.</li><li>Search for “Incoming Webhooks” and install the app. If you are unable to install the app, contact your account administrator.</li><li>Once the app is installed, you can find it in the Apps section of your Zoom chat.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/218/1*XG8_3KGuJdQRjCsI5MRWEQ.png" /><figcaption>Zoom Chat sidebar</figcaption></figure><ul><li>Once installed, navigate to the Incoming Webhooks app.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/687/1*ETytQo9hr40eQ1awz4DQiA.png" /></figure><ul><li>If you see an ‘App Disabled’ message while typing help, contact your admin to enable the app.</li><li>To see the commands for the webhook, type ‘help’.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/671/1*PYAPnsFCqKP8fZFqjPzRuQ.png" /><figcaption>Available commands for Incoming Webhook bot</figcaption></figure><ul><li>Go to the Channel/Group where you want to receive CodePipeline notifications. Type ‘/’ in the message box to see the available commands.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/611/1*xdHzYOe4LFdw1lX45tKh3Q.png" /></figure><ul><li>Select the connect command and enter a descriptive name for your webhook.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/692/1*iQvhzU6s_Upf4vneeRh_AA.png" /></figure><ul><li>Note the Endpoint and the verification token provided.</li></ul><p><strong>Step 2: Set Up an SNS Topic for CodePipeline Notifications</strong></p><ul><li>Navigate to the SNS service.</li><li>Click “Create topic” and select “Standard”.</li><li>Enter a name for your topic. And create the topic.</li></ul><p><strong>Step 3: Configure CodePipeline Notifications</strong></p><ul><li>Go to the CodePipeline.</li><li>Select the pipeline you want to configure.</li><li>Select “Manage notifications.”</li><li>Under “Event type,” choose the events you want to receive notifications for.</li><li>In the “Target” section, select “SNS topic” and paste the SNS topic ARN of the topic created earlier.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/730/1*u9HfqoA2u9evnHuzcztGHg.png" /></figure><p><strong>Step 4: Create a Lambda Function</strong></p><ul><li>Navigate to the Lambda service.</li><li>Click on “Create function” and choose “Author from scratch.”</li><li>Provide a name for your function and choose the runtime.</li><li>The remaining options can be left as default. Click “Create function.”</li></ul><pre>import urllib.request<br>import json<br><br>ZOOM_WEBHOOK_URL = &quot;your_zoom_webhook_url_here&quot;<br>BEARER_TOKEN = &quot;bearer_token&quot;<br><br>def lambda_handler(event, context):<br>    # Log the received event<br>    print(&quot;Received event: &quot; + json.dumps(event, indent=2))<br>    <br>    for record in event[&#39;Records&#39;]:<br>        sns_message = json.loads(record[&#39;Sns&#39;][&#39;Message&#39;])<br>        <br>        pipeline = sns_message[&#39;detail&#39;][&#39;pipeline&#39;]<br>        stage = sns_message[&#39;detail&#39;][&#39;stage&#39;]<br>        state = sns_message[&#39;detail&#39;][&#39;state&#39;]<br>        <br>        # Prepare message<br>        message = f&quot;{stage} stage for {pipeline} has {state}&quot;<br>        data = json.dumps(message).encode(&#39;utf-8&#39;)<br>        <br>        # Send the message to Zoom webhook<br>        req = urllib.request.Request(<br>            ZOOM_WEBHOOK_URL, <br>            data=data, <br>            headers={<br>                &#39;Content-Type&#39;: &#39;application/json&#39;,<br>                &#39;Authorization&#39;: f&#39;Bearer {BEARER_TOKEN}&#39;<br>            }<br>        )<br>        <br>        try:<br>            with urllib.request.urlopen(req) as response:<br>                print(&quot;Response from Zoom: &quot; + response.read().decode(&#39;utf-8&#39;))<br>        except urllib.error.URLError as e:<br>            print(f&quot;Error sending message to Zoom: {e.reason}&quot;)<br><br>    return {<br>        &#39;statusCode&#39;: 200,<br>        &#39;body&#39;: json.dumps(&#39;Notifications forwarded to Zoom&#39;)<br>    }</pre><p>Instead of pasting the URL and bearer token directly in the code, Parameter Store can be utilized.</p><p>Now, deploy the code.</p><p><strong>Step 5: Configure Lambda Function with SNS Topic</strong></p><ul><li>Add the SNS topic created earlier as the trigger for the Lambda function.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/956/1*RpFjmdvwss5NVp6K-cKXrw.png" /><figcaption>Lambda function with SNS trigger</figcaption></figure><p><strong>Step 6: Test the integration</strong></p><ul><li>Test the lambda function with a SNS template to see everything has been set up properly. Upon testing, you will receive an example event on the group/channel you configured the webhook at.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/832/1*2FtoyQSthxYms2CjYcguYg.png" /></figure><ul><li>Now either manually release change in the CodePipeline through the console, or wait for the pipeline to be triggered.</li><li>Upon changes in the pipeline, you will receive notifications for the stages you selected earlier.</li></ul><p>This integration of AWS CodePipeline notifications with the Zoom chat channel eliminates the need for constant console checks, keeps the team updated, and enhances the development workflow.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=599e63eb32e0" width="1" height="1" alt=""><hr><p><a href="https://awstip.com/connecting-aws-codepipeline-updates-to-zoom-chat-a-step-by-step-guide-599e63eb32e0">Connecting AWS CodePipeline Updates to Zoom Chat: A Step-by-Step Guide</a> was originally published in <a href="https://awstip.com/">AWS Tip</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Navigating Blue-Green Deployment: Django Apps on ECS with AWS CodePipeline]]></title>
            <link>https://towardsaws.com/navigating-blue-green-deployment-django-apps-on-ecs-with-aws-codepipeline-7770f856b8e8?source=rss-5ce4611115dc------2</link>
            <guid isPermaLink="false">https://medium.com/p/7770f856b8e8</guid>
            <category><![CDATA[aws-codepipeline]]></category>
            <category><![CDATA[aws-ecs]]></category>
            <category><![CDATA[containerization]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[blue-green-deployment]]></category>
            <dc:creator><![CDATA[Pooja Shrestha]]></dc:creator>
            <pubDate>Sun, 25 Feb 2024 18:00:52 GMT</pubDate>
            <atom:updated>2024-03-14T07:15:56.869Z</atom:updated>
            <content:encoded><![CDATA[<h3>Navigating Blue/Green Deployment: Django Apps on ECS with AWS CodePipeline</h3><p>AWS ECS (Elastic Container Service) provides three deployment types for a service to use:</p><ul><li>Rolling update</li><li>Blue/Green deployment with CodeDeploy</li><li>External Deployment</li></ul><p>For workloads that require uninterrupted operation with functionality like rollback capability, Blue/Green deployment is the suitable choice. With the B/G deployment option, verifying and validating the functioning of the latest version of an application is possible. If the latest deployment (green environment) doesn’t operate as anticipated, the traffic can be reverted to the blue environment, limiting any operational challenges.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YVQ5CjXEk0kWMKQYEd7_nw.png" /></figure><blockquote>If you want to know more about the ECS deployment options, here’s an <a href="https://cloudonaut.io/ecs-deployment-options/">article</a> from an AWS Container Hero.</blockquote><p>In this article, we will be implementing blue/green deployment for a sample Django application. The app will be deployed to ECS using CodePipeline.</p><h4>Prepare a Django Project</h4><p>Step 1: Install Python and pip</p><p>Step 2: Create a virtual environment</p><pre>python -m venv venv</pre><p>Activate the virtual environment</p><ul><li>On windows: <em>.\venv\Scripts\activate</em></li></ul><p>Step 3: Install Django</p><pre>pip install django</pre><p>Step 4: Create a Django project</p><pre>django-admin startproject ProjectName</pre><p>Navigate to the project directory</p><pre>cd ProjectName</pre><p>Step 5: Apply migrations</p><pre>python manage.py migrate</pre><p>Step 6: Run the server</p><pre>python manage.py runserver</pre><p>You can access the project’s welcome page at <a href="http://127.0.0.1:8000/">http://127.0.0.1:8000/</a></p><h4>Create a repository</h4><p>I have created a Bitbucket repository for this project.</p><p>Step 1: Go to <a href="https://bitbucket.org/">bitbucket.org</a> and create a repository.</p><p>Step 2: Go to your folder directory and initialize as a git repository.</p><pre>git init</pre><p>Step 3: Add a remote repository reference.</p><pre>git remote add origin &lt;remote_repository_URL&gt;</pre><p>Step 4: Push the code to the repository.</p><pre>git add .<br>git commit -m &quot;your-comment&quot;<br>git push origin main</pre><blockquote><em>If you face issues while pushing, try “</em><strong>git pull origin main</strong><em>”.</em></blockquote><blockquote><em>If the issue still persists with error “Refusing to Merge Unrelated Histories”, try “</em><strong>git pull origin main — allow-unrelated-histories</strong><em>” and enter the above commands again.</em></blockquote><h4>Let’s get ECS ready</h4><p><strong>Step 1: Set up a registry for container images</strong></p><ul><li>Go to the ECR console. Make sure you are in the region you intend to deploy your resources in.</li><li>Select <strong>‘Create repository’</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/841/1*yuKVW9BHnMJ0HIkGmhYLbg.png" /></figure><p><strong>Step 2: Push the image to ECR</strong></p><ul><li>Select the repository created. On the top right side, we can view the push commands.</li><li>Follow the instructions and push the image.</li></ul><p><strong>Step 3: Create an ECS cluster</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/860/1*WyetYr7_7e9lRMVgWUdqLw.png" /><figcaption>Cluster configuration</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/806/1*utht016w-jZamXgHKQUP1w.png" /><figcaption>Infrastructure configuration</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/846/1*pi5myXmw-izF8Z9GeqRZWg.png" /></figure><p>You can either create a custom VPC or select the default one. (<em>Custom VPC is preferred)</em></p><p><strong>Step 4: Create a Load Balancer</strong></p><p>Since we are implementing blue/green deployment, we will require a load balancer in order to distribute traffic among the tasks in our service.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MywVgWTN-IfH_jecOA5TPw.png" /></figure><p>For network mapping, select any two availability zones.</p><p>Select the security group of your choice.</p><p>Create a target group for targets that are designated to receive traffic from the load balancer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*niaQD2WyM8XKp-JIXRr_aQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/792/1*hZd-IPzUErt-fp6z0gH0gA.png" /></figure><p>Add another listener for test listener purposes, and create the load balancer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*517NyFNykuvMzzoX-j7xPQ.png" /></figure><p><strong>Step 5: Create a task definition</strong></p><p>Go to the Task definitions section via the ECS console.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*z9Z-lL-GBLNMbekjiek4sg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*i6SPnausZtFWfeaqaY8kDQ.png" /></figure><blockquote><a href="https://tutorialsdojo.com/ecs-network-modes-comparison/">This article</a> can help choose between the different network modes available.</blockquote><p>Give the name to your container and also provide the link to the image in the repo created earlier, in the container section.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JVmaiCpqizCbaU28l6NzJQ.png" /><figcaption>Container configuration</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/775/1*3JkERrrLZTrAEkpeSAZsqQ.png" /></figure><p>Now, create the task definition.</p><p>After the definition is created, you can download the JSON version and integrate with your code.</p><p><strong>Step 6: Create a service</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FOIPD2VMaO1fVa1OFCIXyA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yjyD8baM92hTcBhT-rgIVQ.png" /></figure><p>Select the Blue/green deployment type.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/882/1*Btdi5Ibc-NPwQ_eUC4vxGA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/934/1*ydvY_mhoak-gWjS3VbvoWg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/904/1*eflTo0jO4LenT10xGZymSg.png" /></figure><p>Now, create the service.</p><h4>Prepare the Pipeline</h4><p>Go to the CodePipeline and click on Create Pipeline.</p><p><strong>Step 1: Choose pipeline settings</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/812/1*RDmgoZlek0x_ZlQur6zlbw.png" /></figure><p><strong>Step 2: Add the source</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3FaSd4qsFyEKH69lW9pGIQ.png" /></figure><p><strong>Step 3: Add the build stage</strong></p><p>While creating a build project, you can either give the build commands, or create a buildspec file.</p><pre>version: 0.2<br><br>phases:<br>  pre_build:<br>    commands:<br>      - echo Logging in to Amazon ECR...<br>      - aws --version<br>      - aws ecr get-login-password --region your-aws-region | docker login --username AWS --password-stdin account-id.dkr.ecr.your-aws-region.amazonaws.com<br>      - REPOSITORY_URI=account-id.dkr.ecr.your-aws-region.amazonaws.com/repo-name<br>      - COMMIT_HASH=$(echo $CODEBUILD_RESOLVED_SOURCE_VERSION | cut -c 1-7)<br>      - IMAGE_TAG=${COMMIT_HASH:=latest}<br>  build:<br>    commands:<br>      - echo Build started on `date`<br>      - echo Building the Docker image...<br>      - docker build -t $REPOSITORY_URI:latest .<br>      - docker tag $REPOSITORY_URI:latest $REPOSITORY_URI:$IMAGE_TAG<br>  post_build:<br>    commands:<br>      - echo Build completed on `date`<br>      - echo Pushing the Docker images...<br>      - docker push $REPOSITORY_URI:latest<br>      - docker push $REPOSITORY_URI:$IMAGE_TAG<br>      - echo Writing image definitions file...<br>      - printf &#39;[{&quot;name&quot;:&quot;Container&quot;,&quot;imageUri&quot;:&quot;%s&quot;}]&#39; $REPOSITORY_URI:$IMAGE_TAG &gt; imageDetail.json<br>artifacts:<br>    files: <br>      - imageDetail.json<br>      - appspec.yaml<br>      - taskdef.json</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/845/1*IHXb2lcsv1XpN4UqydXiFg.png" /></figure><p><strong>Step 4: Add deploy stage</strong></p><p>Select Amazon ECS (blue/green) as your deploy provider.</p><p>When configuring an ECS service with blue/green deployment, CodeDeploy automatically generates an application and a deployment group.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/734/1*UTCit_KcuwNCNJY2HaSddw.png" /></figure><p>While configuring the deploy stage, in order to specify how to deploy the application on the target environment, we require appspec file.</p><p>We have the appspec.yaml file as:</p><pre>version: 0.0<br>Resources:<br>  - TargetService:<br>      Type: AWS::ECS::Service<br>      Properties:<br>        TaskDefinition: &lt;TASK_DEFINITION&gt;<br>        LoadBalancerInfo:<br>          ContainerName: &quot;your-container-name&quot;<br>          ContainerPort: 8000</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/798/1*AE3kSeBCBoZ2O3U_E_fcbg.png" /></figure><p>In the next step, review the selections for the pipeline to be created. If everything looks as expected, create the pipeline.</p><p>After the pipeline is set up, you should be able to view the Django homepage on the load balancer’s DNS name.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wvnE3wKrelc_rjkMOK1kgQ.png" /><figcaption>Deployment status</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GUQ1XnR3dWi018aucz6fvg.png" /></figure><p>Following the setup, every push on the selected branch of your selected repository will trigger the pipeline.</p><p>After the new deployment, we can see if the application functions as expected on the test listener port we set while creating the ECS service.</p><p>We can also select the duration CodeDeploy should wait to terminate the original taskset in the Deployment group’s configuration.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/817/1*tS8YwqhG9QbozUFjaabT2A.png" /></figure><p>This setup of integrating blue-green deployment with CodePipeline automates the entire deployment process. With reduced downtime and rollback capability, it offers a robust application deployment method with minimal disruption and maximum reliability.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7770f856b8e8" width="1" height="1" alt=""><hr><p><a href="https://towardsaws.com/navigating-blue-green-deployment-django-apps-on-ecs-with-aws-codepipeline-7770f856b8e8">Navigating Blue-Green Deployment: Django Apps on ECS with AWS CodePipeline</a> was originally published in <a href="https://towardsaws.com/">Towards AWS</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Getting my first AWS Certification - Solutions Architect Associate (SAA-C03)]]></title>
            <link>https://medium.com/@pooja_shrestha/getting-my-first-aws-certification-solutions-architect-associate-saa-c03-4a05afcc26d9?source=rss-5ce4611115dc------2</link>
            <guid isPermaLink="false">https://medium.com/p/4a05afcc26d9</guid>
            <category><![CDATA[aws-certification]]></category>
            <category><![CDATA[solutions-architecture]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[udemy]]></category>
            <category><![CDATA[saa-c03]]></category>
            <dc:creator><![CDATA[Pooja Shrestha]]></dc:creator>
            <pubDate>Thu, 04 May 2023 08:33:12 GMT</pubDate>
            <atom:updated>2023-05-04T08:33:12.523Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*r0cA9E2MRQDfC25-IaCVnQ.jpeg" /></figure><p>After contemplating for months on if I was prepared enough for certification, I finally decided to go for it. Here’s my experience getting my first AWS certification, Solutions Architect — Associate.</p><p>Lately, there have been discussions over if certifications are worth it. Certifications can cost a sum and there is no guarantee that they demonstrate practical knowledge of the work in real-world scenarios. And since preparing for certification also requires time, people don’t think investing all the effort is worth it. The opinions had me thinking about the pros and cons. But, after some thinking and discussion with seniors who have acquired certifications before, I decided to go for it. And, I am glad I did!</p><h4><strong><em>I think certifications are totally worth it!</em></strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*FnGXMFU14szUZndwv5nwQA.gif" /></figure><ul><li>On a day-to-day basis, there are only a certain set of services that we deal with. Unless we deal with a situation that requires us to look for new services, we usually don’t do so. For me, prepping for the certification, got me introduced to various new services. Not just the new resources, but even with the services I used on a daily basis, I found out that there were a lot of features that I hadn’t explored.</li><li>Since the questions are scenario based, it’s not enough if we just know about the service and its functionality. We should also know for which problems does that service bring the best, optimized solution. This sometimes was tricky and made the learning curve more exciting.</li><li>The obvious advantage is the validation it provides indicating that you know the services and are familiar with the platform.</li><li>If a student with certification goes to the job market, they are obviously noticed more than the others. Even a basic certification hints that they are aware of what the job is going to be like.</li><li>For a professional, certifications prove your skill and showcase your commitment to professional growth.</li></ul><p>So, to sum it up, I think certifications are worth it!</p><h4><strong>My preparation journey</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*kgl6muUtKAk9iJmxbG6vlQ.gif" /></figure><p>I began with the Cloud Architecting course from AWS Academy. The course, however, doesn’t include much of the SAA syllabus.</p><p>After that, I followed the <a href="https://www.udemy.com/course/aws-certified-solutions-architect-associate-saa-c03/">SAA-C03 preparation course by Stephane Maarek</a>. The course alone is enough for the exam if you follow everything taught and revise the course slides thoroughly. The course includes basic to advanced concepts. Stephane explains in simple terms and goes through every concept. Labs are also included in the course, where he shows the process of resource creation and deletion as well. The course consists of a practice exam at the end of the course. After taking the exam, you will see the detailed reasons for the correct as well as incorrect answers. I scored 61% on my first attempt.</p><p><a href="https://www.examtopics.com/exams/amazon/aws-certified-solutions-architect-associate-saa-c03/view/1/">Examtopics</a> was also one of the useful resources I went through. I practiced with around 150 questions there. The questions helped me know the topics I needed to revise. The downside is that you wouldn’t know the actual answer. The right answer marked and the ‘most voted’ answer were different in many cases, which led to confusion. But, if you see topics you haven’t studied or remember, that’s an opportunity to revise.</p><p>While preparing I was a regular visitor of the <a href="https://www.reddit.com/r/AWSCertifications/">AWS Certification subreddit</a>. Once upon scrolling, I saw an offer of a Udemy Exam preparation course being free for a few days. <a href="https://www.udemy.com/course/aws-solutions-architect-associate-practice-exams-2023/">AWS Solutions Architect Associate Practice Exams 2023 by Kevin Knowledge Hub</a>. It has 4 practice sets. I’d say this helped me way more than I had expected. The question patterns were similar to the real exam questions I attended later. It also includes well-explained solutions, which helps to analyze where you went wrong.</p><p>These 4 resources were the only ones that I followed and I’d say they might come across as a few of the best resources to prepare for SAA-C03.</p><h4><strong>Exam Tips</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/1*2X4kX8wkfbtBFu9Zack_IA.gif" /></figure><ul><li>Before booking the exam, take advantage of the accommodation AWS provides for non-native speakers. 30 minutes of extra time is granted, and personally, that helped me be calm during the exam, knowing I would have ample time to understand the questions.</li><li>Read the instructions fully before starting the exam.</li><li>Read the questions carefully. If your attention diverts midway, don’t panic. Try to be more attentive the next time.</li><li>Process of Elimination was the most helpful technique for me.</li><li>Select the answers as if you won’t get to review them later. This doesn’t mean spending 5 minutes on a question, but do not tick carelessly thinking you’ll correct it in the review process. I have heard of incidents where the examinees ended the exam accidentally.</li><li>Flag the questions where you are not fully sure if the answer is correct. You can view the flagged-only questions later in the review.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/955/1*4_Zb4HKDRq_-pZBuqcMjtg.png" /><figcaption>Exam Results</figcaption></figure><p>The exam has surely increased my confidence regarding my knowledge (for someone with Imposter Syndrome, this is quite a win). So, I would say that the journey and the accomplishment were worth the time and effort.</p><p>If you are planning for your certification, I wish you all the very best!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4a05afcc26d9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Migrating a PHP 5.5.27 and MySQL 5.6.25 application to AWS EC2]]></title>
            <link>https://medium.com/@pooja_shrestha/migrating-a-php-5-5-27-and-mysql-5-6-25-application-to-aws-fd4f195a12e5?source=rss-5ce4611115dc------2</link>
            <guid isPermaLink="false">https://medium.com/p/fd4f195a12e5</guid>
            <category><![CDATA[php]]></category>
            <category><![CDATA[migration]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[ec2-instance]]></category>
            <category><![CDATA[mysql]]></category>
            <dc:creator><![CDATA[Pooja Shrestha]]></dc:creator>
            <pubDate>Fri, 07 Apr 2023 06:24:13 GMT</pubDate>
            <atom:updated>2024-02-25T18:03:53.659Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://w3techs.com/technologies/details/pl-php/7">W3Techs </a>reports that 77.5% of the web uses PHP as their server-side language. If you are considering migrating your PHP site to AWS, you have landed in the right place.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ON66ER7wmvBrOFkH1H2qVA.jpeg" /></figure><p><strong>Why move to AWS?</strong></p><ul><li>Pay-as-you-go pricing</li><li>Instant hosting facility</li><li>Can serve customers globally</li></ul><p>However, while migrating applications with older versions, we face various inconveniences and incompatibility problems. A similar issue was encountered while working on a recent project of moving an application with PHP 5.5.27 and MySQL 5.6.25 to AWS. Here’s how it was solved!</p><p><strong>Versions discussed on this blog:</strong></p><p>PHP version — 5.5.27</p><p>Mysql version — 5.6.48 (Also supports 5.6.25)</p><h3><strong>Launching EC2 instance</strong></h3><p>Launch an EC2 instance with the following configuration:</p><p><strong>OS: Ubuntu 20.04</strong></p><p><strong>Instance type: t2.small</strong></p><p>You can utilize the default VPC and security groups, but it is recommended to create custom resources.</p><p>With default VPC, we do not have to configure internet gateways and routes, and Internet access is provided by default. However, it might not meet all the security best practices.</p><p>Here, I am using the default VPC but creating a custom security group.</p><ul><li>Allow SSH traffic from My IP.</li><li>Allow HTTP and HTTPS traffic from the internet</li></ul><p>Storage: 30GB SSD</p><p><strong>SSHing into the instance</strong></p><p>After the EC2 instance state is running and the status check is passed,</p><ol><li>Select the instance and click on Connect.</li><li>Go to the SSH Client section.</li><li>Connect to the instance as:</li></ol><pre>ssh -i [pem-file] [public DNS]</pre><p>The command can also be found under the Example section.</p><p>4. Go to your CLI and move to the directory where your key file (.pem file) resides.</p><p>5. Enter the copied command on CLI.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/749/1*FoS4ZgWLTHb8hknCYdqnoA.jpeg" /><figcaption>SSHing into the instance</figcaption></figure><p><strong>Installing Apache server</strong></p><p>We need to have an Apache environment to run PHP. So installing Apache:</p><pre>sudo apt install apache2</pre><p><strong>Installing PHP</strong></p><p>Check to see if your instance has PHP pre-installed. Since we are using an older version here, if we have any versions pre-installed, we have to remove them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/477/0*u8senGxObEwHKnsl" /><figcaption>No older versions installed</figcaption></figure><p>Since I don’t have any installed, I am moving to the installation process.</p><p>To get the required PHP version, you can go to <a href="https://www.php.net/distributions/">https://www.php.net/distributions/ </a>and search for it.</p><p>Execute the following commands (explanations below):</p><pre>wget https://www.php.net/distributions/php-5.5.27.tar.bz2<br><br>tar xvf php-5.5.27.tar.bz2<br><br>cd php-5.5.27<br><br>apt install gcc<br><br>./configure</pre><p>Upon running ./configure, I got an error: <em>configure: error: xml2-config not found. Please check your libxml2 installation.</em></p><p>It was solved with:</p><pre>apt-get install libxml2-dev</pre><p>Then run the following commands:</p><pre>./configure<br><br>apt install make<br><br>make<br><br>make test<br><br>make install<br><br>php -v</pre><p>Explaining the commands:</p><p><strong>wget </strong>command allows you to download contents from the web.</p><p><strong>tar </strong>command generally manipulates the archive files.</p><p><strong>tar xvf</strong> here extracts the content of php-5.5.27.tar.bz2 to the current directory.</p><p><strong>./configure</strong> is a build step required while installing software from source code.</p><p>After ./configure, we run <strong>make </strong>commands to compile the software.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/848/0*3cTwd_4rRR7zLU-U" /><figcaption>Checking PHP version</figcaption></figure><p>Now, installing MySQL,</p><pre>wget https://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-server_5.6.48-1debian9_amd64.deb-bundle.tar<br><br>tar xvf mysql-server_5.6.48–1debian9_amd64.deb-bundle.tar<br><br>sudo add-apt-repository &#39;deb http://archive.ubuntu.com/ubuntu trusty universe&#39;<br><br>sudo apt-get update<br><br>apt - fix-broken install<br><br>mysql -V</pre><p>The <strong>universe </strong>component in line 3 contains the software packages managed by the community that is not supported by Ubuntu officially.</p><p>Due to the old versions being used in the system, many issues were encountered during the installation process, thus the additional downloads.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/991/0*YIr6ZJASdjZZ0uz0" /><figcaption>Checking MySQL version</figcaption></figure><p>Now let’s test the server. Copy the public IP address of your instance and paste it into the browser. Make sure you are on HTTP as we don’t have SSL as of yet.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ZN3LDMOGS47QDzD_" /><figcaption>Apache has been successfully installed</figcaption></figure><p>Now let’s test PHP.</p><p>Head to <em>/var/www/html</em> and create a php file.</p><pre>nano phpinfo.php<br><br>echo &quot;&lt;?php phpinfo(); ?&gt;&quot; &gt; phpinfo.php</pre><p>Now, add /phpinfo.php after the IP. You should be seeing PHP’s info page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/873/0*Ay0rtSLQxYBIL5F3" /><figcaption>Source code being displayed instead of PHP info page</figcaption></figure><p>Here, we are seeing the source code directly instead of the page. Upon research, it was found that there were some version issues.</p><p>How to solve:</p><pre>add-apt-repository ppa:ondrej/php<br><br>sudo apt-get update<br><br>sudo apt-get install php5.6 php5.6-mysql php5.6-gd php5.6-mcrypt php5.6-mbstring php5.6-sqlite3 apache2 libapache2-mod-php5.6</pre><p>Here, we have added ondrej/ppa repo to our system. PPA distributes software and updates that are unofficial to Ubuntu.</p><p>After that, we added the selected 5.6 libraries required, except for the bin file.</p><p>Now checking the phpinfo again,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*VOvaxKh09_tR3xfz" /><figcaption>PHP successfully installed</figcaption></figure><p>Here, the browser phpinfo shows the version to be 5.6.4, however on the command line, it still displays 5.5.27. The libraries have been updated to 5.6.4, but the overall version stays to be 5.5.27.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/818/0*UB9_nlKvvGLz7_az" /><figcaption>Checking PHP version</figcaption></figure><p>Now, to transfer our files, we can use WinSCP. You can download it from <a href="https://winscp.net/eng/download.php">here</a>.</p><p>You will see a screen similar to the following screenshot.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*NgggDwki1LTYmHdn" /></figure><p>Click on New Session.</p><p>Change the protocol to SCP.</p><p>Enter the hostname (public DNS).</p><p>Click on Advanced.</p><p>To log in as a root user, which you might require to transfer files, Go to SCP/Shell and choose sudo su - as shown.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/686/0*dRMY_90ds15o71hG" /></figure><p>Then go to the Authentication section and upload your .pem file.</p><p>Click on Ok and then connect to the session. You might be prompted to enter a username. For Ubuntu instances, it’s <strong>ubuntu</strong>. Then, you will be connected.</p><p>Direct to /var/www/html and upload your files there.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/663/0*DznA3xJIgFDJ2b91" /></figure><p>After migrating the files, configure the database, and voila! Your site will be instantly up and running on AWS.</p><p>Post the migration, you can install SSL certificates and the site will be accessed via HTTPS as well.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fd4f195a12e5" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>