<?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 Dibya Darshan Khanal on Medium]]></title>
        <description><![CDATA[Stories by Dibya Darshan Khanal on Medium]]></description>
        <link>https://medium.com/@dibaekhanal101?source=rss-f814343e861a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*uS69IfBoCOd_kRLPAXEJjA.jpeg</url>
            <title>Stories by Dibya Darshan Khanal on Medium</title>
            <link>https://medium.com/@dibaekhanal101?source=rss-f814343e861a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 06:03:14 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@dibaekhanal101/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[Building a Batch Processing System with AWS Bedrock: A Practical Guide]]></title>
            <link>https://medium.com/@dibaekhanal101/building-a-batch-processing-system-with-aws-bedrock-a-practical-guide-1a1ecf29d238?source=rss-f814343e861a------2</link>
            <guid isPermaLink="false">https://medium.com/p/1a1ecf29d238</guid>
            <category><![CDATA[amazon-bedrock]]></category>
            <category><![CDATA[batch-processing]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[automation]]></category>
            <dc:creator><![CDATA[Dibya Darshan Khanal]]></dc:creator>
            <pubDate>Sun, 08 Nov 2026 01:33:14 GMT</pubDate>
            <atom:updated>2026-11-08T01:33:14.558Z</atom:updated>
            <content:encoded><![CDATA[<h3>Building a Batch Processing System with AWS Bedrock: A Practical Guide</h3><p>As an Graduate Student of Computer Science and researcher, I’ve been exploring various AI/ML services across cloud providers. While working with Azure OpenAI’s batch processing and Google’s Gemini API, I became curious about AWS Bedrock’s batch inference capabilities. This article chronicles my journey building a batch processing system for AWS Bedrock, including the challenges, solutions, and infrastructure automation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fF2iP0svi7Nu399VZYTWHQ.png" /></figure><h3>The Big Picture: Why Batch Processing?</h3><p>Batch processing for Large Language Models (LLMs) offers significant advantages:</p><ul><li><strong>Cost Savings</strong>: Up to 50% reduction compared to real-time API calls</li><li><strong>Efficiency</strong>: Process thousands of requests without rate limiting concerns</li><li><strong>Asynchronous Processing</strong>: Submit jobs and retrieve results when ready</li><li><strong>Resource Optimization</strong>: Better for non-time-sensitive workloads</li></ul><p>This pattern is common across major AI providers:</p><ul><li><strong>Azure OpenAI</strong>: Batch API with Global-Batch SKU</li><li><strong>Google Gemini</strong>: Batch prediction API</li><li><strong>AWS Bedrock</strong>: Model invocation jobs</li></ul><h3>The Initial Goal</h3><p>I wanted to build a Python-based batch processor that could:</p><ol><li>Accept multiple prompts/questions</li><li>Submit them as a batch job to AWS Bedrock</li><li>Monitor the job progress for up to 24 hours</li><li>Download and format results in JSON</li></ol><p>The use case? Processing large volumes of questions for documentation, research, or data analysis tasks where immediate responses aren’t critical.</p><h3>Architecture Overview</h3><p>The system consists of three main components:</p><ul><li>Prompt.py — to ask to LLM using processor batch script</li><li>S3 bucket — to store json input and output of batch jobs</li><li>Bedrock Batch Job</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/386/1*-M4m-vOGm6jygkWD__QtOw.png" /></figure><p><strong>Infrastructure Setup with CloudFormation</strong></p><p>Rather than manually configuring IAM roles, S3 buckets, and permissions, I created a CloudFormation template to automate the entire infrastructure setup.</p><h3>What the CloudFormation Template Creates</h3><pre>Resources:<br>  1. S3 Bucket (with versioning and lifecycle policies)<br>  2. IAM Role for Bedrock (allows Bedrock to access S3)<br>  3. IAM User for Script Execution (with access keys)<br>  4. Policies and Permissions (least privilege access)</pre><h3>Key Components Explained</h3><p><strong>1. S3 Bucket Configuration</strong></p><pre>BatchProcessingBucket:<br>  Type: AWS::S3::Bucket<br>  Properties:<br>    VersioningConfiguration:<br>      Status: Enabled<br>    LifecycleConfiguration:<br>      Rules:<br>        - ExpirationInDays: 30  # Auto-cleanup old files</pre><p>The bucket stores:</p><ul><li>Input: JSONL files with batch requests</li><li>Output: JSONL files with model responses</li></ul><p><strong>2. IAM Role for Bedrock</strong></p><pre>BedrockBatchRole:<br>  Type: AWS::IAM::Role<br>  Properties:<br>    AssumeRolePolicyDocument:<br>      Principal:<br>        Service: bedrock.amazonaws.com<br>    Policies:<br>      - S3 Read/Write access to batch bucket</pre><p>This role allows Bedrock service to:</p><ul><li>Read input files from S3</li><li>Write output files to S3</li><li>Nothing more (security best practice)</li></ul><p><strong>3. IAM User for Script</strong></p><pre>BatchProcessingUser:<br>  Type: AWS::IAM::User<br>  Policies:<br>    - Bedrock API access<br>    - S3 bucket access<br>    - PassRole permission</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2QqSQ_mKo6hEiKaX3jCY6Q.png" /></figure><h3>Deploying the Infrastructure</h3><p>The deployment is straightforward:</p><pre># Deploy CloudFormation stack<br>aws cloudformation create-stack \<br>  --stack-name bedrock-batch-processing \<br>  --template-body file://cloudformation-bedrock-batch.yaml \<br>  --capabilities CAPABILITY_NAMED_IAM \<br>  --region us-east-1</pre><pre># Wait for completion<br>aws cloudformation wait stack-create-complete \<br>  --stack-name bedrock-batch-processing \<br>  --region us-east-1</pre><pre># Get outputs (credentials, bucket name, role ARN)<br>aws cloudformation describe-stacks \<br>  --stack-name bedrock-batch-processing \<br>  --query &#39;Stacks[0].Outputs&#39;</pre><p>The CloudFormation outputs provide everything needed for the .env file:</p><ul><li>AWS Access Key ID</li><li>AWS Secret Access Key</li><li>S3 Bucket Name</li><li>Bedrock Role ARN</li><li>AWS Region</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SCxW34hdsI8JtIFe7d2lDA.png" /></figure><h3>The Code: Batch Processing Implementation</h3><h3>Project Structure</h3><pre>batch/<br>├── bedrock_batch_processor.py        # Batch processing (requires approval)<br>├── bedrock_standard_processor.py     # Standard API (works immediately)<br>├── prompts.py                        # Questions to process<br>├── cloudformation-bedrock-batch.yaml # Infrastructure as Code<br>├── .env                              # Configuration (not in git)<br>├── .env.bedrock.example              # Template<br>├── requirements.txt                  # Dependencies<br>└── README.md                         # Documentation</pre><h3>Understanding the Batch Processor Code</h3><p><strong>Step 1: Setup and Configuration</strong></p><pre>import boto3<br>from dotenv import load_dotenv</pre><pre>load_dotenv()</pre><pre># Initialize Bedrock client<br>bedrock = boto3.client(<br>    service_name=&#39;bedrock&#39;,<br>    region_name=os.getenv(&quot;AWS_REGION&quot;),<br>    aws_access_key_id=os.getenv(&quot;AWS_ACCESS_KEY_ID&quot;),<br>    aws_secret_access_key=os.getenv(&quot;AWS_SECRET_ACCESS_KEY&quot;)<br>)</pre><pre># Initialize S3 client<br>s3 = boto3.client(<br>    service_name=&#39;s3&#39;,<br>    region_name=os.getenv(&quot;AWS_REGION&quot;),<br>    aws_access_key_id=os.getenv(&quot;AWS_ACCESS_KEY_ID&quot;),<br>    aws_secret_access_key=os.getenv(&quot;AWS_SECRET_ACCESS_KEY&quot;)<br>)</pre><p><strong>Step 2: Creating Batch Input File</strong></p><p>The input format follows Bedrock’s batch inference specification:</p><pre>from prompts import questions</pre><pre>batch_requests = []<br>for i, question in enumerate(questions, 1):<br>    batch_requests.append({<br>        &quot;recordId&quot;: f&quot;request-{i}&quot;,<br>        &quot;modelInput&quot;: {<br>            &quot;anthropic_version&quot;: &quot;bedrock-2023-05-31&quot;,<br>            &quot;max_tokens&quot;: 1024,<br>            &quot;messages&quot;: [<br>                {<br>                    &quot;role&quot;: &quot;user&quot;,<br>                    &quot;content&quot;: question<br>                }<br>            ]<br>        }<br>    })</pre><pre># Write to JSONL (one JSON object per line)<br>with open(&quot;bedrock_batch_input.jsonl&quot;, &#39;w&#39;) as f:<br>    for request in batch_requests:<br>        f.write(json.dumps(request) + &#39;\n&#39;)</pre><p>Each line in the JSONL file is a separate request with:</p><ul><li>recordId: Unique identifier for tracking</li><li>modelInput: Model-specific request format (Claude in this case)</li></ul><p><strong>Step 3: Uploading to S3</strong></p><pre>bucket_name = os.getenv(&quot;S3_BUCKET_NAME&quot;)<br>input_key = f&quot;batch-input/bedrock_batch_input.jsonl&quot;<br>output_prefix = f&quot;batch-output/{datetime.now().strftime(&#39;%Y%m%d-%H%M%S&#39;)}&quot;</pre><pre># Upload input file<br>s3.upload_file(&quot;bedrock_batch_input.jsonl&quot;, bucket_name, input_key)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YHcoNazfLFAZ9Ua1EO7cRg.png" /></figure><p><strong>Step 4: Creating the Batch Job</strong></p><pre>response = bedrock.create_model_invocation_job(<br>    roleArn=os.getenv(&quot;BEDROCK_ROLE_ARN&quot;),<br>    modelId=os.getenv(&quot;BEDROCK_MODEL_ID&quot;),<br>    jobName=f&quot;batch-job-{datetime.now().strftime(&#39;%Y%m%d-%H%M%S&#39;)}&quot;,<br>    inputDataConfig={<br>        &quot;s3InputDataConfig&quot;: {<br>            &quot;s3Uri&quot;: f&quot;s3://{bucket_name}/{input_key}&quot;<br>        }<br>    },<br>    outputDataConfig={<br>        &quot;s3OutputDataConfig&quot;: {<br>            &quot;s3Uri&quot;: f&quot;s3://{bucket_name}/{output_prefix}&quot;<br>        }<br>    }<br>)</pre><pre>job_arn = response[&#39;jobArn&#39;]</pre><p>Key parameters:</p><ul><li>roleArn: IAM role allowing Bedrock to access S3</li><li>modelId: Which Bedrock model to use (Claude, Llama, Titan, etc.)</li><li>inputDataConfig: S3 location of input JSONL</li><li>outputDataConfig: S3 location for output files</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rBb3j9HZGQxCIImGIcb5ag.png" /></figure><p><strong>Step 5: Monitoring Job Progress</strong></p><pre>start_time = time.time()<br>max_wait_time = 24 * 60 * 60  # 24 hours<br>check_interval = 60  # Check every 60 seconds</pre><pre>status = &quot;InProgress&quot;<br>while status in [&quot;InProgress&quot;, &quot;Submitted&quot;]:<br>    elapsed_time = time.time() - start_time<br>    <br>    if elapsed_time &gt;= max_wait_time:<br>        print(&quot;24 hours elapsed. Job still in progress.&quot;)<br>        break<br>    <br>    time.sleep(check_interval)<br>    job_details = bedrock.get_model_invocation_job(jobIdentifier=job_arn)<br>    status = job_details[&#39;status&#39;]<br>    <br>    hours = int(elapsed_time // 3600)<br>    minutes = int((elapsed_time % 3600) // 60)<br>    print(f&quot;Status: {status} (Elapsed: {hours}h {minutes}m)&quot;)</pre><p>The script polls the job status every 60 seconds, displaying:</p><ul><li>Current status (Submitted, InProgress, Completed, Failed)</li><li>Elapsed time</li><li>Progress information (if available)</li></ul><p><strong>Step 6: Retrieving Results</strong></p><pre>if status == &quot;Completed&quot;:<br>    # List output files in S3<br>    response = s3.list_objects_v2(<br>        Bucket=bucket_name,<br>        Prefix=output_prefix<br>    )<br>    <br>    # Download and parse results<br>    for obj in response[&#39;Contents&#39;]:<br>        if obj[&#39;Key&#39;].endswith(&#39;.jsonl.out&#39;):<br>            s3.download_file(bucket_name, obj[&#39;Key&#39;], local_file)<br>            <br>            with open(local_file, &#39;r&#39;) as f:<br>                for line in f:<br>                    result = json.loads(line)<br>                    # Extract answer from modelOutput<br>                    content = result[&#39;modelOutput&#39;][&#39;content&#39;][0][&#39;text&#39;]<br>                    results.append({<br>                        &quot;request_id&quot;: result[&#39;recordId&#39;],<br>                        &quot;status&quot;: &quot;success&quot;,<br>                        &quot;answer&quot;: content,<br>                        &quot;usage&quot;: result[&#39;modelOutput&#39;][&#39;usage&#39;]<br>                    })<br>    <br>    # Save as formatted JSON<br>    with open(f&quot;bedrock_results_{timestamp}.json&quot;, &#39;w&#39;) as f:<br>        json.dump({<br>            &quot;job_arn&quot;: job_arn,<br>            &quot;total_requests&quot;: len(results),<br>            &quot;results&quot;: results<br>        }, f, indent=2)</pre><h3>The Challenge: Batch Inference Requires Approval</h3><p>When I first ran the batch processor, I encountered this error:</p><pre>ValidationException: Your account is not authorized to perform this action. <br>Please create a support case with details about your use case.</pre><p><strong>What I learned:</strong></p><ul><li>AWS Bedrock batch inference is not enabled by default</li><li>It requires explicit approval from AWS Support</li><li>This is different from standard Bedrock API access</li><li>Even AWS Community Builder credits (I was a CB for previous year) don’t automatically grant batch access</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uZ-ozDZr72AgIBygfr0s2Q.png" /></figure><p>This mirrors how Azure OpenAI requires specific SKU types (Global-Batch or Data Zone Batch) for batch processing, not just any deployment.</p><h3>The Solution: Standard Processing Alternative</h3><p>While waiting for batch approval, I created a standard processing version that works immediately:</p><pre># bedrock_standard_processor.py<br>bedrock_runtime = boto3.client(service_name=&#39;bedrock-runtime&#39;, ...)</pre><pre>for question in questions:<br>    request_body = {<br>        &quot;anthropic_version&quot;: &quot;bedrock-2023-05-31&quot;,<br>        &quot;max_tokens&quot;: 1024,<br>        &quot;messages&quot;: [{&quot;role&quot;: &quot;user&quot;, &quot;content&quot;: question}]<br>    }<br>    <br>    response = bedrock_runtime.invoke_model(<br>        modelId=os.getenv(&quot;BEDROCK_MODEL_ID&quot;),<br>        body=json.dumps(request_body)<br>    )<br>    <br>    answer = json.loads(response[&#39;body&#39;].read())[&#39;content&#39;][0][&#39;text&#39;]</pre><p><strong>Key differences:</strong></p><ul><li>Uses bedrock-runtime client instead of bedrock</li><li>Calls invoke_model() instead of create_model_invocation_job()</li><li>No S3 upload/download needed</li><li>Processes requests sequentially</li><li>Works without special approval</li><li>No cost savings (standard pricing)</li></ul><h3>Getting Started: Step-by-Step Guide</h3><h3>Prerequisites</h3><ol><li><strong>AWS Account</strong> with Bedrock access</li><li><strong>Python 3.9+</strong> installed</li><li><strong>AWS CLI</strong> configured</li><li><strong>Boto3</strong> library</li></ol><h3>Installation</h3><pre># Clone the repository<br>git clone https://github.com/yourusername/bedrock-batch-processing.git<br>cd bedrock-batch-processing</pre><pre># Create virtual environment<br>python3 -m venv .venv<br>source .venv/bin/activate  # On Windows: .venv\Scripts\activate</pre><pre># Install dependencies<br>pip install -r requirements.txt</pre><h3>Configuration</h3><p><strong>1. Deploy Infrastructure</strong></p><pre>aws cloudformation create-stack \<br>  --stack-name bedrock-batch-processing \<br>  --template-body file://cloudformation-bedrock-batch.yaml \<br>  --capabilities CAPABILITY_NAMED_IAM \<br>  --region us-east-1</pre><p><strong>2. Get Configuration Values</strong></p><pre>aws cloudformation describe-stacks \<br>  --stack-name bedrock-batch-processing \<br>  --query &#39;Stacks[0].Outputs&#39;</pre><p><strong>3. Create .env File</strong></p><p>Copy the outputs to .env:</p><pre>AWS_ACCESS_KEY_ID=AKIA...<br>AWS_SECRET_ACCESS_KEY=...<br>AWS_REGION=us-east-1<br>BEDROCK_MODEL_ID=anthropic.claude-3-sonnet-20240229-v1:0<br>BEDROCK_ROLE_ARN=arn:aws:iam::123456789:role/bedrock-role<br>S3_BUCKET_NAME=bedrock-batch-1234567890</pre><p><strong>4. Add Your Questions</strong></p><p>Edit prompts.py:</p><pre>questions = [<br>    &quot;Explain quantum computing in simple terms&quot;,<br>    &quot;What are the benefits of serverless architecture?&quot;,<br>    &quot;How does machine learning differ from deep learning?&quot;,<br>    # Add more questions...<br>]</pre><h3>Running the Processor</h3><p><strong>Option 1: Standard Processing (Works Immediately)</strong></p><pre>python bedrock_standard_processor.py</pre><p>Output:</p><pre>======================================================================<br>AWS Bedrock Standard Processing Demo<br>======================================================================<br>Region: us-east-1<br>Model: anthropic.claude-3-sonnet-20240229-v1:0<br>======================================================================</pre><pre>Processing 10 prompts...</pre><pre>[1/10] Processing: Explain quantum computing in simple terms...<br>Completed</pre><pre>[2/10] Processing: What are the benefits of serverless...<br>Completed</pre><pre>...</pre><pre>Results saved to bedrock_results_20251125123456.json<br>Completed: 10/10 requests successful</pre><p><strong>Option 2: Batch Processing (Requires AWS Approval)</strong></p><pre>python bedrock_batch_processor.py</pre><p>If not approved, you’ll see the authorization error and need to:</p><ol><li>Go to AWS Support Console</li><li>Create a case requesting Bedrock batch inference access</li><li>Explain your use case</li><li>Wait for approval (typically 1–3 business days)</li></ol><h3>Cost Comparison</h3><p>Based on AWS Bedrock pricing (as of Nov 2025):</p><p><strong>Standard Processing:</strong></p><ul><li>Claude 3 Sonnet: $3.00 per 1M input tokens, $15.00 per 1M output tokens</li></ul><p><strong>Batch Processing:</strong></p><ul><li>Claude 3 Sonnet: $1.50 per 1M input tokens, $7.50 per 1M output tokens</li><li><strong>50% cost savings</strong></li></ul><p>For 10,000 requests averaging 500 input tokens and 200 output tokens each:</p><ul><li>Standard: $45 (5M input + 2M output)</li><li>Batch: $22.50 (50% savings)</li></ul><h3>Lessons Learned</h3><h3>1. Service Availability ≠ Feature Availability</h3><p>Having AWS and Bedrock access doesn’t automatically grant batch inference permissions. Always check feature-specific requirements.</p><h3>2. Infrastructure as Code is Essential</h3><p>The CloudFormation template saved hours of manual IAM/S3 configuration and ensures reproducible deployments.</p><h3>3. Build Fallback Options</h3><p>Having both batch and standard processors allows flexibility based on account permissions and use case urgency.</p><h3>4. Cross-Cloud Patterns</h3><p>The batch processing pattern is remarkably similar across providers:</p><ul><li><strong>Azure OpenAI</strong>: Upload JSONL → Create batch → Poll status → Download results</li><li><strong>AWS Bedrock</strong>: Upload to S3 → Create job → Poll status → Download from S3</li><li><strong>Google Gemini</strong>: Upload to Cloud Storage → Create batch → Poll status → Download</li></ul><h3>Practical Use Cases</h3><p>This batch processing system is ideal for:</p><ol><li><strong>Documentation Generation</strong>: Process hundreds of code snippets into explanations</li><li><strong>Data Analysis</strong>: Analyze survey responses or customer feedback at scale</li><li><strong>Content Creation</strong>: Generate variations of marketing copy or product descriptions</li><li><strong>Research</strong>: Process academic papers for summarization or key point extraction</li><li><strong>Translation</strong>: Translate large volumes of text across languages</li><li><strong>Code Review</strong>: Analyze codebases for improvements or bug detection</li></ol><h3>Conclusion</h3><p>Building this AWS Bedrock batch processing system taught me valuable lessons about cloud AI services, infrastructure automation, and the importance of understanding service-level permissions. While I’m still awaiting batch inference approval, the standard processing alternative provides a working solution.</p><p>The CloudFormation template makes deployment straightforward, and the modular code structure allows easy customization for different use cases. Whether you’re processing 10 or 10,000 prompts, this system provides a solid foundation.</p><p>I’m excited to see how batch inference performs once approved and will update this project with performance benchmarks and cost comparisons.</p><h3>Resources</h3><ul><li><strong>GitHub Repository</strong>: <a href="https://github.com/Dibae101/AWS-Bedrock-Batch-Processing">https://github.com/Dibae101/AWS-Bedrock-Batch-Processing</a></li><li><strong>AWS Bedrock Docs</strong>: <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/batch-inference.html">https://docs.aws.amazon.com/bedrock/latest/userguide/batch-inference.html</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1a1ecf29d238" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a Streamlit Weather Chat App with AWS Kiro: My Journey, Benefits, and a Comparison]]></title>
            <link>https://medium.com/@dibaekhanal101/building-a-streamlit-weather-chat-app-with-aws-kiro-my-journey-benefits-and-a-comparison-3bde385fb44c?source=rss-f814343e861a------2</link>
            <guid isPermaLink="false">https://medium.com/p/3bde385fb44c</guid>
            <category><![CDATA[aws-kiro]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[kiro]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[vibe-coding]]></category>
            <dc:creator><![CDATA[Dibya Darshan Khanal]]></dc:creator>
            <pubDate>Sun, 05 Oct 2025 21:54:16 GMT</pubDate>
            <atom:updated>2025-10-05T21:54:16.332Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>“From vibe coding to viable code”<em> — that’s one of Kiro’s taglines, and over the last few weeks, I’ve put it through its paces building a weather chat app with Streamlit + Gemini key + weather APIs. Here’s how I used it, what worked (and what didn’t), how it benefited me, and how it compares to other tools I use.</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ke-lDAK9YP66tylpUVK6aQ.png" /></figure><h3>Introduction</h3><p>Lately, the world of AI-assisted development has exploded: GitHub Copilot, Cursor, Windsurf, Amazon Q, etc. I downloaded Kiro the first sight I saw a post over a Linkedin AWS launched Kiro. I was too excited to try.</p><p>AWS recently introduced <strong>Kiro</strong>, a new “agentic AI IDE” that aims not just to help you write code, but to structure and manage the entire development process (from prompt → specs → design → code → tests / docs).</p><p>In this post, I’ll walk you step-by-step through how <em>I</em> used Kiro to build a weather chat app, show before/after (via screenshots), highlight the benefits (and limitations), and compare that experience to using GitHub Copilot.</p><p>At the end, I’ll share a prompt template you can feed into Kiro to scaffold your own app (or adapt mine).</p><h3>My Workflow Using Kiro</h3><p>Below is roughly how I used Kiro in building this:</p><ol><li><strong>Bootstrap a new project in Kiro</strong></li></ol><ul><li>Created a blank project directory (or imported my existing folder)</li><li>In Kiro, selected “Spec-driven” mode</li><li>Created a requirements.md (or “spec”) file with initial user stories and acceptance criteria</li></ul><p>E.g. <em>“As a user, when I ask for weather in a city, the system should fetch current weather data and show temperature, humidity, condition.”</em></p><p>Created a design.md spec: modules (chat interface, weather client, LLM / agent logic, UI components), interfaces, data flows, error handling</p><ul><li>Let Kiro break that into implementation tasks / cards</li></ul><p><strong>2. Implement module by module using Kiro agent</strong></p><ul><li>For each task, I asked Kiro (via chat / agent) to generate the skeleton code (in Python)</li><li>As I worked on files, Kiro’s agent hooks (on save) generated unit tests, documentation stubs, updated spec artifacts, lint checks</li><li>When I changed spec or design, Kiro proposed refactors or updated tasks accordingly</li><li>I iterated — running Streamlit locally, verifying logic, making adjustments</li></ul><p><strong>3. Integrate weather API &amp; conversational logic</strong></p><ul><li>I asked Kiro to generate a wrapper around a weather API, mapping JSON response to structured data</li><li>Then I asked it to build a “chat agent” function that takes user input, parses location / date, decides which API endpoints to call, formats a reply</li></ul><p>Here I have screenshots as follows:</p><ul><li>Selecting the appropriate model ( I love Claude Sonnet 4 and 4.5)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kdVtksksIn--GLKVshtngQ.png" /></figure><ul><li>The spec file being generated (requirements.md with user stories)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*N55FoC7QI2ECSlJBsRNvBg.png" /></figure><ul><li>Kiro showing “tasks in progress” and “completed tasks”</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RP-4agy_vvVK6N_PoID2AQ.png" /></figure><ul><li>Screenshot of code diff view (Kiro proposing or applying code)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ri87Q2eJjcsr_XkKynbRFg.png" /></figure><ul><li>Screenshot of Streamlit UI running with weather chat</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8y7NKRqk6M26VD3rXMWkig.png" /></figure><p>Prompt template used:</p><pre># Project: Weather Chat App  <br><br>## Goal  <br>Build a simple Streamlit chat app that lets users ask about the weather and get real-time answers using a weather API and a Gemini key for natural conversation.  <br><br>## Requirements  <br>- Users can ask:<br>  - “What’s the weather in {city}?”<br>  - “Will it rain tomorrow in {city}?”<br>  - “Show me the 5-day forecast.”<br>- Show temperature, humidity, and condition (sunny, rainy, etc.)<br>- Handle invalid cities or API errors with friendly messages<br>- Keep chat history and refresh results without reloading<br>- Include basic tests, error handling, and documentation<br>- Make it easy to deploy (Docker or lightweight setup)<br><br>## Design Overview  <br>- `weather_client`: fetches and parses data from the weather API  <br>- `chat_agent`: interprets user queries and decides which API call to use  <br>- `ui`: Streamlit front-end for input/output  <br>- `state_manager`: manages chat history  <br>- `error_handling`: handles failed lookups and API issues  <br><br>## Key Functions  <br>- `get_current_weather(city)`  <br>- `get_forecast(city, days)`  <br>- `chat_response(user_input)`  <br><br>## Implementation Steps  <br>1. Scaffold folders and modules  <br>2. Build weather client and chat logic  <br>3. Connect UI with Streamlit  <br>4. Add error handling and validation  <br>5. Write tests and documentation  <br>6. Package for deployment (Dockerfile, requirements.txt)<br><br>## Notes  <br>Use Python 3.11, minimal dependencies, and secure API keys.  <br>Keep the design clean, responsive, and easy to maintain.  <br>Integrate the Gemini key for conversational weather replies.</pre><p>Benefits I Observed</p><p>Using Kiro gave me:</p><ul><li><strong>Clear structure and focus</strong> : writing specs early kept design aligned.</li><li><strong>Less repetitive work</strong> : agents handled docs, tests, and linting automatically.</li><li><strong>Faster development: </strong>quick scaffolding and refactoring of modules.</li><li><strong>Easy maintenance: </strong>specs and code stayed synchronized.</li><li><strong>Lower cognitive load: </strong>I focused on logic, not setup.</li><li><strong>Smooth onboarding: </strong>new contributors can follow updated specs and tasks easily.</li></ul><p><strong>Things I loved compared to other tools:</strong></p><p>Love how it creates streamline app development, it thought for a while, next created requirements, then the design, then task lists to perform and then application development. Similar to what I would have done.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8pBtyPVaSLFBfAg_mwGXAg.png" /></figure><p>Another cool thing, little notification. I can vibe code while I am browsing Kiro documentation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/752/1*hQ671bJz5H0WPvv7F2su7g.png" /></figure><p>Super userful, add context.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/866/1*8QkPJWCGayx8Eakj4gZLgA.png" /></figure><p>Created test scripts, validated itself, found errors and then again refactored the code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AUqCwKZqh6j7gvRNYWlubg.png" /></figure><p>Copilot is wonderful for quick code snippets or small functions. Kiro tries to be more holistic , helping you manage structure, consistency, automation, and evolution. In my weather chat app, I used Copilot early for small helpers, but when the project grew, Kiro’s spec-driven approach kept things more maintainable.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3bde385fb44c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Create a new user in Linux and add the user for Root Access.]]></title>
            <link>https://medium.com/@dibaekhanal101/create-a-new-user-in-linux-and-add-the-user-for-root-access-e2c2a0cf6198?source=rss-f814343e861a------2</link>
            <guid isPermaLink="false">https://medium.com/p/e2c2a0cf6198</guid>
            <dc:creator><![CDATA[Dibya Darshan Khanal]]></dc:creator>
            <pubDate>Thu, 28 Aug 2025 21:40:30 GMT</pubDate>
            <atom:updated>2025-08-28T21:40:30.076Z</atom:updated>
            <content:encoded><![CDATA[<p>Guide to create a new user in Linux and add the user for Root Access,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CxkYevv0skQqxxnQMCggAA.png" /></figure><ol><li>Create a new user<br>Log in as root (or a sudo user) and run:</li></ol><p># replace ‘newuser’ with your username</p><pre>sudo adduser newuser</pre><p>2. Set a password for the user (just in case, for local login):</p><pre>sudo passwd newuser</pre><p>3. Go to this file:</p><pre>sudo nano /etc/ssh/sshd_config</pre><p>Find these lines and make sure they are set like this:</p><pre>PasswordAuthentication yes<br>PermitRootLogin no</pre><p>4. Restart the sshd service</p><pre>sudo systemctl restart sshd</pre><p>5. Now exit from the root and login to newuser from the local machine</p><pre>ssh newuser@&lt;server-ip&gt;</pre><p>Add to root:<br>To add user to root, fire this command while you are logged in as root.</p><pre>Visudo</pre><p>Add line:</p><pre>newuser ALL=(ALL) ALL</pre><p>Exit from root, and text the root login from the newuser.</p><pre>exit<br>ssh newuser@&lt;server-ip&gt;<br>sudo su</pre><p>Enter password and you are all set.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e2c2a0cf6198" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Setting up Apache Doris on AWS EC2]]></title>
            <link>https://medium.com/@dibaekhanal101/setting-up-apache-doris-on-aws-ec2-9fa2c62b9ebc?source=rss-f814343e861a------2</link>
            <guid isPermaLink="false">https://medium.com/p/9fa2c62b9ebc</guid>
            <category><![CDATA[data]]></category>
            <category><![CDATA[data-mining]]></category>
            <category><![CDATA[data-warehouse]]></category>
            <category><![CDATA[doris]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Dibya Darshan Khanal]]></dc:creator>
            <pubDate>Fri, 11 Apr 2025 22:15:07 GMT</pubDate>
            <atom:updated>2025-04-11T22:15:30.882Z</atom:updated>
            <content:encoded><![CDATA[<p>Apache Doris is an open-source, real-time data warehouse designed for fast data analytics. It offers a simplified architecture, ensuring high availability, reliability, fault tolerance, and scalability</p><ol><li>Apache Doris requires a Frontend and backend setup to function.</li><li>For frontend, 8GB RAM, and for backend 16GB RAM is required for development environment, or you could use higher configuration instance and setup both on same machine.</li></ol><h3>Doris_Frontend Setup:</h3><ol><li>Update the packages</li></ol><pre>sudo apt update</pre><p>Doris requires to maximize the filehandles, for this we will be setting the following settings in limits.conf file.<br>More on this from doris documentation here: <a href="https://doris.apache.org/docs/2.0/install/cluster-deployment/k8s-deploy/install-env">https://doris.apache.org/docs/2.0/install/cluster-deployment/k8s-deploy/install-env</a></p><pre>nano /etc/security/limits.conf<br><br>soft nofile 65536<br>hard nofile 65536</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*2ewayFiEubtI93X5" /></figure><ol><li>Next we need to turn off the disk partition, this can be done using swapoff.</li></ol><pre>swapoff -a</pre><ol><li>We also need Java to run Doris, for this use the following command, any latest Java runtime should work.</li></ol><pre>sudo apt install default-jdk<br>sudo apt install default-jre</pre><ol><li>Check the java version after completing the installation.</li></ol><pre>java - version</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*e-_q8r-u6ykumNMa" /></figure><ol><li>This setup also requires python, in AWS Ubuntu AMI, python is already installed, check the python with</li></ol><pre>python3 - version</pre><ol><li>Further, we also require GCC compiler to compile and install Apache Doris in Ubuntu</li></ol><pre>sudo apt install gcc-11 g++-11<br>Also create a symbolic link to it.<br>sudo ln -s /usr/bin/g++-11 /usr/bin/g++<br>sudo ln -s /usr/bin/gcc-11 /usr/bin/gcc</pre><ol><li>Finally, we can now install Apache Doris</li></ol><p>Download link is here: <a href="https://doris.apache.org/download">https://doris.apache.org/download</a></p><pre>wget https://apache-doris-releases.oss-accelerate.aliyuncs.com/apache-doris-2.1.8.1-bin-x64.tar.gz</pre><ol><li>After download, untar the file:</li></ol><pre>tar -xf apache-doris-2.1.8.1-bin-x64.tar.gz</pre><ol><li>Also we need to change the priority networks for Doris to run,</li></ol><p>Uncomment the meta_dir line.</p><pre>nano apache-doris-2.1.8.1-bin-x64/fe/conf/fe.conf</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*cLlh3-Hof2a8efiQ" /></figure><p>Also, uncomment the priority_networks, remove rest and add the private network from your AWS EC2 machine. Save it and exit.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*gUNnEpd7oemALtRZ" /></figure><ol><li>We are now ready to run the Frontend service:</li></ol><pre>apache-doris-2.1.8.1-bin-x64/fe/bin/start_fe.sh - daemon</pre><p>With this, you should be able to login to Doris frontend at this URL:</p><p><a href="http://fe_ip:8030/">http://fe_ip:8030/</a></p><p>Default username is: root</p><p>Password: &lt;empty&gt;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Q-1owOhlCA0OaDtT" /></figure><p>At this time, if you check the backend, you will see blank rows.</p><pre>show backends</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*F5DySFOqRyVJc3vz" /></figure><h3>Doris_Backend Setup:</h3><p>If you are using a separate machine, you need to follow all the setup same to Doris_Frontend until untar apache_doris.</p><p>Follow along with this setup next:</p><ol><li>We need to edit the be/conf/be.conf file’s JAVA_HOME:</li></ol><pre>sudo update-alternatives - config java</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*sCRqtHECyjlP1ac4" /></figure><pre>/usr/lib/jvm/java-21-openjdk-amd64<br>nano apache-doris-2.1.8.1-bin-x64/be/conf/be.conf</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*qe8SGa6RAQe3GpzA" /></figure><p>Next, change the Priority_network to private IP, same as frontend setting.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*q07kxCC3YoF1f1We" /></figure><p>Also, uncomment the storage_root_path and add SSD, and HDD path to these.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*r8rEIwRgg9hK_eNn" /></figure><ol><li>We need to make disk1 and disk2 at ubuntu home directory for backend.</li></ol><pre>sudo mkdir disk1 disk2</pre><p>Set permission to ubuntu user:</p><pre>mkdir disk2/doris.HDD<br>mkdir disk1/doris.SSD</pre><pre>chown -R ubuntu:ubuntu /home/disk1/doris.SSD/<br>chown -R ubuntu:ubuntu /home/disk2/doris.HDD/</pre><ol><li>Set the max_map_count size</li></ol><pre>sysctl -w vm.max_map_count=2000000</pre><p>Also set the ulimit</p><pre>ulimit -n 65536</pre><ol><li>Now, start the backend service.</li></ol><pre>/home/ubuntu/apache-doris-2.1.8.1-bin-x64/be/bin/start_be.sh - daemon<br>/home/ubuntu/apache-doris-2.1.8.1-bin-x64/fe/bin/start_fe.sh - daemon</pre><ol><li>Now login to frontend,</li></ol><p>2. Add the BE service IP and heartbeat service port</p><pre>ALTER SYSTEM ADD BACKEND &quot;backend_private_ip:9050&quot;</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9fa2c62b9ebc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Getting Started With — Terraform (101)]]></title>
            <link>https://medium.com/@dibaekhanal101/terraform-101-8f4a5e9ca0e9?source=rss-f814343e861a------2</link>
            <guid isPermaLink="false">https://medium.com/p/8f4a5e9ca0e9</guid>
            <category><![CDATA[terraform]]></category>
            <category><![CDATA[infrastructure-as-a-code]]></category>
            <category><![CDATA[cloud]]></category>
            <dc:creator><![CDATA[Dibya Darshan Khanal]]></dc:creator>
            <pubDate>Thu, 20 Feb 2025 02:54:30 GMT</pubDate>
            <atom:updated>2025-02-27T21:14:03.868Z</atom:updated>
            <content:encoded><![CDATA[<p>Terraform Download: <a href="https://developer.hashicorp.com/terraform/install">https://developer.hashicorp.com/terraform/install</a></p><p>AWS CLI Setup in machine for TF to connect to AWS env.</p><ul><li>Create a user in AWS IAM, generate Access and Secret key.</li><li>Aws configure, and set values to it. You should see these values in</li></ul><pre>cat ~/.aws/credentials</pre><h3><strong>Terraform Commands</strong></h3><ul><li>Terraform init — initialize terraform for a project, this works if you have any tf files, for example main.ef file. The init command will create a .terraform file to work with.</li><li>terraform fmt — this command formats the terraform files, indentations mostly.</li><li>terraform plan — plans the resources being built out of tf scripts, gives logs of changes or changesets</li><li>terraform validate — Checks for syntax of tf scripts.</li><li>terraform apply — after planning, you are ready to provision the infra with apply command. This also runs the validate command by default. You can force apply with:<br>Terraform apply -auto-approve to skip ‘yes’ approve option.</li><li>terraform update — this basically runs apply command, for any infra changes done on the template, the update command also runs validate by default.</li></ul><p><strong>Terraform Validate vs Plan</strong>, Validate checks the syntax while the Plan checks the configuration changes.</p><h3><strong>Terraform variable</strong></h3><p>Terraform allows variables to insert into values, instead of hardcoded values. For this we need to set var.key and then in terraform.tfvars file we need to specify the variable</p><pre>instance_type = var.instance_type // in main.tf file<br>instance_type = &quot;t2.medium&quot; // in terraform.tfvars file</pre><p>This can also be done within command line while applying the terraform script</p><pre>terraform apply -var=instance_type=&quot;t2.micro&quot;</pre><h3><strong>Terraform local</strong></h3><p><a href="https://developer.hashicorp.com/terraform/language/values/locals">https://developer.hashicorp.com/terraform/language/values/locals</a></p><p>A local value assigns a name to an expression, so you can use the name multiple times within a module instead of repeating the expression.</p><pre>locals {<br> tag_name = &quot;test-ec2–02&quot;<br>}<br><br>tags = {<br> Name = &quot;${local.tag_name}&quot;<br> }</pre><h3><strong>Output values</strong></h3><p><a href="https://developer.hashicorp.com/terraform/language/values/outputs">https://developer.hashicorp.com/terraform/language/values/outputs</a></p><p>Output values make information about your infrastructure available on the command line, similar to outputs in programming languages.</p><pre>output &quot;instance_ip_addr&quot; {<br> value = aws_instance.app_server.private_ip<br>}</pre><p>The app_server is from the resource</p><h3><strong>Terraform modules</strong></h3><p>Terraform modules allows pre-defined modules from Cloud providers to provision infras, with concise implementation</p><p><a href="https://registry.terraform.io/browse/modules">https://registry.terraform.io/browse/modules</a></p><p>After you apply this module, you need to import the module, to do so you need to run terraform init command again.</p><p>The snippet here creates a new VPC.</p><pre>module &quot;vpc&quot; {<br> source = &quot;terraform-aws-modules/vpc/aws&quot;<br> name = &quot;tf-vpc&quot;<br> cidr = &quot;10.0.0.0/16&quot;<br> azs = [&quot;us-east-1a&quot;, &quot;us-east-1b&quot;, &quot;us-east-1c&quot;]<br> private_subnets = [&quot;10.0.1.0/24&quot;, &quot;10.0.2.0/24&quot;, &quot;10.0.3.0/24&quot;]<br> public_subnets = [&quot;10.0.101.0/24&quot;, &quot;10.0.102.0/24&quot;, &quot;10.0.103.0/24&quot;]<br> enable_nat_gateway = true<br> enable_vpn_gateway = true<br> tags = {<br> Terraform = &quot;true&quot;<br> Environment = &quot;dev&quot;<br> }<br>}</pre><h3><strong>Dividing files</strong></h3><p>It’s common practice to divide terraform files from main to standalone files, variables.tf, outputs.tf, providers.tf are common files in terraform.</p><h3><strong>Terraform destroy</strong></h3><p>Deletes infras, all of them.</p><h3><strong>Terraform workspace and cloud</strong></h3><p>By default we are using ‘default’ workspace.</p><p>To check this:</p><pre>terraform workspace list</pre><p>We are going to put everything in the cloud for team collaboration to the project, to get started, create an account on terraform.io, activate the account and create an organization and a new workspace within.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*g9eILK1RiZB8dzLJ" /></figure><p>You might want to choose to create CLI driven workspace and terraform login to authenticate to the terraform cloud. Generate a token and paste it to the console, then you are good to go.</p><pre>terraform { <br> cloud { <br> organization = &quot;darshan-org&quot; <br> workspaces { <br> name = &quot;terraform-wspc&quot; <br> } <br> } <br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*BnJuxYHnINxUWH74" /></figure><p>When you apply the terraform, you might run into issue with current code</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*2nf8mOye_kLnRzqD" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ehrkeP5MeSNPQlhd" /></figure><p><a href="https://registry.terraform.io/providers/hashicorp/aws/latest/docs">https://registry.terraform.io/providers/hashicorp/aws/latest/docs</a></p><p>Follow along this document to authenticate AWS within our terraform cloud, with access and secret key.</p><p>Usage:</p><pre>provider &quot;aws&quot; {<br> region = &quot;AWS_REGION&quot;<br> access_key = &quot;AWS_ACCESS_KEY_ID&quot;<br> secret_key = &quot;AWS_SECRET_ACCESS_KEY&quot;<br>}</pre><p>There are multiple ways you can do this, you can set a variable in provider and set the variables with terraform cloud, or export the access and secret key locally and use it to authenticate.</p><p>For this run, I am using export. Also make sure to add these variables to variables.tf file.</p><pre>export AWS_ACCESS_KEY_ID=&quot;anaccesskey&quot;<br>export AWS_SECRET_ACCESS_KEY=&quot;asecretkey&quot;<br>export AWS_REGION=&quot;us-east-2&quot;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/929/0*P1zwgXhNVjSDOgkd" /></figure><p>Successfully applied and finally destroyed the infra with workspace within TF cloud.</p><p>Browse this commit to look into changes: <a href="https://github.com/Dibae101/Infra-Spagheti/tree/49d357d55d662940cfa01d0bf07440c4e99c2d0b">https://github.com/Dibae101/Infra-Spagheti/tree/49d357d55d662940cfa01d0bf07440c4e99c2d0b</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Dj0NwooeKYcspXxW" /></figure><h3><strong>Terraform Registry</strong></h3><p>The terraform registry is the repository hosting providers and modules of cloud providers.</p><p><a href="https://registry.terraform.io/">https://registry.terraform.io/</a></p><p>A provider is a plugin for Terraform that makes a collection of related resources available. A provider plugin is responsible for understanding the API interactions with services (Azure, AWS, VMware etc) and exposing resources based on that API. Providers are usually platform specific. <a href="https://registry.terraform.io/browse/providers">https://registry.terraform.io/browse/providers</a></p><p>A resource is a block of config that describes one or more infrastructure objects. Resources can be things like virtual networks, compute instances etc.</p><p>A module is a self contained reusable collection of terraform resources (think of it like a function or method).</p><h3><strong>Terraform Local Exec Provisioner</strong></h3><p>The local-exec provisioner invokes a local executable after a resource is created.</p><p><a href="https://developer.hashicorp.com/terraform/language/resources/provisioners/local-exec">https://developer.hashicorp.com/terraform/language/resources/provisioners/local-exec</a></p><p>Example:</p><pre>resource &quot;aws_instance&quot; &quot;web&quot; {<br> # …<br> provisioner &quot;local-exec&quot; {<br> command = &quot;echo ${self.private_ip} &gt;&gt; private_ips.txt&quot;<br> }<br>}</pre><p>After adding this in the main.tf file, you might want to run Terraform init as we will be using local as backend instead of remote.</p><pre>terraform init -migrate-state</pre><p>The local exec in the above example creates a private_ips.txt file, which has private IP from the server TF launched.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*M06v3DCv7kOTFGKM" /></figure><h3><strong>Terraform Remote Exec Provisioner</strong></h3><p><a href="https://developer.hashicorp.com/terraform/language/resources/provisioners/remote-exec">https://developer.hashicorp.com/terraform/language/resources/provisioners/remote-exec</a></p><p>Similar to local exec, the remote exec provisioner invokes a script on a remote resource after it is created. This can be used to run a configuration management tool, bootstrap into a cluster, etc.</p><p>With this, you can invoke any script on a remote machine using remote exec, for example to invoke a script on an EC2 machine, you would need a connection block, something like below snippet, in the password field you may also give a path to .pem file.</p><pre>connection {<br> type = &quot;ssh&quot;<br> user = &quot;root&quot;<br> password = var.root_password<br> host = var.host<br> }</pre><p>Then use remote exec provisioner</p><pre>provisioner &quot;file&quot; {<br> source = &quot;script.sh&quot;<br> destination = &quot;/tmp/script.sh&quot;<br> }</pre><p>Combinedly:</p><pre>provisioner &quot;remote-exec&quot; {<br> inline = [<br> &quot;echo ${self-private_ip} »&gt; /home/ec2-user/private_ips.txt&quot;<br>]<br>connection {<br> Type = &quot;ssh&quot;<br> user= &quot;ec2-user&quot;<br> Host = &quot;${self-public_ip}&quot;<br> private_key = &quot;${file(&quot;/root/.ssh/terraform&quot;)}&quot;<br>}</pre><h3><strong>Terraform variables</strong></h3><p>Terraform variables are placeholders for values that you can use to make your configurations more dynamic and reusable.</p><p>Usage:</p><pre>variable &quot;image_id&quot; {<br> type = string<br>}</pre><p>You may as well use other keys to variables like, description, sensitive, condition, validation and so on.</p><p><a href="https://developer.hashicorp.com/terraform/language/values/variables">https://developer.hashicorp.com/terraform/language/values/variables</a></p><p>Example:</p><p>While defining a resource in main.tf for ec2, here is the snippet for this.</p><pre>resource &quot;aws_instance&quot; &quot;app_server&quot; {<br> ami = var.ami <br> instance_type = var.instance_type<br>}</pre><p>We have mentioned in ami placeholder value to var.ami. The var for ami comes from variables.tf</p><pre>variable &quot;instance_type&quot; {<br> type = string<br>}</pre><p>Next the actual value for this instance_type string is mentioned in terraform.tfvars.</p><p>You can custom name this tfvars to something my_var.tfvars but this will prompt you to add tfvar file manually, instead you can name the custom filename to my_var.auto.tfvars which will automatically takes the file and appends it main.tf.</p><pre>instance_type = &quot;t2.medium&quot;</pre><h3>Data source in AWS</h3><p>Data source is to get the ID of an Amazon EC2 Instance for use in other resources.<br>In the code below, the data aws_ami’s filter is referred to resources ami to get ubuntu’s default ID, this can be used anywhere in other resources without having to pull data from cloud but locally.<br><a href="https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/instance">https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/instance</a></p><pre># AWS Data Source to Fetch Latest Ubuntu AMI<br>data &quot;aws_ami&quot; &quot;ubuntu&quot; {<br> most_recent = true<br>filter {<br> name = &quot;name&quot;<br> values = [&quot;ubuntu/images/hvm-ssd/ubuntu-focal-20.04-amd64-server-*&quot;]<br> }<br>filter {<br> name = &quot;virtualization-type&quot;<br> values = [&quot;hvm&quot;]<br> }<br>owners = [&quot;099720109477&quot;] <br>}<br># Reference AWS Data Source to Get AMI ID<br>resource &quot;aws_instance&quot; &quot;app_server&quot; {<br> ami = data.aws_ami.ubuntu.id<br> instance_type = var.instance_type<br>tags = {<br> Name = local.tag_name<br> }<br>}</pre><h3>Resource</h3><p>In Terraform, resources are the primary elements of configuration. They represent infrastructure components, such as virtual networks, compute instances, or DNS records.</p><p>Terraform offers several key sections to help manage resources:</p><ul><li>Resource Blocks: This section outlines the syntax used to declare resources in Terraform.</li><li>Resource Behavior: Explains in detail how Terraform manages and interacts with resources when applying a configuration.</li><li>Meta-Arguments: Special arguments that can be used across all resource types, allowing you to control dependencies, resource iteration, and lifecycle management.</li><li>Provisioners: Used to configure actions after a resource is created, such as provisioning software or making connection adjustments.</li></ul><h3>Resource Meta-Arguments</h3><p>Meta-arguments in Terraform are used to influence how resources are created, updated, or destroyed. These arguments aren’t tied to any specific resource type but provide a consistent way to configure behaviors across all resources.</p><p>Here are the main meta-arguments commonly used in Terraform:</p><p><strong>1. depends_on</strong></p><p>The depends_on meta-argument explicitly defines dependencies between resources. It ensures that one resource will not be created or destroyed until another resource is fully created or destroyed.</p><pre>resource &quot;aws_security_group&quot; &quot;example&quot; {<br> name = &quot;example_security_group&quot;<br>}<br>resource &quot;aws_instance&quot; &quot;example&quot; {<br> ami = &quot;ami-123456&quot;<br> instance_type = &quot;t2.micro&quot;<br> <br> depends_on = [aws_security_group.example]<br>}</pre><p>In this example, the AWS instance (aws_instance.example) will not be created until the security group (aws_security_group.example) is fully created.</p><p><strong>2. count</strong></p><p>The count meta-argument allows you to create multiple instances of a resource based on a specified number. It’s useful when you want to create several identical resources without duplicating the resource block.</p><pre>resource &quot;aws_instance&quot; &quot;example&quot; {<br> count = 3<br> ami = &quot;ami-123456&quot;<br> instance_type = &quot;t2.micro&quot;<br>}</pre><p>Here, Terraform will create three identical instances of the aws_instance resource.</p><p><strong>3. for_each</strong></p><p>The for_each meta-argument enables you to iterate over a map or set of values, creating a separate resource for each entry. Unlike count, which uses numeric values, for_each works with complex structures like maps or lists.</p><p>Example:</p><pre>resource &quot;aws_instance&quot; &quot;example&quot; {<br> for_each = {<br> instance1 = &quot;ami-123456&quot;<br> instance2 = &quot;ami-654321&quot;<br> }<br> ami = each.value<br> instance_type = &quot;t2.micro&quot;<br>}</pre><p>In this case, Terraform will create two instances, one with ami-123456 and another with ami-654321.</p><p><strong>4. provider</strong></p><p>The provider meta-argument specifies the provider configuration for a resource. Terraform supports various cloud providers (like AWS, Azure, Google Cloud, etc.), and this meta-argument links a resource to a particular provider.</p><p>Example:</p><pre>provider &quot;aws&quot; {<br> region = &quot;us-east-1&quot;<br>}<br>resource &quot;aws_instance&quot; &quot;example&quot; {<br> ami = &quot;ami-123456&quot;<br> instance_type = &quot;t2.micro&quot;<br>}</pre><p>Here, the aws_instance resource is associated with the aws provider, and Terraform will use the AWS configuration specified under the provider block.</p><p><strong>5. lifecycle</strong></p><p>The lifecycle meta-argument manages the behavior of resources during creation, update, and deletion. It allows you to customize how Terraform handles resource destruction, changes, and even ignores changes to certain attributes.</p><p>Example:</p><pre>resource &quot;aws_instance&quot; &quot;example&quot; {<br> ami = &quot;ami-123456&quot;<br> instance_type = &quot;t2.micro&quot;<br> lifecycle {<br> ignore_changes = [<br> ami,<br> ]<br> }<br>}</pre><p>In this example, Terraform will ignore any changes to the ami attribute, even if the value changes in the configuration, thus preventing the instance from being recreated.</p><h3>Terraform Expressions</h3><p>Terraform expressions are used to compute values in configurations. They can refer to variables, resource attributes, functions, and more.</p><ul><li>Literals — Direct values like numbers (42), strings (“hello”), and booleans (true).</li><li>References — Use values from variables, resources, or data sources (var.instance_type).</li><li>Operators — Perform calculations (+, -, *, /).</li><li>Functions — Built-in functions to manipulate data (length(var.list)).</li><li>Conditional Expressions — Use condition ? true_value : false_value for decisions.</li><li>For Expressions — Create lists/maps dynamically ([for i in var.list : i * 2]).</li></ul><p>Example:</p><pre>variable &quot;instance_type&quot; {<br> default = &quot;t2.micro&quot;<br>}<br>resource &quot;aws_instance&quot; &quot;example&quot; {<br> instance_type = var.instance_type == &quot;t2.micro&quot; ? &quot;t2.small&quot; : &quot;t2.medium&quot;<br>}</pre><p>If instance_type is “t2.micro”, the instance will use “t2.small”, otherwise, it will use “t2.medium”.</p><ol><li><strong>Types and Values</strong></li></ol><p>Terraform supports types like <strong>string</strong>, <strong>number</strong>, <strong>bool</strong>, <strong>list</strong>, <strong>map</strong>, and <strong>object</strong>.</p><pre>variable &quot;instance_type&quot; {<br> type = string<br> default = &quot;t2.micro&quot;<br>}</pre><ol><li><strong>Strings and String Templates</strong></li></ol><p>Strings can be <strong>plain</strong> (“Hello”) or <strong>interpolated</strong> using ${}.</p><pre>output &quot;greeting&quot; {<br> value = &quot;Hello, ${var.name}!&quot;<br>}</pre><ol><li><strong>Expressions — Operators</strong></li></ol><ul><li><strong>Arithmetic</strong> (+, -, *, /)</li><li><strong>Comparison</strong> (==, !=, &gt;, &lt;)</li><li><strong>Logical</strong> (&amp;&amp;, ||, !)</li></ul><pre>output &quot;double&quot; {<br> value = 5 * 2 # Result: 10<br>}</pre><ol><li><strong>Conditional Expressions</strong></li></ol><p><strong>Ternary operator:</strong> condition ? true_value : false_value</p><pre>output &quot;instance_size&quot; {<br> value = var.cpu &gt; 2 ? &quot;large&quot; : &quot;small&quot;<br>}</pre><ol><li><strong>Expressions — For Expressions</strong></li></ol><p>Used for looping over <strong>lists</strong> or <strong>maps</strong>.</p><pre>output &quot;squared&quot; {<br> value = [for num in [1, 2, 3] : num * num]<br>}<br># Result: [1, 4, 9]</pre><ol><li><strong>Expressions — Splat Expressions</strong></li></ol><ul><li>Simplifies accessing attributes of lists.</li></ul><pre>output &quot;instance_ids&quot; {<br> value = aws_instance.example[*].id<br>}</pre><ol><li><strong>Dynamic Blocks</strong></li></ol><p>Used to generate repeated nested blocks dynamically.</p><pre>resource &quot;aws_security_group&quot; &quot;example&quot; {<br> dynamic &quot;ingress&quot; {<br> for_each = var.ports<br> content {<br> from_port = ingress.value<br> to_port = ingress.value<br> protocol = &quot;tcp&quot;<br> }<br> }<br>}</pre><ol><li><strong>Version Constraints</strong></li></ol><p>Defines which versions of Terraform or providers are allowed.</p><pre>terraform {<br> required_version = &quot;&gt;= 1.0.0&quot;<br>}</pre><h3>Terraform State</h3><p>Terraform state is a file (terraform.tfstate) that keeps track of infrastructure managed by Terraform. It helps Terraform understand what resources exist, their configurations, and what needs to be changed when applying updates.</p><p><strong>Command — Description</strong></p><p>terraform state list — Shows all resources tracked in the state file.</p><p>terraform state show &lt;resource&gt; — Displays details of a specific resource from the state.</p><p>terraform state pull — Downloads the latest state file from remote storage.</p><p>terraform state rm &lt;resource&gt; — Removes a resource from state without deleting it from the cloud.</p><p>terraform state mv &lt;old&gt; &lt;new&gt; — Moves a resource to a new name or location in the state.</p><p>terraform state push — Manually updates the remote state file (used rarely).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*8pXhhiT-fSaaaGpe" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*xX4HN5XkMEkLT_Zl" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8f4a5e9ca0e9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Setting Up SEED Labs on AWS EC2 with VNC Server]]></title>
            <link>https://medium.com/@dibaekhanal101/setting-up-seed-labs-on-aws-ec2-with-vnc-server-7c5c51657c33?source=rss-f814343e861a------2</link>
            <guid isPermaLink="false">https://medium.com/p/7c5c51657c33</guid>
            <dc:creator><![CDATA[Dibya Darshan Khanal]]></dc:creator>
            <pubDate>Wed, 29 Jan 2025 02:51:22 GMT</pubDate>
            <atom:updated>2025-01-30T19:28:50.251Z</atom:updated>
            <content:encoded><![CDATA[<h4>This document provides step-by-step instructions to install and configure a VNC server on an AWS EC2 instance running Ubuntu before installing SEED Labs. This approach resolves issues with SEED Labs’ built-in VNC configuration, ensuring a stable graphical environment.</h4><h3>1. Launch an EC2 Instance</h3><p>1. Go to the AWS Management Console.<br> 2. Navigate to ‘EC2’ under the ‘Compute’ section.<br> 3. Click ‘Launch Instance’ and choose ‘Ubuntu Server 20.04 LTS’.<br> 4. Select an instance type (recommended: `t3.small`).<br> 5. Configure Security Groups to allow SSH (port 22) and VNC (port 5901) from your IP.<br> 6. Launch the instance and download the `.pem` key file for SSH access.</p><h3>2. Connect to Your EC2 Instance</h3><p>Use SSH to connect to your EC2 instance:</p><pre>ssh -i &quot;your-key.pem&quot; ubuntu@your-ec2-public-ip</pre><h3>3. Update the System</h3><p>Update package lists and upgrade existing packages:</p><pre>sudo apt update &amp;&amp; sudo apt upgrade -y</pre><h3>4. Install a Desktop Environment</h3><p>Install XFCE, a lightweight GUI for remote connections:</p><pre>sudo apt install -y xfce4 xfce4-goodies</pre><h3>5. Install and Configure TightVNC Server</h3><p>1. Install TightVNC:</p><pre>sudo apt install -y tightvncserver</pre><p>2. Start the VNC server to set up a password:</p><pre>vncserver</pre><p>3. Kill the VNC server to apply configuration changes:</p><pre>vncserver -kill :1</pre><p>4. Edit the `xstartup` file:</p><pre>nano ~/.vnc/xstartup</pre><p>Replace contents with:</p><pre>#!/bin/bash<br>xrdb $HOME/.Xresources<br>startxfce4 &amp;</pre><p>5. Save and make the script executable:</p><pre>chmod +x ~/.vnc/xstartup</pre><p>6. Restart the VNC server:</p><pre>vncserver :1</pre><h3>6. Configure AWS Security Group for VNC</h3><p>1. In AWS, go to ‘Security Groups’ under ‘EC2’.<br> 2. Select your instance’s security group and edit inbound rules.<br> 3. Allow TCP traffic on port 5901 from your IP address.</p><h3>7. Connect to the VNC Server</h3><p>1. Install a VNC client (RealVNC, TightVNC, or Remmina).<br> 2. Connect to `your-ec2-public-ip:5901`.<br> 3. Enter your VNC password when prompted.</p><h3>8. Install SEED Labs</h3><ol><li>Download and extract SEED Labs:</li><li>Navigate to the SEED Labs directory and install:</li></ol><pre>curl -o src-cloud.zip https://seed.nyc3.cdn.digitaloceanspaces.com/src-cloud.zip<br><br>sudo apt install -y unzip<br><br>unzip src-cloud<br><br>cd src-cloud<br><br>./install.sh</pre><p>3. Select ‘No’ for non-root Wireshark capture.<br> 4. Choose ‘LightDM’ as the display manager. (you may not get this screen as the SEED package has issue with Gnome setup, that’s why we have installed VNC server prior to SEED installation)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*5PdNTDcH2sRf010JzHhLbg.png" /></figure><h3>9. Start Using SEED Labs</h3><ol><li>Switch to the SEED user:</li></ol><pre>sudo su seed</pre><p>2. List available SEED Labs:</p><pre>ls ~/src-cloud</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yU3IT60mzeMk3HMzDzxM6Q.jpeg" /></figure><h3>10. Install Brave Browser</h3><p>The built-in browser and the firefox installed with SeedLab has issue, so counter this we are installing brave browser. Always check this available site for updated commands, for now you can paste the commands below.</p><p><a href="https://brave.com/linux/">Installing Brave on Linux | Brave</a></p><pre>curl -fsS https://dl.brave.com/install.sh | sh<br><br>curl -fsSLO &quot;https://dl.brave.com/install.sh{,.asc}&quot; &amp;&amp; gpg --keyserver hkps://keys.openpgp.org --recv-keys BF62821AFB16036A4ACABCCC87E072BD82960F4D &amp;&amp; gpg --verify install.sh.asc</pre><h3>11. Troubleshooting VNC Issues</h3><p>If VNC fails to start or exits too early:<br> 1. Ensure `.Xresources` exists:</p><pre>touch ~/.Xresources<br>chmod 644 ~/.Xresources</pre><p>2. Kill and restart the VNC server:</p><pre>vncserver -kill :1<br>vncserver :1</pre><p>3. Check VNC logs:</p><pre>cat ~/.vnc/*.log</pre><h3>12. Set VNC to Start Automatically on Boot</h3><p>1. Create a systemd service:</p><pre>sudo nano /etc/systemd/system/vncserver@.service</pre><p>Add the following:</p><pre>[Unit]<br> Description=Start VNC server at startup<br> After=syslog.target network.target<br> <br> [Service]<br> Type=forking<br> User=seed<br> PAMName=login<br> PIDFile=/home/seed/.vnc/%H:%i.pid<br> ExecStart=/usr/bin/vncserver -depth 24 -geometry 1280x800 :%i<br> ExecStop=/usr/bin/vncserver -kill :%i<br> <br> [Install]<br> WantedBy=multi-user.target</pre><p>2. Save and enable the service:</p><pre>sudo systemctl daemon-reload<br>sudo systemctl enable vncserver@1<br>sudo systemctl start vncserver@1</pre><h3>13. Set permission to Wireshark</h3><p>When you first run the wireshark, you may encounter “Couldn’t run dumpcap in child process: Permission denied,” is typically related to Wireshark not having the necessary permissions to capture network packets. Here’s how to fix the issue on Ubuntu:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2o6E4J9trZswVgcWQnn45Q.png" /></figure><p>1. <strong>Check if Wireshark is installed properly</strong>:</p><ul><li>Ensure that Wireshark is installed and the required dependencies are in place. You can check by running:</li></ul><pre>sudo apt update<br>wireshark -version</pre><p>2. <strong>Add your user to the wireshark group</strong>:</p><p>• Wireshark needs to run with elevated privileges to capture network traffic. However, rather than running Wireshark as root, it’s safer to add your user to the wireshark group, which grants the necessary permissions.</p><p>Run the following command:</p><pre>sudo usermod -aG wireshark $USER</pre><p>3. Ensure dumpcap is installed and accessible:</p><pre>which dumpcap</pre><ul><li>If it’s not found, reinstall it with:</li></ul><pre>sudo apt install dumpcap</pre><p>4. <strong>Set permissions on dumpcap</strong>:</p><ul><li>Ensure that the dumpcap executable has the correct permissions. Run:</li></ul><pre>sudo chmod +x /usr/bin/dumpcap</pre><ul><li>Then, grant dumpcap the necessary permissions to capture packets by running:</li></ul><pre>sudo setcap cap_net_raw,cap_net_admin=eip /usr/bin/dumpcap</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EZzIpq-K-V-PfP4F7wz--Q.png" /></figure><h3>14. Final Steps</h3><p>You have now successfully installed and configured:<br> — A VNC server on AWS EC2 with XFCE desktop<br> — SEED Labs for cybersecurity training<br> You can now connect remotely and begin using SEED Labs, make sure to grant enough permission for Wireshark to work.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7c5c51657c33" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Publishing Your Lambda Function to AWS Serverless Application Repository]]></title>
            <link>https://medium.com/@dibaekhanal101/publishing-your-lambda-function-to-aws-serverless-application-repository-6cfd797f3ea3?source=rss-f814343e861a------2</link>
            <guid isPermaLink="false">https://medium.com/p/6cfd797f3ea3</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[serverless-application]]></category>
            <category><![CDATA[lambda]]></category>
            <category><![CDATA[serverless]]></category>
            <category><![CDATA[autoscaling]]></category>
            <dc:creator><![CDATA[Dibya Darshan Khanal]]></dc:creator>
            <pubDate>Fri, 19 Jul 2024 19:38:13 GMT</pubDate>
            <atom:updated>2024-07-19T19:53:42.810Z</atom:updated>
            <content:encoded><![CDATA[<p>As part of my journey in pursuing the AWS DevOps Professional certification, I stumbled upon the AWS Serverless Application Repository — a service that allows developers to share and deploy serverless applications. Intrigued by its potential, I decided to give it a try with a Lambda function I had been working on. This article details my experience and the steps I followed to publish my ASG Capacity Checker application to the AWS Serverless Application Repository.</p><p>The <a href="https://serverlessrepo.aws.amazon.com/applications/us-east-1/185399948145/ASG-capacity-checker-lambda"><strong>ASG Capacity Checker</strong></a><strong> </strong>is a serverless application designed to monitor Auto Scaling Groups (ASGs) and ensure they do not exceed their maximum capacity. This application automatically checks the maximum capacity of ASGs and compares it with the number of registered instances in a specified Load Balancer. If an ASG reaches its maximum capacity, it sends an alert via Amazon SNS to notify the operations team.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BYWBOf3OktUP3UnRGcSzzQ.png" /></figure><h4>Key Features:</h4><ul><li>Automatic Monitoring: Continuously monitors ASGs and Load Balancer to check for capacity limits.</li><li>Real-Time Alerts: Sends notifications through Amazon SNS when an ASG reaches its maximum capacity.</li><li>State Management: Maintains the state of the last alert to prevent duplicate notifications.</li><li>Easy Deployment: Uses <a href="https://aws.amazon.com/serverless/sam/">AWS SAM</a> for simple and straightforward deployment.</li><li>Scalable: Built on serverless architecture, ensuring scalability and low maintenance.</li></ul><p>This application is ideal for ensuring high availability and preventing service disruption by proactively managing ASG capacities.</p><h3>Steps to Publish Your Lambda Function</h3><p><strong>1. Prepare Your Lambda Function Code</strong></p><p>Ensure your Lambda function code (`index.py`) is ready. Here’s a sample Lambda function that checks ASG capacities: (make sure to change TARGET_GROUP_ARN, SNS_TOPIC_ARN, ASG_NAME.</p><pre>import boto3<br>import re<br>import json<br><br># Initialize clients using the IAM role attached to the Lambda function<br>autoscaling = boto3.client(&#39;autoscaling&#39;, region_name=&#39;us-east-1&#39;)<br>elbv2 = boto3.client(&#39;elbv2&#39;, region_name=&#39;us-east-1&#39;)<br>sns = boto3.client(&#39;sns&#39;, region_name=&#39;us-east-1&#39;)<br>ssm = boto3.client(&#39;ssm&#39;, region_name=&#39;us-east-1&#39;)<br><br># Configuration<br>ASG_NAME_PATTERN = r&#39;^ASG_NAME.*$&#39;<br>TARGET_GROUP_ARN = &#39;TARGET_GROUP_ARN&#39;<br>SNS_TOPIC_ARN = &#39;SNS_TOPIC_ARN&#39;<br>SSM_PARAMETER_NAME = &#39;ASGAlertState&#39;<br><br>def get_matching_asg_names(pattern):<br>    paginator = autoscaling.get_paginator(&#39;describe_auto_scaling_groups&#39;)<br>    page_iterator = paginator.paginate()<br>    <br>    matching_asgs = []<br>    for page in page_iterator:<br>        matching_asgs.extend(<br>            [asg[&#39;AutoScalingGroupName&#39;] for asg in page[&#39;AutoScalingGroups&#39;]<br>             if re.match(pattern, asg[&#39;AutoScalingGroupName&#39;])]<br>        )<br>    return matching_asgs<br><br>def get_max_capacity(asg_name):<br>    response = autoscaling.describe_auto_scaling_groups(<br>        AutoScalingGroupNames=[asg_name]<br>    )<br>    if not response[&#39;AutoScalingGroups&#39;]:<br>        raise Exception(f&quot;No Auto Scaling group found with name {asg_name}&quot;)<br>    return response[&#39;AutoScalingGroups&#39;][0][&#39;MaxSize&#39;]<br><br>def get_registered_targets_count(target_group_arn):<br>    response = elbv2.describe_target_health(TargetGroupArn=target_group_arn)<br>    return len(response[&#39;TargetHealthDescriptions&#39;])<br><br>def send_sns_alert(topic_arn, message):<br>    sns.publish(<br>        TopicArn=topic_arn,<br>        Message=message,<br>        Subject=&quot;ASG and Target Group Capacity Match Alert&quot;<br>    )<br><br>def get_last_alert_state():<br>    try:<br>        response = ssm.get_parameter(Name=SSM_PARAMETER_NAME)<br>        return json.loads(response[&#39;Parameter&#39;][&#39;Value&#39;])<br>    except ssm.exceptions.ParameterNotFound:<br>        return None<br><br>def update_alert_state(state):<br>    ssm.put_parameter(<br>        Name=SSM_PARAMETER_NAME,<br>        Value=json.dumps(state),<br>        Type=&#39;String&#39;,<br>        Overwrite=True<br>    )<br><br>def lambda_handler(event, context):<br>    try:<br>        # Get the number of registered targets<br>        registered_targets_count = get_registered_targets_count(TARGET_GROUP_ARN)<br>        print(f&quot;Number of registered instances in target group : {registered_targets_count}&quot;)<br><br>        # Get all matching ASG names<br>        asg_names = get_matching_asg_names(ASG_NAME_PATTERN)<br><br>        # Get the last alert state<br>        last_alert_state = get_last_alert_state()<br><br>        new_alert_state = {<br>            &#39;asg_name&#39;: None,<br>            &#39;max_capacity&#39;: None,<br>            &#39;registered_targets_count&#39;: registered_targets_count<br>        }<br><br>        for asg_name in asg_names:<br>            # Get the maximum capacity of the ASG<br>            max_capacity = get_max_capacity(asg_name)<br>            print(f&quot;Max capacity of ASG &#39;{asg_name}&#39;: {max_capacity}&quot;)<br>            <br>            # Check if the max capacity matches the number of registered targets<br>            if max_capacity == registered_targets_count:<br>                new_alert_state[&#39;asg_name&#39;] = asg_name<br>                new_alert_state[&#39;max_capacity&#39;] = max_capacity<br>                message = (f&quot;The Auto Scaling Group &#39;{asg_name}&#39; has reached its maximum capacity, &quot;<br>                           f&quot;which matches the number of registered targets in the target group. &quot;<br>                           f&quot;Max capacity: {max_capacity}, Registered targets: {registered_targets_count}.&quot;)<br>                print(message)<br>                <br>                # Send an alert only if the state has changed<br>                if last_alert_state != new_alert_state:<br>                    send_sns_alert(SNS_TOPIC_ARN, message)<br>                    update_alert_state(new_alert_state)<br>                return  # Alert sent, exit the loop<br>            else:<br>                print(f&quot;ASG &#39;{asg_name}&#39; max capacity: {max_capacity}, Target group registered targets: {registered_targets_count}. No match.&quot;)<br>        <br>        # If no match found, clear the state<br>        if last_alert_state:<br>            update_alert_state({&#39;asg_name&#39;: None, &#39;max_capacity&#39;: None, &#39;registered_targets_count&#39;: registered_targets_count})<br><br>    except Exception as e:<br>        print(f&quot;Error: {str(e)}&quot;)<br><br>if __name__ == &quot;__main__&quot;:<br>    lambda_handler({}, {})</pre><p>2. <strong>Ensure Lambda Function Code is in a ZIP File</strong></p><p>Save your Lambda function code in a file named index.py and create a ZIP file:</p><pre>zip function.zip index.py</pre><p><strong>3. Create the AWS SAM Template<br></strong>Here, make sure to change LicenseUrl, ReadmeUrl, HomePageUrl, SourceCodeUrl and CodeUri.</p><pre>AWSTemplateFormatVersion: &#39;2010-09-09&#39;<br>Transform: &#39;AWS::Serverless-2016-10-31&#39;<br>Description: &gt;<br>  ASG Capacity Alert<br><br>Metadata:<br>  AWS::ServerlessRepo::Application:<br>    Name: ASGCapacityAlert<br>    Description: &gt;<br>      This function checks the ASG maximum capacity and the target instances in the ALB and notifies us via SNS if the maximum capacity is reached.<br>    Author: Dibya Darshan Khanal<br>    SpdxLicenseId: MIT<br>    LicenseUrl: &#39;https://github.com/xxxx/&lt;repo_name&gt;/blob/main/LICENSE&#39;<br>    ReadmeUrl: &#39;https://github.com/xxxx/&lt;repo_name&gt;/blob/main/readme.md&#39;<br>    Labels: <br>      - Monitoring<br>      - Alerting<br>      - AutoScaling<br>    HomePageUrl: &#39;https://github.com/xxxx/ASG-&lt;repo_name&gt;&#39;<br>    SourceCodeUrl: &#39;https://github.com/xxxx/&lt;repo_name&gt;&#39;<br>    SemanticVersion: 1.0.0<br><br>Resources:<br>  ASGCapacityAlertFunction:<br>    Type: &#39;AWS::Serverless::Function&#39;<br>    Properties:<br>      Handler: index.lambda_handler<br>      Runtime: python3.8<br>      CodeUri: ./function.zip<br>      Description: &gt;<br>        This function checks the ASG maximum capacity and the target instances in the ALB and notifies us via SNS if the maximum capacity is reached.<br>      MemorySize: 128<br>      Timeout: 30<br>      Policies:<br>        - AWSLambdaBasicExecutionRole<br>        - Version: &#39;2012-10-17&#39;<br>          Statement:<br>            - Effect: Allow<br>              Action:<br>                - &#39;autoscaling:DescribeAutoScalingGroups&#39;<br>                - &#39;elasticloadbalancing:DescribeTargetHealth&#39;<br>                - &#39;sns:Publish&#39;<br>                - &#39;ssm:GetParameter&#39;<br>                - &#39;ssm:PutParameter&#39;<br>              Resource: &#39;*&#39;<br><br>Outputs:<br>  ASGCapacityAlertFunctionArn:<br>    Description: &quot;ARN of the ASG Capacity Alert Lambda Function&quot;<br>    Value: !GetAtt ASGCapacityAlertFunction.Arn</pre><p><strong>4. Add bucket policy</strong></p><p>Add a policy to the S3 bucket to allow access from the Serverless Application Repository:</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;: &quot;serverlessrepo.amazonaws.com&quot;<br>            },<br>            &quot;Action&quot;: &quot;s3:GetObject&quot;,<br>            &quot;Resource&quot;: &quot;arn:aws:s3:::asg-checker-lambda/*&quot;<br>        }<br>    ]<br>}</pre><p><strong>5. Package the SAM Template</strong></p><p>Package the SAM template and upload it to S3:</p><pre>sam package - template-file template.yaml - output-template-file packaged.yaml - s3-bucket asg-checker-lambda - region us-east-1</pre><p><strong>6. Publish to AWS Serverless Application Repository</strong></p><p>Publish your application to the Serverless Application Repository:</p><pre>sam publish - template packaged.yaml - region us-east-1</pre><p><strong>7. Deploy the Application</strong></p><p>Deploy the application stack using AWS SAM:</p><pre>sam deploy - template-file packaged.yaml - stack-name AsgCapacityCheckerStack - capabilities CAPABILITY_IAM - region us-east-1</pre><p><strong>Tips</strong>: After Lambda is created, you can schedule to run the lambda at certain time using EventBridge Scheduler.</p><p><strong>Licensing and Public Sharing</strong></p><p>To make your serverless application public on the AWS Serverless Application Repository, you need to have a license similar to the one you used for your GitHub repository, such as the MIT License. Ensure your application complies with the licensing requirements and update the `LicenseUrl` and `License` fields in the SAM template accordingly.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6cfd797f3ea3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Build Amazon VPC with Public /Private Subnets and Deploy Apache server in EC2 instance]]></title>
            <link>https://medium.com/@dibaekhanal101/build-amazon-vpc-with-public-private-subnets-and-deploy-apache-server-in-ec2-instance-3632a13ec488?source=rss-f814343e861a------2</link>
            <guid isPermaLink="false">https://medium.com/p/3632a13ec488</guid>
            <category><![CDATA[vpc]]></category>
            <category><![CDATA[amazon-web-services]]></category>
            <category><![CDATA[cloud]]></category>
            <category><![CDATA[apache]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Dibya Darshan Khanal]]></dc:creator>
            <pubDate>Mon, 04 Mar 2024 14:18:38 GMT</pubDate>
            <atom:updated>2024-08-04T08:34:24.016Z</atom:updated>
            <content:encoded><![CDATA[<p>The article provides a step-by-step guide on how to build an Amazon Virtual Private Cloud (VPC) with public and private subnets and deploy an Apache server in an EC2 instance. It covers the creation of a VPC, setting up public and private subnets, configuring routing and security groups, and finally deploying an Apache server on an EC2 instance within the private subnet.</p><p><strong>Task1: Create New VPC</strong></p><ol><li>Navigate to VPC by clicking on <strong>service</strong> on the top of AWS Console.</li><li>Click on <strong>VPC</strong> (under <strong>Networking &amp; Content Delivery</strong> section) or you can also search for VPC.</li><li>Click on <strong>Your VPCs </strong>from the left menu.</li><li>Here you can see the list of all VPC. No need to do anything with the existing and default VPCs, we will create a new VPC for this lab.</li><li>Click on Create VPC.</li><li><strong>Name tag: </strong>Enter a VPC name for identification to your VPC. Ex<strong><em>: </em>MyVpc</strong></li><li><strong>IPv4 CIDR block: </strong>Enter<strong> <em>10.0.0.0/16</em></strong></li><li><strong>IPv6 CIDR block: </strong>No need to change this, make sure <strong>No IPv6 CIDR Block</strong> is checked.</li><li><strong>Tenancy: </strong>No need to change this, make sure <strong>Default </strong>is selected.</li><li>Now click on <strong>Create VPC</strong>.</li><li>Once VPC is created, it will appear with details as shown below:</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*AwYauyjgqTT4zE8O" /></figure><p><strong>Task2: Create Subnet</strong></p><p>In this lab, we will create one public subnet and a private subnet in us-east-1a and us-east-1b Availability Zones respectively as follows:</p><ol><li>For the Public Subnet<strong>,</strong> click on <strong>Subnets</strong> from the left menu and click on <strong>Create subnet</strong>.</li></ol><ul><li><strong>VPC ID : </strong>Select <strong>MyVpc</strong> from the list you created earlier.</li><li><strong>Subnet Name : </strong>Enter Name <strong><em>MyPublicSubnet</em></strong></li><li><strong>Availability Zone : </strong>Select <strong>us-east-1a</strong></li><li><strong>IPv4 CIDR block : </strong>Enter the range <strong><em>10.0.1.0/24</em></strong></li><li>Click on <strong>Create subnet.</strong></li></ul><ol><li>For the Private Subnet<strong>,</strong> click on <strong>Create subnet</strong> again.</li></ol><ul><li><strong>VPC ID : </strong>Select <strong>MyVPC</strong> from the list you created earlier.</li><li><strong>Subnet Name : </strong>Enter Name <strong><em>MyPrivateSubnet</em></strong></li><li><strong>Availability Zone : </strong>Select <strong>us-east-1b</strong></li><li><strong>IPv4 CIDR block : </strong>Enter the range <strong><em>10.0.2.0/24</em></strong></li><li>Click on <strong>Create subnet.</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*845ob2jNMOf75mPe" /></figure><p><strong>Task3: Create and Configure internet gateway</strong></p><p>Click on Internet Gateways from the left menu and click <strong>Create Internet gateway</strong>.</p><ul><li><strong>Name Tag </strong>: Enter <strong><em>MyInternetGateway</em>.</strong></li><li>Click on <strong>Crete Internet gateway</strong></li></ul><p>Select the Internet gateway you created from the list</p><ul><li>Click on Actions.</li><li>Click on Attach to VPC.</li><li>Select MyVPC which you created from the list and click on Attach internet gateway.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*yo8DRp93k21JOLDF" /></figure><p><strong>Task 4 : Create Route Tables</strong></p><ol><li>Go to <strong>Route Tables</strong> from the left menu and click on <strong>Create route table</strong>.</li></ol><ul><li><strong>Name Tag: </strong>Enter <strong><em>PublicRouteTable</em></strong>.</li><li><strong>VPC: </strong>Select <strong>MyVpc</strong> from the list.</li><li>Click on <strong>Create route table</strong>.</li></ul><ol><li>Repeat the same steps to create a route table for the Private subnet.</li></ol><ul><li><strong>Name Tag: </strong>Enter <strong><em>PrivateRouteTable</em></strong>.</li><li><strong>VPC: </strong>Select <strong>MyCloudVpc</strong> from the list.</li><li>Click on <strong>Create route table</strong>.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*cHhcKf8Z3WvKD-Ge" /></figure><ol><li>Now <strong>associate the subnets</strong> to the route tables.</li><li>Click on one <strong>PublicRouteTable</strong> and go to the <strong>Subnet Associations</strong> tab.</li></ol><ul><li>Click on Edit Subnet Associations.</li><li>Select <strong>MyPublicSubnet</strong> from the list.</li><li>Click on <strong>Save associations</strong>.</li></ul><ol><li>Click on one <strong>PrivateRouteTable</strong> and go to the <strong>Subnet Associations</strong> tab.</li></ol><ul><li>Click on Edit <strong>Subnet Associations</strong>.</li><li>Select <strong>MyPrivateSubnet</strong> from the list.</li><li>Click on <strong>Save associations</strong>.</li></ul><ol><li>Make sure not to associate any subnets with the <strong>Main Route Table</strong>.</li><li><strong>PublicRouteTable</strong>: Add a route to allow Internet traffic to the VPC.</li></ol><ul><li>Select <strong>PublicRouteTable.</strong></li><li>Go to <strong>Routes</strong> tab, click on <strong>Edit Route</strong> and on the next page, click on <strong>Add Route.</strong></li><li>Specify the following values:</li><li><strong>Destination:</strong> Enter <strong><em>0.0.0.0/0</em></strong></li><li><strong>Target:</strong> Select <strong>Internet Gateway</strong> from the dropdown menu to select <strong>MyInternetGateway</strong>.</li><li>Click on <strong>Save changes</strong>.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*J5QzHkmcgbS1qgTO" /></figure><p><strong>Task 5 Launching an EC2 instance</strong></p><ol><li>Navigate to <strong>Instances </strong>on the left panel and click on <strong>Launch instances.</strong></li><li><strong>Choose an Amazon Machine Image (AMI):</strong> Search for <strong>Amazon Linux 2 AMI</strong> in the search box and click on the <strong>select</strong> button</li><li><strong>Note: if there are two AMI’s present for Amazon Linux 2 AMI, choose any of them.</strong></li><li><strong>Choose an Instance Type:</strong> select <strong>T2.micro (free eligible)</strong> and then click on the <strong>Next: Configure Instance details</strong></li><li><strong>Configure Instance Details: Select </strong>MyCloudlayaVpc and in subnet choose <strong>MyPublicSubnet</strong> then <strong>Enable</strong> <strong>Auto-assign Public IP</strong> , click <strong>on Next: Add Storage</strong></li></ol><p><strong>Note:</strong> Ignore the warning in the IAM Role selection section</p><ol><li><strong>Add Storage:</strong> No need to change anything in this step, click on <strong>Next: Add Tag</strong></li><li><strong>Add Tags:</strong> Click on Add Tag</li><li>Key : Enter <strong><em>Name</em></strong></li><li>Value : Enter <strong><em>MyEC2Server</em></strong></li><li>Click on <strong>Next: Configure security Group=</strong></li><li><strong>Configure Security Group:</strong></li><li>Assign a security group : Select <strong>Create a new security group</strong></li><li>Security group name : Enter <strong><em>MyEC2Server_SG</em></strong></li><li>Description : Enter <strong><em>Security Group to allow traffic to EC2</em></strong></li></ol><p>To add <strong>SSH</strong>,</p><ol><li>Choose Type: <strong>SSH</strong></li><li>Source: Select <strong>Anywhere (From ALL IP addresses accessible).</strong></li></ol><p>For <strong>HTTP,</strong></p><ol><li>Click on <strong>Add Rule</strong></li><li>Choose Type: <strong>HTTP</strong></li><li>Source: Select <strong>Anywhere (From ALL IP addresses accessible).</strong></li><li>After that, click on <strong>Review and Lunch</strong></li><li><strong>Review and Launch : </strong>Review all settings and click on <strong>Lunch.</strong></li><li><strong>Key Pair : </strong>Select<strong> Create a new key pair</strong></li><li>Key pair type : Select <strong>RSA</strong></li><li>Key pair name : Enter <strong><em>MyEC2Key</em></strong></li><li>click on <strong>Download Key pair</strong> , and store it on your local machine, Click on <strong>Lunch Instances.</strong></li></ol><p><strong>Launch Status:</strong> Your instance is now launching, Click on the instance ID and wait for complete initialization of instance till status change to <strong>Running.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*zMmU9M-sT8pSJWkN" /></figure><p><strong>Task 6: SSH to EC2-instance</strong></p><ol><li>Select your EC2 instance(<strong>MyEC2Server</strong>) and click on the <strong>Connect </strong>button.</li><li>Select <strong>EC2 Instance Connect </strong>option and click on <strong>Connect </strong>button.(Keep everything else as default)</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/802/0*yfRynic5iOcPnQJg" /></figure><ol><li>A new tab will open in the browser where you can execute the CLI Commands.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/816/0*3mkR8wnFHq80EVKS" /></figure><p><strong>Task 6: Install an Apache Server</strong></p><ol><li>Switch to root user: <strong>sudo su</strong></li><li>Now run the updates using the following command:</li></ol><ul><li><strong>yum -y update</strong></li></ul><ol><li>Once completed, lets install and run an apache server</li></ol><p>Install the Apache web server:</p><ul><li><strong>yum install httpd -y</strong></li></ul><p>Start the web server</p><ul><li><strong>systemctl start httpd</strong></li></ul><p>Now enable httpd:</p><ul><li><strong>systemctl enable httpd</strong></li></ul><p>Check the web server status</p><ul><li><strong>systemctl status httpd</strong></li></ul><p>You can see Active status is running.</p><ul><li>Go to path <strong>cd /var/www/html </strong>then create a html file example index.html</li></ul><p>Vi index.html</p><ul><li>Click I for insert then write Hello Cloudlaya</li><li>Click on esc button then click colon wq (:wq) for save and quite.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/626/0*_47f5sIBUkDOAZzZ" /></figure><ul><li>You can test that your web server is properly installed and started by entering the <strong>public IPv4 address</strong> of your <strong>EC2 instance</strong> in the address bar of a web browser.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/492/0*20tHhvxGNlsl7rge" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3632a13ec488" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Enable Password Authentication in AWS ec2 Instances]]></title>
            <link>https://medium.com/@dibaekhanal101/how-to-enable-password-authentication-in-aws-ec2-instances-374df456472e?source=rss-f814343e861a------2</link>
            <guid isPermaLink="false">https://medium.com/p/374df456472e</guid>
            <category><![CDATA[ubuntu]]></category>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[ssh]]></category>
            <category><![CDATA[centos]]></category>
            <dc:creator><![CDATA[Dibya Darshan Khanal]]></dc:creator>
            <pubDate>Sun, 13 Aug 2023 09:30:28 GMT</pubDate>
            <atom:updated>2025-12-19T19:16:16.857Z</atom:updated>
            <content:encoded><![CDATA[<p>While this tutorial provides guidance on enabling password authentication for AWS EC2 instances, it is essential to note that implementing password-based authentication is not recommended for production or any development environment where security is a critical concern. The use of password authentication introduces potential security vulnerabilities and may expose your instances to unauthorized access.</p><p>By default, AWS ec2 instances don’t have password authentication. You have to use the private key to connect to the instances. However, you might have situations to use password-based authentication for your AWS ec2 instances.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/0*YBtxEA42R1k-AD6F.png" /></figure><p>In this tutorial, we have done the configuration to enable password authentication in AWS instances.</p><p><strong>Step 1:</strong></p><p>Login to AWS instances</p><blockquote>ssh -i your-key.pem username@ip_address</blockquote><p><strong>Step 2:</strong></p><p>Set up a password for the user using <strong>passwd</strong> command along with the <strong>username</strong>.</p><blockquote>sudo passwd ubuntu</blockquote><p><strong>Step 3:</strong></p><p>Edit <strong>sshd_config</strong> file.</p><blockquote>sudo nano /etc/ssh/sshd_config</blockquote><p>Find the Line containing <strong>‘PasswordAuthentication’</strong> parameter and change its value from <strong>‘no’</strong> to <strong>‘yes’</strong></p><p><em>PasswordAuthentication yes</em></p><p>If you want to set up <strong>‘root’</strong> login, find <strong>‘PermitRootLogin’</strong> parameter and change its value from <strong>‘prohibit-password’</strong> to <strong>‘yes’</strong></p><p><em>PermitRootLogin yes</em></p><p>After this changes <strong>save file</strong> and exit.</p><p><strong>Step 4:</strong></p><p>Restart the SSH service.</p><blockquote>sudo systemctl restart ssh ## for ubuntu</blockquote><blockquote>sudo service sshd restart ## for centos</blockquote><p><strong>Step 5:</strong></p><p>Now we can log in using the password you set for the user. For example,</p><blockquote>ssh ubuntu@IP_Address</blockquote><p>and, enter password to login to the server.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=374df456472e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[OpenShift, integration with cloud solutions, comparisons, and, Security issues]]></title>
            <link>https://medium.com/@dibaekhanal101/openshift-integration-with-cloud-solutions-comparisons-and-security-issues-dab26c275b2c?source=rss-f814343e861a------2</link>
            <guid isPermaLink="false">https://medium.com/p/dab26c275b2c</guid>
            <category><![CDATA[cloud]]></category>
            <category><![CDATA[redhat-linux]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[opensearch]]></category>
            <dc:creator><![CDATA[Dibya Darshan Khanal]]></dc:creator>
            <pubDate>Sun, 13 Aug 2023 09:24:15 GMT</pubDate>
            <atom:updated>2023-08-13T17:44:09.981Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>I. Introduction:</strong></p><p>OpenShift is a container application platform developed by Red Hat, which provides a complete platform for deploying and managing applications in the cloud. It was first released in 2011, and since then it has become one of the most popular platforms for building, deploying, and scaling applications in the cloud.</p><p>The OpenShift platform is built on top of Kubernetes, which is an open-source container orchestration system. OpenShift adds additional layers of functionality, such as a web console, integrated CI/CD tools, and security features, that make it easier for developers to manage their applications.</p><p><strong>II. History of OpenShift:</strong></p><p>The history of OpenShift dates back to 2010 when Red Hat acquired Makara, a cloud application platform company. Makara’s technology formed the basis for Red Hat’s OpenShift platform. OpenShift was initially released as a public beta in May 2011, and it was made generally available in June 2012.</p><p>The original version of OpenShift was based on the PaaS (Platform as a Service) model, which provides a complete platform for building, deploying, and managing applications in the cloud. However, in 2015, Red Hat introduced a new version of OpenShift, called OpenShift Container Platform, which is based on the container orchestration system Kubernetes.</p><p>Since then, OpenShift has become one of the most popular container application platforms, used by organizations of all sizes to deploy and manage their applications in the cloud. In addition to OpenShift Container Platform, Red Hat also offers a number of other OpenShift products, including OpenShift Online, OpenShift Dedicated, and OpenShift Enterprise.</p><p><strong>III. OpenShift Services:</strong></p><p>Red Hat offers several types of OpenShift services to meet different deployment needs and requirements. Here are the main types of OpenShift services:</p><ul><li><strong>OpenShift Container Platform:</strong> This is the flagship product of OpenShift, and it is a complete container application platform for deploying, managing, and scaling applications in the cloud. It is based on Kubernetes, and it provides a set of integrated tools for developers to build, test, and deploy applications.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*3g0TvzI7y0oUDjFc" /></figure><ul><li><strong>OpenShift Dedicated: </strong>This is a fully-managed version of OpenShift Container Platform that is hosted and managed by Red Hat. It is designed for organizations that want to use OpenShift but do not want to manage the infrastructure themselves. OpenShift Dedicated provides a dedicated cluster of OpenShift nodes, which can be customized to meet specific requirements.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/0*QOnjAZMkDGwugxYZ" /></figure><ul><li><strong>OpenShift Online:</strong> This is a hosted version of OpenShift that is designed for developers who want to deploy their applications quickly without managing the underlying infrastructure. OpenShift Online provides a web-based interface for developers to build, test, and deploy their applications.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*lM7vH1OWgiOynDI2" /></figure><ul><li><strong>OpenShift Container Storage: </strong>This is a container-native storage solution that is integrated with OpenShift. It provides persistent storage for containerized applications, and it is based on the GlusterFS file system. OpenShift Container Storage can be used to store data for stateful applications, such as databases.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*nCL3N9BKWtuY8TEK" /></figure><ul><li><strong>OpenShift Service Mesh:</strong> This is a service mesh solution that is integrated with OpenShift. It provides a set of tools for managing the communication between microservices, including traffic routing, service discovery, and load balancing.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/752/0*KVRJOBxkMqMkbh7Z" /></figure><ul><li><strong>OpenShift Virtualization:</strong> This is a platform for running virtual machines (VMs) on OpenShift. It enables organizations to run legacy applications that cannot be containerized directly on OpenShift. OpenShift Virtualization provides a set of tools for managing VMs, including virtual networking, storage, and security.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/0*volZgHPeE5_l0cUH" /></figure><p><strong>IV. Redhat Openshift integration with other cloud solutions:</strong></p><p>Red Hat OpenShift is designed to integrate with a wide range of cloud solutions, allowing organizations to leverage the strengths of multiple cloud platforms while still using OpenShift as their primary application platform. Here are some examples of how OpenShift can integrate with other cloud solutions:</p><ul><li><strong>Cloud providers: </strong>OpenShift can be deployed on various cloud providers such as Amazon Web Services, Google Cloud, and Microsoft Azure. This allows organizations to use OpenShift as their application platform while still leveraging the benefits of a cloud provider’s infrastructure and services.</li><li><strong>Infrastructure as code tools: </strong>OpenShift integrates with popular infrastructure as code tools such as Ansible, Terraform, and Puppet. This allows organizations to automate the deployment and management of OpenShift clusters using familiar tools and workflows.</li><li><strong>Container registries: </strong>OpenShift can integrate with container registries such as Docker Hub, Quay, and Google Container Registry. This allows organizations to store their container images in a centralized location and deploy them to OpenShift clusters as needed.</li><li><strong>Service mesh solutions: </strong>OpenShift integrates with service mesh solutions such as Istio and Maistra. This allows organizations to manage the communication between microservices running on OpenShift clusters using advanced features such as traffic routing, load balancing, and service discovery.</li><li><strong>Continuous integration and deployment (CI/CD) tools: </strong>OpenShift integrates with popular CI/CD tools such as Jenkins, GitLab, and CircleCI. This allows organizations to automate the build, test, and deployment of their applications on OpenShift clusters using their preferred CI/CD workflows.</li></ul><p>By integrating with these and other cloud solutions, OpenShift provides a flexible and powerful platform for building, deploying, and scaling applications in the cloud.</p><p><strong>V. Competitors of OpenStack</strong></p><ul><li><strong>Kubernetes</strong>: Kubernetes is an open-source container orchestration system that is the foundation for OpenShift. Many organizations choose to use Kubernetes directly instead of OpenShift, especially if they want a more lightweight and customizable solution.</li><li><strong>Docker Swarm: </strong>Docker Swarm is a container orchestration system that is built into Docker. While it is not as feature-rich as Kubernetes or OpenShift, it is often seen as an easier-to-use solution for smaller deployments.</li><li><strong>Google Kubernetes Engine (GKE):</strong> GKE is a managed Kubernetes service provided by Google Cloud. It offers many of the same features as OpenShift, including a web-based console and integrated CI/CD tools.</li><li><strong>Amazon Elastic Kubernetes Service (EKS): </strong>EKS is a managed Kubernetes service provided by Amazon Web Services. Like GKE, it offers many of the same features as OpenShift.</li><li><strong>Rancher</strong>: Rancher is an open-source container management platform that offers Kubernetes as well as its own lightweight orchestration system. It is often seen as a more flexible and customizable solution than OpenShift.</li><li><strong>IBM Cloud Kubernetes Service:</strong> IBM Cloud offers a managed Kubernetes service that includes built-in security features and integrated DevOps tools.</li></ul><p>While OpenShift has many competitors, its strong integration with Kubernetes and the Red Hat ecosystem, as well as its comprehensive feature set, make it a popular choice for many organizations.</p><p><strong>VI. Benefits of using OpenShift</strong></p><ul><li><strong>Integrated ecosystem: </strong>OpenShift is an enterprise-ready container application platform that is built on top of Kubernetes. It provides a comprehensive ecosystem of tools and services for developers and IT operations teams, including an integrated web-based console, CI/CD pipelines, and a container registry.</li><li><strong>Developer productivity: </strong>OpenShift simplifies the process of building and deploying containerized applications, allowing developers to focus on writing code rather than managing infrastructure. It provides a set of developer-focused tools, such as source-to-image (S2I) builds and GitOps workflows, that streamline the development process and increase productivity.</li><li><strong>Hybrid cloud support: </strong>OpenShift can be deployed on-premises or in the cloud, allowing organizations to choose the deployment model that best suits their needs. It also supports hybrid cloud scenarios, allowing workloads to run across multiple environments.</li><li><strong>Security and compliance:</strong> OpenShift includes a range of security features, such as network policies, pod security policies, and integrated identity and access management. It also supports compliance standards such as PCI DSS, HIPAA, and SOC 2, making it suitable for use in regulated industries.</li><li><strong>Multi-tenancy: </strong>OpenShift provides multi-tenancy capabilities, allowing multiple teams or applications to share the same infrastructure while maintaining isolation and security.</li><li><strong>Enterprise support: </strong>OpenShift is supported by Red Hat, a leading provider of enterprise software and services. Red Hat offers comprehensive support and training for OpenShift, ensuring that organizations can get the most out of their investment in the platform.</li></ul><p>Overall, OpenShift’s strong integration with Kubernetes, a comprehensive ecosystem of tools and services, and support for hybrid cloud and multi-tenancy scenarios make it a popular choice for organizations looking to build and deploy containerized applications at scale.</p><p><strong>VII. Openshift vs Kubernetes vs Containers</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/576/1*JJqih-PQTTn0dejoIeRBYQ.png" /></figure><p><strong>VIII. Potential security risks with OpenStack</strong></p><h3>A.</h3><p>OpenStack, like any other cloud platform, has several potential security risks that can impact the security of an application or data hosted on it. Here are some examples:</p><ul><li><strong>Insecure API: </strong>The OpenStack API is a critical component that enables users to interact with the platform’s resources. If the API is not properly secured, attackers can exploit vulnerabilities to access sensitive data or launch attacks on the platform.</li><li><strong>Misconfigured Security Controls: </strong>OpenStack provides a range of security controls, such as network isolation, access controls, and encryption. However, if these controls are not properly configured, attackers can bypass them and gain unauthorized access to resources.</li><li><strong>Insider Threats:</strong> Insiders, such as employees or contractors, with access to OpenStack resources, can misuse their privileges to steal data or launch attacks on the platform.</li><li><strong>Advanced Persistent Threats (APTs): </strong>APTs are sophisticated cyberattacks that are designed to evade detection and remain undetected for long periods of time. APTs can use various techniques to gain access to OpenStack resources, such as social engineering, phishing, or exploiting vulnerabilities.</li><li><strong>Third-Party Services: </strong>Many OpenStack deployments rely on third-party services, such as cloud storage or authentication services. If these services are not properly secured, attackers can exploit vulnerabilities to gain access to the OpenStack environment and launch attacks.</li><li><strong>Network Vulnerabilities: </strong>OpenStack relies on the underlying network infrastructure for communication between nodes and resources. If the network infrastructure is not properly secured, attackers can exploit vulnerabilities to intercept traffic, launch man-in-the-middle attacks, or steal data.</li></ul><h3>B.</h3><p>A real-world scenario that can cause issues while using the OpenStack platform to host an entire application, despite meeting all security compliance requirements, is a zero-day vulnerability or an undiscovered security flaw.</p><p>Suppose a company hosts a mission-critical application on OpenStack that handles sensitive data and has implemented all recommended security controls and compliance regulations. However, an attacker discovers a previously unknown vulnerability in the OpenStack platform that allows them to gain unauthorized access to the application’s resources or data.</p><p>The vulnerability may not have been discovered during regular security assessments or scans, and no known patch or update exists to fix the flaw. The attacker can then use the vulnerability to launch an attack on the application, potentially causing data breaches, system outages, or other serious consequences.</p><p>To mitigate this scenario, it is essential to have a proactive approach to security and stay up-to-date with the latest security threats and vulnerabilities. Companies should also consider implementing threat detection and incident response mechanisms, such as intrusion detection systems (IDS) and security event monitoring (SEM), to quickly detect and respond to security incidents.</p><p>Moreover, regular security assessments, penetration testing, and vulnerability scanning should be carried out to identify and remediate potential security issues. Additionally, companies should have a disaster recovery plan in place to ensure that data can be quickly restored in the event of a security incident or system failure.</p><p>In summary, even if all security compliance requirements are met properly, it is crucial to have a comprehensive security strategy that includes regular assessments, threat detection mechanisms, and a robust incident response plan to mitigate potential vulnerabilities and zero-day exploits.</p><p><strong>IX. References</strong></p><p>[1] Red Hat. Inc. (2018). An introduction to enterprise Kubernetes. <a href="https://www.redhat.com/cms/managed-files/cl-openshift-kubernetes-primer-technichal-detail-f13237wg-201807-en.pdf">https://www.redhat.com/cms/managed-files/cl-openshift-kubernetes-primer-technichal-detail-f13237wg-201807-en.pdf</a></p><p>[2] Kushwaha, A. (2021) “Interantional Journal of Scientific Research in Engineering and management,” <em>Research Paper on Redhat Openshift Cloud Platform</em>, 05 (04). Available at: <a href="https://doi.org/10.55041/ijsrem.">https://doi.org/10.55041/ijsrem.</a></p><p>[3] Palumbo, A. (2022) “Redhat openshift,” Literature Review on Kubernetes &amp;amp; RedHat Openshift Container Platform [Preprint]. Available at: <a href="https://doi.org/10.13140/RG.2.2.31190.32322.">https://doi.org/10.13140/RG.2.2.31190.32322.</a></p><p>[4] CloudZero (no date) <em>Kubernetes vs. Docker vs. OpenShift: What’s the difference?</em>, <em>CloudZero</em>. Available at: <a href="https://www.cloudzero.com/blog/kubernetes-vs-docker">https://www.cloudzero.com/blog/kubernetes-vs-docker</a> (Accessed: April 12, 2023).</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dab26c275b2c" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>