<?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 Bhupeshpandey on Medium]]></title>
        <description><![CDATA[Stories by Bhupeshpandey on Medium]]></description>
        <link>https://medium.com/@bhupeshpandey589?source=rss-42856b9efeaa------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*tXW1n2-5i18QRils</url>
            <title>Stories by Bhupeshpandey on Medium</title>
            <link>https://medium.com/@bhupeshpandey589?source=rss-42856b9efeaa------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 17:09:37 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@bhupeshpandey589/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[Control AWS EC2 Using Telegram Bot + AWS Lambda (Step-by-Step Serverless Guide)]]></title>
            <link>https://medium.com/@bhupeshpandey589/control-aws-ec2-using-telegram-bot-aws-lambda-step-by-step-serverless-guide-0d7ce13d6a2e?source=rss-42856b9efeaa------2</link>
            <guid isPermaLink="false">https://medium.com/p/0d7ce13d6a2e</guid>
            <category><![CDATA[serverless]]></category>
            <category><![CDATA[aws-lambda]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[amazon-ec2]]></category>
            <category><![CDATA[automation]]></category>
            <dc:creator><![CDATA[Bhupeshpandey]]></dc:creator>
            <pubDate>Tue, 17 Mar 2026 13:54:32 GMT</pubDate>
            <atom:updated>2026-03-17T13:54:32.703Z</atom:updated>
            <content:encoded><![CDATA[<h3>Control AWS EC2 Using Telegram messages + AWS Lambda (Step-by-Step, Serverless &amp; Low Cost)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dSPKY53lwGaEp8uC0PthCQ.png" /></figure><p>Managing cloud servers usually means logging into AWS, using SSH, or running scripts.</p><p>That works, but it is not efficient for real life.</p><ul><li>You may not have your laptop</li><li>You may need quick action</li><li>You don’t want to maintain another server</li></ul><p>There is a better way.</p><p><em>👉 Control your AWS EC2 server directly from Telegram<br>👉 No backend server required<br>👉 Works from your phone anywhere<br>👉 Almost zero additional cost</em></p><p>This guide is designed for <strong>personal setups, freelancers, and small startups</strong> who want a simple but production-ready solution.</p><h3>What You Are Building</h3><p>You are building a <strong>serverless remote control system</strong>.</p><p>Flow:</p><p>You → Telegram → AWS Lambda → EC2 → Action</p><p>What happens behind the scenes:</p><ul><li>You send a command like /restart</li><li>Telegram sends it to your backend</li><li>AWS Lambda processes it</li><li>EC2 performs the action</li></ul><p><em>👉 This is called an </em><strong><em>event-driven architecture</em></strong><em> (used in real production systems)</em></p><h3>Step 1: Create a Telegram Bot</h3><p>Why this is needed:<br>We need a system that can receive your commands.</p><p>Steps:</p><ul><li>Open Telegram</li><li>Search <strong>BotFather</strong></li><li>Send /start</li><li>Then /newbot</li><li>Enter bot name and username</li></ul><p>You will get:</p><pre>BOT_TOKEN</pre><p><em>👉 This token connects your bot with your backend. Keep it secure.</em></p><h3>Step 2: Understand Webhook (Core Concept)</h3><p>Why this matters:<br>This decides how messages reach your system.</p><p>Two approaches:</p><ul><li>Polling → system keeps asking Telegram repeatedly</li><li>Webhook → Telegram sends data instantly</li></ul><p>We use webhook because:</p><ul><li>Faster</li><li>More efficient</li><li>Production-friendly</li></ul><p><em>👉 Telegram sends your message directly to AWS</em></p><h3>Step 3: Create AWS Lambda (Backend Brain)</h3><p>Why this is needed:<br>This is where your logic runs.</p><p>Steps:</p><ul><li>Go to AWS → Lambda</li><li>Click <strong>Create Function</strong></li><li>Runtime: Python</li><li>Name: telegram-ec2-controller</li></ul><p><em>👉 Lambda runs only when triggered (no idle cost)</em></p><h3>Step 4: Attach Permissions (Very Important)</h3><p>Why this is needed:<br>Lambda cannot control EC2 without permission.</p><p>Steps:</p><ul><li>Open IAM Role linked to Lambda</li><li>Attach policy:</li></ul><pre>AmazonEC2FullAccess</pre><p><em>👉 This allows start, stop, restart actions</em></p><h3>Step 5: Add Logic to Control EC2</h3><p>Why this is needed:<br>We define what happens when a message comes.</p><pre>import json<br>import boto3<br>import urllib.request</pre><pre>TOKEN = &quot;YOUR_BOT_TOKEN&quot;<br>INSTANCE_ID = &quot;YOUR_INSTANCE_ID&quot;</pre><pre>ec2 = boto3.client(&#39;ec2&#39;, region_name=&#39;ap-south-1&#39;)</pre><pre>def send_message(chat_id, text):<br>    url = f&quot;https://api.telegram.org/bot{TOKEN}/sendMessage&quot;<br>    data = json.dumps({<br>        &quot;chat_id&quot;: chat_id,<br>        &quot;text&quot;: text<br>    }).encode(&quot;utf-8&quot;)</pre><pre>    req = urllib.request.Request(url, data=data, headers={&#39;Content-Type&#39;: &#39;application/json&#39;})<br>    urllib.request.urlopen(req)</pre><pre>def lambda_handler(event, context):<br>    body = json.loads(event[&#39;body&#39;])<br>    <br>    message = body.get(&quot;message&quot;, {})<br>    chat_id = message.get(&quot;chat&quot;, {}).get(&quot;id&quot;)<br>    text = message.get(&quot;text&quot;, &quot;&quot;)</pre><pre>    if text == &quot;/start&quot;:<br>        send_message(chat_id, &quot;Bot is active!&quot;)</pre><pre>    elif text == &quot;/restart&quot;:<br>        ec2.reboot_instances(InstanceIds=[INSTANCE_ID])<br>        send_message(chat_id, &quot;Server restarting...&quot;)</pre><pre>    elif text == &quot;/stop&quot;:<br>        ec2.stop_instances(InstanceIds=[INSTANCE_ID])<br>        send_message(chat_id, &quot;Server stopping...&quot;)</pre><pre>    elif text == &quot;/run&quot;:<br>        ec2.start_instances(InstanceIds=[INSTANCE_ID])<br>        send_message(chat_id, &quot;Server starting...&quot;)</pre><pre>    return {<br>        &#39;statusCode&#39;: 200,<br>        &#39;body&#39;: json.dumps(&#39;ok&#39;)<br>    }</pre><p><em>👉 This connects Telegram → AWS → EC2</em></p><h3>Step 6: Why API Gateway is Required</h3><p>Short answer:</p><p>👉 Yes, you need it in most cases</p><p>Reason:</p><ul><li>Telegram needs a <strong>public HTTPS URL</strong></li><li>Lambda alone does not provide one</li></ul><p>So we introduce:</p><p>Telegram → API Gateway → Lambda</p><p>👉 API Gateway exposes your Lambda securely</p><h3>Step 7: Create API Gateway</h3><p>Why this is needed:<br>We need a public endpoint.</p><p>Steps:</p><ul><li>Go to API Gateway</li><li>Create HTTP API</li><li>Connect Lambda</li><li>Deploy</li></ul><p>Example URL:</p><pre>https://abc123.execute-api.ap-south-1.amazonaws.com</pre><h3>Step 8: Connect Telegram (Webhook Setup)</h3><p>Why this is needed:<br>This connects Telegram to your backend.</p><p>Open in browser:</p><pre>https://api.telegram.org/bot&lt;YOUR_TOKEN&gt;/setWebhook?url=&lt;YOUR_API_URL&gt;</pre><p>If successful:</p><pre>{&quot;ok&quot;:true}</pre><h3>Step 9: Test Your Setup</h3><p>Go to your Telegram bot and send:</p><ul><li>/start</li><li>/restart</li><li>/stop</li><li>/run</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HCDzc45KDwohoA1XUVWEtg.png" /></figure><p>👉 Your EC2 instance will respond instantly</p><h3>Cost Breakdown (Real-World View)</h3><p>This setup is extremely cost-efficient.</p><ul><li>AWS Lambda → Free for most users</li><li>API Gateway → Free for low usage</li><li>Telegram → Free</li></ul><p>👉 Additional cost: <strong>~₹0/month</strong></p><p>Only EC2 has cost (which you already pay)</p><h3>Why This Setup is Useful (For Individuals &amp; Startups)</h3><h3>1. No Infrastructure to Maintain</h3><ul><li>No extra servers</li><li>No scripts running 24/7</li></ul><p><em>👉 Ideal for small teams</em></p><h3>2. Remote Control from Anywhere</h3><ul><li>Works on mobile</li><li>No SSH required</li></ul><p><em>👉 Perfect for on-the-go fixes</em></p><h3>3. Production-Ready Design</h3><ul><li>Event-driven architecture</li><li>Serverless backend</li></ul><p><em>👉 Same pattern used by modern companies</em></p><h3>4. Saves Cost</h3><ul><li>No idle compute</li><li>Pay only when used</li></ul><p><em>👉 Important for startups</em></p><h3>5. Easy to Extend</h3><p>You can add:</p><ul><li>Monitoring</li><li>Alerts</li><li>Deployment triggers</li></ul><p><em>👉 This becomes your automation system</em></p><blockquote>You’ve taken a big step from manual work to real automation. Start small, experiment, and improve. This simple setup can grow into much bigger systems.</blockquote><blockquote>👉 And you built it yourself.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0d7ce13d6a2e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Click-to-Deploy on AWS: How GitHub Actions + Terraform + OIDC + EKS + cert-manager Automate Your…]]></title>
            <link>https://medium.com/@bhupeshpandey589/click-to-deploy-on-aws-how-github-actions-terraform-oidc-eks-cert-manager-automate-your-fea3b2d046cf?source=rss-42856b9efeaa------2</link>
            <guid isPermaLink="false">https://medium.com/p/fea3b2d046cf</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[github-actions]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[terraform]]></category>
            <category><![CDATA[devops]]></category>
            <dc:creator><![CDATA[Bhupeshpandey]]></dc:creator>
            <pubDate>Fri, 28 Nov 2025 22:27:35 GMT</pubDate>
            <atom:updated>2025-11-28T22:27:35.582Z</atom:updated>
            <content:encoded><![CDATA[<h3>Click-to-Deploy on AWS: How GitHub Actions + Terraform + OIDC + EKS + cert-manager Automate Your Entire Infrastructure</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dagFFLPY72ybtlcoLGyKbw.png" /></figure><p>Modern DevOps teams no longer run terraform apply from laptops or store long-lived AWS keys in pipelines.<br> Today, the industry standard looks like this:</p><p><strong>Terraform lives inside GitHub → GitHub Actions uses OIDC to assume IAM roles → Terraform creates VPC, EKS, ECR, cert-manager, ALB → CI builds image → CD deploys application → HTTPS comes automatically via Route53.</strong></p><p>This is the exact pattern used at leading companies like Lyft, Netflix, Stripe, and Shopify.<br> In this guide, we walk through how this “Click-to-Deploy” architecture works — and how you can build it cleanly, efficiently, and securely.</p><h3>1. Architecture Overview</h3><p>Here’s how the pipeline works end-to-end:<br><strong>Developer commits / clicks “Run Workflow”</strong><br><strong>GitHub Actions authenticates to AWS using OIDC (no keys)</strong><br><strong>Terraform provisions the entire infra:</strong></p><ul><li>VPC</li><li>Subnets</li><li>NAT + IGW</li><li>EKS cluster</li><li>Node group</li><li>ECR</li><li>IAM roles</li><li>ALB Ingress Controller</li><li>cert-manager with Route53 DNS challenge<br><strong><em>CI builds Docker image → pushes to ECR</em></strong><em><br></em><strong><em>CD applies Kubernetes manifests<br>cert-manager automatically issues HTTPS certificates<br>ALB exposes the app with a public URL</em></strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/902/1*tMzpaKpvdJLFaJUHckYeDw.png" /></figure><p>This results in a <strong>one-click deployment system</strong> used by real production teams.</p><h3>2. Repository Structure (Simple &amp; Maintainable)</h3><pre>project/<br>├── terraform/       → All infrastructure as code<br>├── k8s/             → Application manifests<br>└── .github/workflows/<br>      ├── ci.yml     → Build &amp; push to ECR<br>      └── deploy.yml → Terraform apply + Kubernetes deploy</pre><p>Terraform stays in its own folder.<br> CI/CD stays in GitHub Actions.<br> Kubernetes manifest lives separately.</p><p>Clean. Clear. Scalable.</p><h3>3. Using GitHub OIDC to Access AWS (No Secrets Needed)</h3><p>Instead of storing AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY, we use OIDC, which gives GitHub a <strong>short-lived identity token</strong>.</p><p>AWS trusts GitHub via an IAM OIDC provider.<br> GitHub Actions then assumes a role using:</p><pre>permissions:<br>  id-token: write<br>  contents: read</pre><p>And uses:</p><pre>uses: aws-actions/configure-aws-credentials@v4<br>with:<br>  role-to-assume: arn:aws:iam::&lt;account-id&gt;:role/&lt;github-oidc-role&gt;<br>  aws-region: ap-south-1</pre><p>This is the <strong>most secure</strong> way to run Terraform in pipelines.</p><h3>4. Terraform Creates the Entire AWS Infrastructure</h3><p>The Terraform inside terraform/ is responsible for <strong>everything</strong>:</p><h3>VPC</h3><ul><li>CIDR 10.10.0.0/16</li><li>Public subnets (for ALB)</li><li>Private subnets (for EKS nodes)</li><li>NAT, IGW, routing</li></ul><p>Essential snippet:</p><pre>resource &quot;aws_vpc&quot; &quot;main&quot; {<br>  cidr_block = &quot;10.10.0.0/16&quot;<br>  enable_dns_hostnames = true<br>}</pre><h3>EKS Cluster</h3><p>EKS cluster plus OIDC provider:</p><pre>resource &quot;aws_eks_cluster&quot; &quot;this&quot; {<br>  name     = var.cluster_name<br>  role_arn = aws_iam_role.eks_cluster_role.arn<br>  vpc_config {<br>    subnet_ids = var.private_subnets<br>  }<br>}</pre><h3>Node Group</h3><pre>resource &quot;aws_eks_node_group&quot; &quot;default&quot; {<br>  cluster_name    = aws_eks_cluster.this.name<br>  node_role_arn   = aws_iam_role.eks_node_role.arn<br>  instance_types  = [&quot;t3.medium&quot;]<br>  desired_size    = 2<br>}</pre><h3>ECR Repository</h3><pre>resource &quot;aws_ecr_repository&quot; &quot;app&quot; {<br>  name = &quot;click-deploy-app&quot;<br>}</pre><h3>cert-manager (via Helm)</h3><p>Terraform installs cert-manager and CRDs:</p><pre>resource &quot;helm_release&quot; &quot;certmanager&quot; {<br>  name       = &quot;cert-manager&quot;<br>  repository = &quot;https://charts.jetstack.io&quot;<br>  chart      = &quot;cert-manager&quot;<br>  set {<br>    name  = &quot;installCRDs&quot;<br>    value = true<br>  }<br>}</pre><h3>Route53 DNS Permissions</h3><p>cert-manager needs to write TXT records for DNS-01 challenge:</p><pre>resource &quot;aws_iam_policy&quot; &quot;cert_manager_dns&quot; {<br>  policy = file(&quot;route53-policy.json&quot;)<br>}</pre><h3>ALB Ingress Controller</h3><p>Installed using Helm after creating IRSA role.</p><h3>5. Kubernetes Manifests (Simplified Example)</h3><p>Put these in k8s/.</p><h3>deployment.yaml</h3><pre>apiVersion: apps/v1<br>kind: Deployment<br>metadata:<br>  name: click-app<br>spec:<br>  replicas: 2<br>  selector:<br>    matchLabels:<br>      app: click-app<br>  template:<br>    metadata:<br>      labels:<br>        app: click-app<br>    spec:<br>      containers:<br>      - name: app<br>        image: &lt;ECR-URL&gt;:latest<br>        ports:<br>        - containerPort: 3000</pre><h3>service.yaml</h3><pre>apiVersion: v1<br>kind: Service<br>metadata:<br>  name: click-app-svc<br>spec:<br>  selector:<br>    app: click-app<br>  ports:<br>    - port: 80<br>      targetPort: 3000</pre><h3>ingress.yaml</h3><p>Using ALB + cert-manager:</p><pre>apiVersion: networking.k8s.io/v1<br>kind: Ingress<br>metadata:<br>  name: click-app-ingress<br>  annotations:<br>    kubernetes.io/ingress.class: alb<br>    cert-manager.io/cluster-issuer: letsencrypt-prod<br>spec:<br>  tls:<br>    - hosts: [ &quot;yourdomain.com&quot; ]<br>      secretName: tls-click-app<br>  rules:<br>    - host: yourdomain.com<br>      http:<br>        paths:<br>          - path: /<br>            pathType: Prefix<br>            backend:<br>              service:<br>                name: click-app-svc<br>                port:<br>                  number: 80</pre><p>When applied, cert-manager automatically requests and manages the certificate via Route53.</p><h3>6. CI Pipeline (Build → Push to ECR)</h3><p>.github/workflows/ci.yml:</p><pre>uses: aws-actions/configure-aws-credentials@v4<br>with:<br>  role-to-assume: arn:aws:iam::&lt;account&gt;:role/&lt;github-oidc-role&gt;<br>  aws-region: ap-south-1</pre><p>Then:</p><pre>docker build -t $ECR:latest .<br>docker push $ECR:latest</pre><p>This ensures each push builds the latest container image.</p><h3>7. CD Pipeline (Click-to-Deploy Everything)</h3><p>.github/workflows/deploy.yml does:</p><ol><li>Configure AWS via OIDC</li><li>Terraform init + apply</li><li>Update kubeconfig</li><li>Install cert-manager + ALB controller</li><li>Deploy the application</li><li>Create ingress → HTTPS ready</li></ol><p>Snippet:</p><pre>terraform init<br>terraform apply -auto-approve</pre><pre>aws eks update-kubeconfig --name $CLUSTER</pre><pre>kubectl apply -f k8s/</pre><p>When someone clicks <strong>Run Workflow</strong>, this entire pipeline provisions — or updates — everything automatically.</p><h3>8. Validating the Deployment</h3><p>Check pods:</p><pre>kubectl get pods</pre><p>Check ingress:</p><pre>kubectl get ingress</pre><p>You should see:</p><pre>ADDRESS: &lt;ALB-DNS&gt;<br>HOSTS: yourdomain.com<br>TLS: True</pre><p>Testing in browser:</p><pre>https://yourdomain.com</pre><p>Your app is online with a valid Let’s Encrypt certificate.</p><h3>9. Why Companies Use This Approach</h3><h3>No long-lived AWS keys</h3><p>OIDC gives GitHub short-lived credentials.</p><h3>Fully versioned infrastructure</h3><p>Terraform inside GitHub = every resource change is tracked.</p><h4>Developer self-service</h4><p>Click “Run Workflow” → full infra deployed.</p><h4>Reproducible environments</h4><p>Dev, Staging, Prod can all be created identically.</p><h4>Automated TLS</h4><p>cert-manager + Route53 means no more manual certificate handling.</p><h4>Scales with team growth</h4><p>This is the base pattern for GitOps, ArgoCD, and Platform Engineering.</p><h3>Conclusion</h3><p>This setup gives you a <strong>true Click-to-Deploy environment</strong> on AWS:</p><ul><li>GitHub Actions authenticates securely via OIDC</li><li>Terraform provisions the entire infrastructure</li><li>CI builds the container image into ECR</li><li>CD deploys to EKS</li><li>cert-manager issues TLS certificates automatically</li><li>ALB exposes your app globally</li></ul><p><em>The best part of building this pipeline was watching everything come together with a single workflow trigger. No keys, no manual provisioning, no late-night cluster patching. Just clean automation. This is the kind of setup I personally rely on for my own projects, and I hope it gives you the same confidence and speed it’s given me.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fea3b2d046cf" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[“We Lost the pem File” -The Client Call That Changed My Friday Night]]></title>
            <link>https://medium.com/@bhupeshpandey589/we-lost-the-pem-file-the-client-call-that-changed-my-friday-night-5295e04afffe?source=rss-42856b9efeaa------2</link>
            <guid isPermaLink="false">https://medium.com/p/5295e04afffe</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[google-compute-engine]]></category>
            <category><![CDATA[azure]]></category>
            <category><![CDATA[ec2]]></category>
            <category><![CDATA[ssh-keys]]></category>
            <dc:creator><![CDATA[Bhupeshpandey]]></dc:creator>
            <pubDate>Fri, 28 Nov 2025 21:27:58 GMT</pubDate>
            <atom:updated>2025-11-28T21:27:58.718Z</atom:updated>
            <content:encoded><![CDATA[<h3>“We Lost the pem File” — The Client Call That Changed My Friday Night</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OShZwVRjYrO6SRF0GD0VQA.png" /></figure><p>It was almost the end of my Friday when a new client called in. Their EC2 instance was down during peak traffic, and they urgently needed someone to fix it. They had full AWS console access, but the one thing they did not have was the PEM file. The developer who created the instance had left months earlier, and no one knew where the key was stored.</p><p>This is a situation many teams run into and usually panic about, but it is entirely recoverable. Here is the exact process I followed to regain access without recreating or damaging the instance.</p><h3>Quick Checks Before Going Into Deep Recovery</h3><p>Before touching volumes or creating rescue instances, you should always try these simple options:</p><p>• <strong>EC2 Instance Connect</strong><br> If already enabled, you can log in directly from the AWS console without any PEM file.</p><p>• <strong>AWS Systems Manager Session Manager</strong><br> If SSM agent and IAM role were set up earlier, you can open a full shell from the console instantly.</p><p>• <strong>Check team password managers or shared folders<br></strong>Often the key exists somewhere in a shared vault or old handover document.</p><p>• <strong>Check old AMIs or snapshots</strong><br>Instances cloned from these often contain the original authorized keys.</p><p>• <strong>Check if the instance uses a keyless login method</strong><br>Some teams configure keyless SSH using IAM or cloud-init scripts.<br>If so, EC2 Instance Connect may still work even without key files.</p><p>If none of these work, then it is time for the reliable and guaranteed method: recovering access through the root volume.</p><h3>Step One: Stop the Instance</h3><p>I stopped the affected EC2 instance from the AWS console. Stopping pauses compute but keeps the root disk intact.</p><blockquote><strong>Pro Tip</strong><br> Always stop the instance before you handle the root volume. It protects the filesystem and avoids corruption.</blockquote><h3>Step Two: Detach the Root Volume</h3><p>In the EBS section, I located the root volume (mounted as /dev/xvda) and detached it. Once detached, it became available to attach elsewhere.</p><blockquote><strong>Pro Tip</strong><br> Make note of the root device name. You must attach it back using the same identifier.</blockquote><h3>Step Three: Launch a Rescue Instance</h3><p>I created a temporary Amazon Linux instance in the same availability zone. This is important because EBS volumes cannot move across zones. I generated a new key pair during launch and saved it securely.</p><p>After the instance was running, I attached the client’s root volume to it. AWS assigned it as /dev/sdf.</p><h3>Step Four: Add Your Own SSH Key</h3><p>I logged into the rescue instance with the newly generated key and verified the attached disk using lsblk. Then I mounted it:</p><pre>sudo mkdir /mnt/recovery<br>sudo mount /dev/xvdf1 /mnt/recovery</pre><p>Inside the mounted filesystem, I opened the authorized_keys file:</p><pre>/mnt/recovery/home/ec2-user/.ssh/authorized_keys</pre><p>I added my public key to the file, ensuring the original key remained untouched.</p><p>After that, I unmounted the volume:</p><pre>sudo umount /mnt/recovery</pre><blockquote><strong>Pro Tip</strong><br> If the instance uses Ubuntu, Amazon Linux 2023, or a custom AMI, the username folder may differ. Always verify the correct home directory before editing authorized keys.</blockquote><h3>Step Five: Attach the Volume Back</h3><p>I detached the volume from the rescue instance and reattached it to the original instance using the original device name: /dev/xvda.</p><p>Attaching it incorrectly can cause boot issues, so this step needs extra care.</p><h3>Step Six: Start and Access the Instance</h3><p>Once the instance started, I connected with my new key:</p><pre>ssh -i new-key.pem ec2-user@public-ip</pre><p>Access restored.<br>From there, I checked logs, restarted services, and resolved the application issue.</p><h3>Strengthen Your Setup After Recovery</h3><p>Once everything was stable, I set up stronger, more reliable access methods for the client so they never end up in the same situation again:</p><p><strong>EC2 Instance Connect</strong><br>Allows SSH without depending on physical key files.</p><p><strong>AWS Systems Manager Session Manager</strong><br>Provides browser-based shell access without SSH, ports, or PEM files.</p><p><strong>Backup key pairs</strong><br>Stored in a password manager and accessible to multiple team members.</p><p><strong>Shared documentation</strong><br>Clear instructions on access paths and emergency recovery procedures.</p><p>These small improvements drastically reduce downtime risks and eliminate dependency on a single developer’s machine.</p><h3>Why This Process Matters</h3><p>Incidents like this highlight a simple truth in cloud operations: technical issues are not always the real problem. Often it is missing documentation, poor handover, or misplaced access credentials that cause the biggest outages.</p><p>Knowing how to recover EC2 access when the PEM file is lost is a skill that saves time, prevents data loss, and restores confidence quickly for clients and teams.</p><p>If you ever face this situation, follow these steps carefully. With a rescue instance and a few commands, you can regain full control of your EC2 instance without rebuilding it or losing any data.</p><p><strong><em>Been in a similar situation with a client? I’d love to hear your story. Connect with me or drop a comment below — we’re all learning from each other out here.</em></strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5295e04afffe" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Argo CD CI/CD Deployment With Bitbucket]]></title>
            <link>https://medium.com/@bhupeshpandey589/argo-cd-ci-cd-deployment-with-bitbucket-2688f114eaab?source=rss-42856b9efeaa------2</link>
            <guid isPermaLink="false">https://medium.com/p/2688f114eaab</guid>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[bitbucket-pipelines]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[argo-cd]]></category>
            <category><![CDATA[ci-cd-pipeline]]></category>
            <dc:creator><![CDATA[Bhupeshpandey]]></dc:creator>
            <pubDate>Mon, 24 Nov 2025 16:04:46 GMT</pubDate>
            <atom:updated>2025-11-24T17:01:45.050Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XSB_GowYPf8FcJMioZKC3g.png" /></figure><p>A beginner-friendly guide with a working Bitbucket pipeline.<br>Setting up a smooth CI/CD flow with ArgoCD doesn’t have to be complicated. In this walkthrough, I’ll show you the exact steps to build your Docker image, push it to Artifact Registry, and then trigger ArgoCD to deploy automatically by updating a version value inside your GitOps repo.</p><p>This is a simple, reliable, and production-friendly pattern that many teams use in GitOps environments.</p><h3>Step 1: Generate SSH Keys in Your Application Repository</h3><p>Your CI pipeline will need secure access to your GitOps repository.<br> In your application repo, create SSH keys:</p><pre>ssh-keygen -t rsa -b 4096 -f id_rsa</pre><p>This gives you:</p><ul><li><strong>id_rsa</strong> — private key</li><li><strong>id_rsa.pub</strong> — public key</li></ul><p>You’ll use the public key in the next step.</p><h3>Step 2: Add the Public Key to Your GitOps Repo</h3><p>Open your destination repository (example):</p><pre>git@bitbucket.org:dummy-org/dummy-infra.git</pre><p>Go to <strong>Repository Settings → Access Keys</strong> and paste the <strong>public key</strong>.</p><p>This allows your CI pipeline to push changes safely.</p><h3>Step 3: Configure SSH Access Locally</h3><p>Load the private key into your SSH agent:</p><pre>eval &quot;$(ssh-agent -s)&quot;<br>ssh-add id_rsa</pre><p>Verify the connection:</p><pre>ssh -T git@bitbucket.org</pre><p>If everything is correct, Bitbucket will confirm your access.</p><h3>Step 4: Add Rollout Logic to deployment.yaml</h3><p>ArgoCD deploys whenever the Git repository changes.<br> So we introduce a simple environment variable that CI will update:</p><pre>env:<br>  - name: LOGIC_FOR_ROLLOUT<br>    value: &quot;build_v1&quot;</pre><p>Every pipeline run will replace build_v1 with a new version such as build_v15, build_v89, etc.</p><blockquote><strong>Professional Tip:</strong><br> Keep your versioning pattern simple and predictable. This makes rollback and troubleshooting much easier.</blockquote><h3>Step 5: Add Bitbucket Pipelines for Building the Docker Image</h3><p>Inside your <strong>application repository</strong>, create a file:</p><pre>bitbucket-pipelines.yaml</pre><p>The first part of this pipeline builds your Docker image and pushes it to Google Artifact Registry. Artifact Registry automatically keeps unique SHAs for every push, so tagging with <strong>latest</strong> is safe.</p><h3>Step 6: Automate Deployment by Updating GitOps Repo</h3><p>This is where Continuous Delivery happens.</p><p>After the image is built, the pipeline will:</p><ol><li>Clone your GitOps repo</li><li>Update the version inside deployment.yaml</li><li>Commit and push the change</li></ol><p>ArgoCD detects the commit and deploys the new version immediately.</p><p>The version update command:</p><pre>sed -i &#39;s/build_v[0-9]*/build_v&#39;$BITBUCKET_BUILD_NUMBER&#39;/&#39; deployment.yaml</pre><h3>Full Example Pipeline (Easy to Reuse)</h3><pre>image: node:latest</pre><pre>pipelines:<br>  branches:<br>    main:<br>      - step:<br>          name: Build and Push Docker Image<br>          services:<br>            - docker<br>          script:<br>            - echo &quot;Building image for Dev&quot;<br>            - IMAGE_NAME=${IMAGE_NAME}<br>            - VERSION=&quot;${BITBUCKET_BUILD_NUMBER}&quot;<br>            - docker build -t ${IMAGE_NAME}:${VERSION} -t ${IMAGE_NAME} .<br>            - pipe: atlassian/google-gar-push-image:0.3.0<br>              variables:<br>                KEY_FILE: $KEY_FILE<br>                LOCATION: $LOCATION<br>                PROJECT: $PROJECT<br>                REPOSITORY: $REPOSITORY<br>                IMAGE_NAME: ${IMAGE_NAME}<br>                TAG: &#39;${VERSION} latest&#39;</pre><pre>      - step:<br>          name: Update GitOps Repo for ArgoCD Rollout<br>          script:<br>            - git config --global user.email &quot;${GIT_USER_EMAIL}&quot;<br>            - git config --global user.name &quot;${GIT_USER_NAME}&quot;<br>            - git config --global credential.helper store<br>            - echo &quot;https://${BITBUCKET_USERNAME}:${BITBUCKET_APP_PASSWORD}@bitbucket.org&quot; &gt; ~/.git-credentials</pre><pre>            - git clone <a href="https://bitbucket.org/dummy-org/dummy-infra.git">https://bitbucket.org/dummy-org/dummy-infra.git</a><br>            - cd dummy-infra/gke-deployments/env/dev/app-deployment</pre><pre>            - sed -i &#39;s/build_v[0-9]*/build_v&#39;$BITBUCKET_BUILD_NUMBER&#39;/&#39; deployment.yaml</pre><pre>            - git add deployment.yaml<br>            - git commit -m &quot;Auto-update deployment version $BITBUCKET_BUILD_NUMBER&quot;<br>            - git push origin main</pre><pre>            - rm ~/.git-credentials</pre><blockquote>Professional Tip</blockquote><blockquote>If multiple teams are pushing updates, use a separate branch in your GitOps repo and let ArgoCD watch a stable branch like main. This keeps your deployment clean and prevents conflicts.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2688f114eaab" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SSH Into a GCP VM From Your Local Machine]]></title>
            <link>https://medium.com/@bhupeshpandey589/ssh-into-a-gcp-vm-from-your-local-machine-620893538aab?source=rss-42856b9efeaa------2</link>
            <guid isPermaLink="false">https://medium.com/p/620893538aab</guid>
            <category><![CDATA[google-compute-engine]]></category>
            <category><![CDATA[gcp-compute-engine]]></category>
            <category><![CDATA[ssh]]></category>
            <category><![CDATA[google-vm]]></category>
            <category><![CDATA[google-cloud-platform]]></category>
            <dc:creator><![CDATA[Bhupeshpandey]]></dc:creator>
            <pubDate>Mon, 24 Nov 2025 15:32:54 GMT</pubDate>
            <atom:updated>2025-11-24T15:34:32.439Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*f1c6GarHdyXKs34c7muJPQ.png" /></figure><p>Connecting to a Google Cloud VM from your laptop is one of the first things you learn when working with Compute Engine. It is simple once you understand how SSH keys, metadata and permissions fit together.<br> This guide walks you through both common methods: using the Google Cloud CLI and using your own manually generated SSH keys.</p><h3>Install the gcloud CLI</h3><p>The Google Cloud CLI is the most convenient way to manage SSH access because it handles key creation and metadata updates automatically.</p><p>macOS or Linux</p><pre>curl https://sdk.cloud.google.com | bash<br>exec -l $SHELL<br>gcloud init</pre><p>Windows<br> Install the Google Cloud SDK and run gcloud init.</p><h3>Authenticate and Set Your Project</h3><p>Login and point the CLI to the project containing your VM.</p><pre>gcloud auth login<br>gcloud config set project &lt;PROJECT_ID&gt;</pre><h3>Connect to Your VM Using gcloud</h3><p>The easiest approach:</p><pre>gcloud compute ssh &lt;VM_NAME&gt; --zone &lt;ZONE&gt;</pre><p>If this is your first time connecting, gcloud generates SSH keys and stores them under ~/.ssh/ and automatically places your public key into the VM’s metadata.<br>This is why the gcloud method is almost always preferred. Everything happens behind the scenes.</p><blockquote>Pro Tip</blockquote><blockquote>If you have a default zone set, you can simply run:</blockquote><pre>gcloud compute ssh myvm</pre><h3>Connect to a VM Without a Public IP</h3><p>If your VM is private, you can still access it using IAP.</p><pre>gcloud compute ssh &lt;VM_NAME&gt; --tunnel-through-iap</pre><p>No public IP required. No additional firewall rule needed.</p><h3>Using Your Own SSH Key Pair</h3><p>Some people prefer generating and managing their own SSH keys instead of letting gcloud do it. Here is how you can do that.</p><h3>Generate an SSH Key Pair</h3><p>Run this on your local machine:</p><pre>ssh-keygen -t rsa -b 4096 -C &quot;&lt;your_email&gt;&quot;</pre><p>This creates:</p><ul><li>A private key: ~/.ssh/id_rsa</li><li>A public key: ~/.ssh/id_rsa.pub</li></ul><p>You will use the public key for GCP.</p><h3>Add Your Public Key to the VM Metadata</h3><p>Go to<br> Compute Engine → Metadata → SSH Keys → Add SSH Key</p><p>Paste the public key in the format:</p><pre>username:ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQ...</pre><p>You can also add the key only to a specific VM by editing that VM and scrolling to the SSH Keys section.</p><h3>SSH Manually Into the VM</h3><p>Once the key is added, connect using:</p><pre>ssh -i ~/.ssh/id_rsa &lt;username&gt;@&lt;EXTERNAL_IP&gt;</pre><p>This is the traditional SSH workflow, and it works exactly the same way on GCP.</p><h3>Quick Troubleshooting Checks</h3><h3>Firewall</h3><p>Ensure port 22 is allowed for either the instance or the network tags it uses.</p><h3>IAM roles</h3><p>Your account needs either</p><ul><li>compute.osLogin</li><li>compute.osAdminLogin</li></ul><h3>Key issues</h3><p>If using gcloud and your keys feel out of sync:</p><pre>gcloud compute ssh &lt;VM_NAME&gt; --force-key-file-overwrite</pre><h3>Transfer Files Easily</h3><p>Upload a file</p><pre>gcloud compute scp local.txt &lt;VM_NAME&gt;:~</pre><p>Download a file</p><pre>gcloud compute scp &lt;VM_NAME&gt;:~/output.log .</pre><h3>Conclusion</h3><p>Once you understand how keys and metadata work in Google Cloud, SSH access becomes straightforward and consistent.<br>You now have both approaches: the quick gcloud workflow and the manual SSH key method. Pick whichever fits your style or team requirements.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=620893538aab" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Managing and Renewing SSL Certificates Kubernetes using cert manager]]></title>
            <link>https://medium.com/@bhupeshpandey589/managing-and-renewing-ssl-certificates-kubernetes-using-cert-manager-8ac54622f26e?source=rss-42856b9efeaa------2</link>
            <guid isPermaLink="false">https://medium.com/p/8ac54622f26e</guid>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[cert-manager]]></category>
            <category><![CDATA[ssl-certificate]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[devops]]></category>
            <dc:creator><![CDATA[Bhupeshpandey]]></dc:creator>
            <pubDate>Thu, 20 Nov 2025 05:34:22 GMT</pubDate>
            <atom:updated>2025-11-28T22:33:41.950Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*78Wfnw7qMfOrfxK_09TaKw.png" /></figure><p>Keeping SSL certificates updated is one of those tasks that sounds simple until you have many services running in Kubernetes. Missing even one renewal can lead to downtime and security warnings. Cert manager solves this problem by taking over the entire process of issuing and renewing certificates.</p><p>This article explains how cert manager works across EKS, AKS and GKE, how to install it, how to request certificates, how renewal happens, and how to troubleshoot when things break.<br>What cert manager Does in Simple Terms</p><p>cert manager sits inside your cluster and handles everything related to SSL certificates. It takes care of:</p><p><em>requesting certificates</em></p><p><em>storing them as Kubernetes secrets</em></p><p><em>watching expiry dates</em></p><p><em>renewing them before they expire</em></p><p><em>updating secrets, so your apps never see a broken certificate</em></p><p>The process works almost the same on EKS, AKS and GKE, which makes it dependable across cloud providers.</p><h3>Why You Should Use cert manager</h3><p>Without cert manager, you would need to:</p><ul><li>request a certificate manually</li><li>store it somewhere safe</li><li>upload it to Kubernetes</li><li>replace it before expiry</li><li>redeploy your services using the updated certificate</li></ul><p>Doing this again and again is not fun. cert manager removes this burden. Once it is set up, it works automatically.</p><h3>Installing cert manager</h3><p>We will use Helm since it is the most common method.</p><h3>Step 1: Add the repo</h3><pre>helm repo add jetstack https://charts.jetstack.io<br>helm repo update</pre><h3>Step 2: Install cert manager with CRDs</h3><pre>helm install cert-manager jetstack/cert-manager \<br>  --namespace cert-manager \<br>  --create-namespace \<br>  --set installCRDs=true</pre><h3>Step 3: Verify installation</h3><pre>kubectl get pods -n cert-manager</pre><p>You should see three pods:</p><ul><li>cert-manager</li><li>cert-manager-webhook</li><li>cert-manager-cainjector</li></ul><blockquote>Pro Tip:</blockquote><blockquote>If any of these pods are CrashLooping, check the logs using:</blockquote><blockquote>“kubectl logs -n cert-manager &lt;pod-name&gt;”</blockquote><blockquote>It quickly reveals missing permissions or webhook issues.</blockquote><h3>Creating an Issuer or ClusterIssuer</h3><p>To request certificates, cert manager needs to know where to get them from. You can use Let’s Encrypt for public certificates.</p><p>Example: ClusterIssuer for Let’s Encrypt</p><pre>apiVersion: cert-manager.io/v1<br>kind: ClusterIssuer<br>metadata:<br>  name: letsencrypt-prod<br>spec:<br>  acme:<br>    server: https://acme-v02.api.letsencrypt.org/directory<br>    email: your-email@example.com<br>    privateKeySecretRef:<br>      name: letsencrypt-prod-key<br>    solvers:<br>      - http01:<br>          ingress:<br>            class: nginx</pre><p>This works for EKS, AKS and GKE.</p><blockquote>Pro Tip:</blockquote><blockquote>If you use a cloud load balancer ingress (AWS ALB, Azure Application Gateway, Google Load Balancer), make sure the <strong>ingress class</strong> matches exactly. A typo here is one of the most common reasons certificates fail.</blockquote><h3>Creating a Certificate</h3><p>Once the ClusterIssuer is ready, create a Certificate object.</p><pre>apiVersion: cert-manager.io/v1<br>kind: Certificate<br>metadata:<br>  name: my-app-cert<br>  namespace: default<br>spec:<br>  secretName: my-app-tls<br>  issuerRef:<br>    name: letsencrypt-prod<br>    kind: ClusterIssuer<br>  dnsNames:<br>    - myapp.example.com</pre><p>cert manager will:</p><ol><li>request the certificate</li><li>validate the challenge</li><li>create a secret named my-app-tls</li><li>store the certificate and key inside that secret</li></ol><h3>Checking the Status of Certificates</h3><p>This is useful when something is wrong.</p><p><strong>Check if cert manager issued your certificate</strong></p><pre>kubectl describe certificate my-app-cert -n default</pre><p><strong>Check all certificates</strong></p><pre>kubectl get certificate --all-namespaces</pre><p><strong>Check secrets containing the certificate and key</strong></p><pre>kubectl get secrets -n default<br>kubectl describe secret my-app-tls -n default</pre><p><strong>Check Certificate Request objects when something fails</strong></p><pre>kubectl get certificaterequests -A<br>kubectl describe certificaterequest &lt;name&gt;</pre><blockquote>Pro Tip:</blockquote><blockquote>If the reason shows Pending, check DNS.<br> If it shows Failed, check the events section.</blockquote><h3>Using the Certificate in the Ingress</h3><p>Your ingress must reference the secret generated by cert manager.</p><pre>apiVersion: networking.k8s.io/v1<br>kind: Ingress<br>metadata:<br>  name: my-app-ingress<br>spec:<br>  tls:<br>    - hosts:<br>        - myapp.example.com<br>      secretName: my-app-tls<br>  rules:<br>    - host: myapp.example.com<br>      http:<br>        paths:<br>          - path: /<br>            pathType: Prefix<br>            backend:<br>              service:<br>                name: my-app<br>                port:<br>                  number: 80</pre><p>Once deployed, your app will be reachable through HTTPS.</p><h3>How Renewal Works</h3><p>cert manager constantly watches your certificates. When the expiry date comes close (usually 30 days before):</p><ul><li>it requests a new certificate</li><li>updates the secret</li><li>your workload starts using the new one automatically</li></ul><p>You don’t need to restart pods. Kubernetes automatically reloads secrets for ingress controllers.</p><blockquote>Pro Tip:</blockquote><blockquote>To see when the certificate will expire:</blockquote><pre>kubectl get certificate my-app-cert -n default -o yaml | grep &quot;notAfter&quot;</pre><blockquote>To see when the certificate will expire:</blockquote><pre>kubectl get certificate my-app-cert -n default -o yaml | grep &quot;notAfter&quot;</pre><h3>Troubleshooting Guide</h3><p>If your certificate is not being issued, here are some commands and checks.</p><p>1. Check cert manager pod health</p><pre>kubectl get pods -n cert-manager</pre><p>2. Check logs for detailed errors</p><pre>kubectl logs -n cert-manager deploy/cert-manager<br>kubectl logs -n cert-manager deploy/cert-manager-webhook<br>kubectl logs -n cert-manager deploy/cert-manager-cainjector</pre><p>3. Check events in the Certificate</p><pre>kubectl describe certificate my-app-cert -n default</pre><p>4. Check CertificateRequest</p><pre>kubectl get certificaterequests -A<br>kubectl describe certificaterequest &lt;name&gt;</pre><p>5. Verify domain DNS</p><p>Check if your domain points to the right ingress load balancer:</p><pre>kubectl get ingress -n default</pre><p>Then verify DNS using:</p><pre>nslookup myapp.example.com</pre><p>or</p><pre>dig myapp.example.com</pre><p>If DNS is wrong, Let’s Encrypt challenge will fail.</p><p>6. Check if the challenge is created</p><pre>kubectl get challenges.acme.cert-manager.io -A<br>kubectl describe challenge -n default &lt;challenge-name&gt;</pre><p>If this object is stuck, the HTTP challenge might be blocked.</p><blockquote>Pro Tip:</blockquote><blockquote>If you use a path-based ingress, make sure the challenge path /.well-known/acme-challenge/ is not overridden by other rules.</blockquote><h3>Final Thoughts</h3><p>cert manager makes certificate handling simple across EKS, AKS and GKE. Once installed, it quietly manages all your SSL certificates in the background. It saves time, prevents expired certificate outages, and keeps your apps secure without manual work.</p><p>If you run any production workloads on Kubernetes, having cert manager is almost essential.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8ac54622f26e" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>