<?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 Alfonso on Medium]]></title>
        <description><![CDATA[Stories by Alfonso on Medium]]></description>
        <link>https://medium.com/@alfonso.grana?source=rss-59049c2b51b7------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*9zuQtrCMdlyYtI1yXs77zw.jpeg</url>
            <title>Stories by Alfonso on Medium</title>
            <link>https://medium.com/@alfonso.grana?source=rss-59049c2b51b7------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 01:34:12 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@alfonso.grana/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[What the heck are git work trees]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@alfonso.grana/what-the-heck-are-git-work-trees-7f7fa3c61083?source=rss-59049c2b51b7------2"><img src="https://cdn-images-1.medium.com/max/2264/1*cCSKw1QfZnKkuraI46b2gQ.png" width="2264"></a></p><p class="medium-feed-snippet">I was today&apos;s years old when I find out that you can create a copy of your repository and a branch totally independent from you work&#x2026;</p><p class="medium-feed-link"><a href="https://medium.com/@alfonso.grana/what-the-heck-are-git-work-trees-7f7fa3c61083?source=rss-59049c2b51b7------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@alfonso.grana/what-the-heck-are-git-work-trees-7f7fa3c61083?source=rss-59049c2b51b7------2</link>
            <guid isPermaLink="false">https://medium.com/p/7f7fa3c61083</guid>
            <category><![CDATA[bash]]></category>
            <category><![CDATA[git]]></category>
            <category><![CDATA[software-engineering]]></category>
            <dc:creator><![CDATA[Alfonso]]></dc:creator>
            <pubDate>Sat, 31 Jan 2026 10:46:06 GMT</pubDate>
            <atom:updated>2026-01-31T17:53:35.739Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[What Using 1B+ Tokens in Cursor Taught Me]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@alfonso.grana/what-using-1b-tokens-in-cursor-taught-me-bbe48d8ae24b?source=rss-59049c2b51b7------2"><img src="https://cdn-images-1.medium.com/max/1080/1*ZGcJo8-Yyzire_eydC007A.png" width="1080"></a></p><p class="medium-feed-link"><a href="https://medium.com/@alfonso.grana/what-using-1b-tokens-in-cursor-taught-me-bbe48d8ae24b?source=rss-59049c2b51b7------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@alfonso.grana/what-using-1b-tokens-in-cursor-taught-me-bbe48d8ae24b?source=rss-59049c2b51b7------2</link>
            <guid isPermaLink="false">https://medium.com/p/bbe48d8ae24b</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[vibe-coding]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[ai-agent]]></category>
            <dc:creator><![CDATA[Alfonso]]></dc:creator>
            <pubDate>Fri, 09 Jan 2026 22:50:41 GMT</pubDate>
            <atom:updated>2026-01-10T09:57:40.750Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Clipboard to obsidian in mac]]></title>
            <link>https://medium.com/@alfonso.grana/clipboard-to-obsidian-in-mac-a8511e654483?source=rss-59049c2b51b7------2</link>
            <guid isPermaLink="false">https://medium.com/p/a8511e654483</guid>
            <category><![CDATA[obsidian]]></category>
            <category><![CDATA[shortcuts]]></category>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[mac]]></category>
            <dc:creator><![CDATA[Alfonso]]></dc:creator>
            <pubDate>Sat, 30 Dec 2023 18:04:07 GMT</pubDate>
            <atom:updated>2023-12-30T18:04:07.149Z</atom:updated>
            <content:encoded><![CDATA[<p>I wanted a way to create a scratch pad daily note where to collect all the things that I wanted to persist from my clipboards.</p><p>I found a way to do that by using a <a href="https://support.apple.com/en-gb/guide/shortcuts-mac/apdf22b0444c/mac">mac shortcut</a>, a rather obscure feature from which I didn’t hear a lot about before, seemed good enough for this job.</p><p>This is a screenshot of the end product.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*w2sY5Yln07FOdw_-Nzdz3g.png" /></figure><p>This gives a one key combination or click to save whatever is on your clipboard to an obsidian note without leaving what you are doing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/628/1*Mpu0sXdfOPAjAE93EV97pQ.png" /></figure><h4>Prerequisites:</h4><p>To use this same shortcut, you need to have installed the <a href="https://github.com/Yakitrak/obsidian-cli">obsidian CLI</a></p><p>You could also use just shell redirection to a text file. I already had obs installed, so I just used that.</p><pre><br>brew install obs</pre><p>Set the default vault.</p><pre>obs set-default &lt;your vault name&gt;</pre><h4>Shortcut</h4><p>It’s a shortcut of type Run Shell Script that does:</p><ul><li>Saves the date in a variable, configure the date in ISO8601 YYYY-MM-DD so it is easy to use a file name.</li><li>Calls the `obs create` [obsidian cli)](<a href="https://github.com/Yakitrak/obsidian-cli">https://github.com/Yakitrak/obsidian-cli</a>)</li><li>Name of the note date-scrap</li><li>Will append to the note</li><li>And will pass the content from the clipboard to the note with \n at the end.</li><li>And finally shows an alert with the data that inserted in the note. Makes it clear what you are saving.</li></ul><p>You can just get the shortcut from the shortcut gallery in this <a href="https://www.icloud.com/shortcuts/7a2bc3e8697d438485087a7c7ad93483">URL</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a8511e654483" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Execute commands in ECS Fargate tasks containers]]></title>
            <link>https://medium.com/@alfonso.grana/execute-commands-in-ecs-fargate-tasks-containers-7ba372a46a67?source=rss-59049c2b51b7------2</link>
            <guid isPermaLink="false">https://medium.com/p/7ba372a46a67</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[containers]]></category>
            <dc:creator><![CDATA[Alfonso]]></dc:creator>
            <pubDate>Sat, 03 Sep 2022 15:33:56 GMT</pubDate>
            <atom:updated>2022-09-03T15:33:56.138Z</atom:updated>
            <content:encoded><![CDATA[<h4>Debugging live Fargate containers.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*jJ6vCQDBDjD91yg3X1SRkg.png" /><figcaption>AI Generated Image of a turbulent sea in Renoir style</figcaption></figure><h4>Motivation:</h4><p>Having access to a live container interactive console to see how things are running from the inside during development could accelerate the understanding on how an app is behaving.</p><p>Questions like:</p><ul><li>Is that file created and can be inspected?</li><li>Can I open connections to endpoint X?</li></ul><p>Can be answered fast if you just get an interactive shell to the container and execute things as your application would.</p><h4>Procedure:</h4><p>I’m describing the procedure that I used to adapt existing terraform code to enable command executions using aws cli.<br>Similar procedure can be followed with cloud formation or the AWS console.</p><h4>Create a policy in IAM to allow your ECS executor open a channel with SSM.</h4><ul><li>Enable to open command channel with SSM and logging depending on how are you logging in your app if you need cloudwatch or s3 or both.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fe66bf74176d2b4dbeeeb197b247e9bc/href">https://medium.com/media/fe66bf74176d2b4dbeeeb197b247e9bc/href</a></iframe><p>Attach the policy to the role running your tasks.</p><h4>Enable execute command in your task.</h4><p>This is terraform code to create a service in a Fargate cluster with enable_execute_command as true.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1f0832e9cfd9dd8dac2906c25b15806f/href">https://medium.com/media/1f0832e9cfd9dd8dac2906c25b15806f/href</a></iframe><h4>Respawn your task</h4><h4>Review config with <a href="https://github.com/aws-containers/amazon-ecs-exec-checker">ecs-exec-checker</a></h4><p>This tool is a time saver will tell you if you are missing something in your configuration.</p><p>Review if you have all you environment configured correctly with tool to check ECS run task.</p><pre>git clone <a href="https://github.com/aws-containers/amazon-ecs-exec-checker.git">https://github.com/aws-containers/amazon-ecs-exec-checker.git</a>;<br>cd amazon-ecs-exec-checker;<br>./check-ecs-exec.sh $CLUSTER_NAME $TASK_ID</pre><h4>Configure your CLI</h4><p>In mac you can use this command to enable the session manager plugin in your cli.</p><pre>curl “<a href="https://s3.amazonaws.com/session-manager-downloads/plugin/latest/mac/session-manager-plugin.pkg">https://s3.amazonaws.com/session-manager-downloads/plugin/latest/mac/session-manager-plugin.pkg</a>&quot; -o “session-manager-plugin.pkg”</pre><h4>Execute command in your container interactively.</h4><pre>aws ecs execute-command --region eu-west-1 --cluster $CLUSTER_NAME ---task $TASK_ID --container $CONTAINER_NAME --command “/bin/sh” --interactive</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7ba372a46a67" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Automating Bitbucket pipelines self-hosted runners in AWS]]></title>
            <link>https://medium.com/@alfonso.grana/automating-bitbucket-pipelines-self-hosted-runners-in-aws-12005513f85b?source=rss-59049c2b51b7------2</link>
            <guid isPermaLink="false">https://medium.com/p/12005513f85b</guid>
            <category><![CDATA[aws-spot]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[bitbucket-pipelines]]></category>
            <category><![CDATA[bitbucket]]></category>
            <dc:creator><![CDATA[Alfonso]]></dc:creator>
            <pubDate>Thu, 25 Aug 2022 11:19:02 GMT</pubDate>
            <atom:updated>2025-04-16T20:38:26.018Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="Photo by Pixabay" src="https://cdn-images-1.medium.com/max/1024/1*Mr5yyYUmVY1UYzaGvDof6g.jpeg" /><figcaption>Photo by Pixabay</figcaption></figure><p>Bitbucket pipelines allow you to run your tasks directly in containers so you can leverage containers from trusted sources like open source official container images directly.</p><p>It is very easy and fast to configure.</p><p>Perhaps is not as flexible as its competitors GitLab, Azure DevOps, Github Actions etc.</p><p>But if you are already using Atlassian tools, it will put the pipelines very close to the developers. With out-of-the-box integration with Jira software.</p><p>It has integration with VS Code, so you see after pushing code the status of the pipeline without leaving the IDE.</p><p>To make the solution complete, sooner or later you will need to run pipelines in your own infrastructure with self-hosted runners. Since August 2021 you can do that in Bitbucket cloud pipelines with self-hosted runners.</p><p>I am focusing here in docker runners, but new types of runners are being added constantly, Windows runners and Mac are also available. There is an open beta of a Linux shell for high load jobs which improves performance over the default docker runner.</p><p>This is the architectural diagram on how to use cheap self-hosted runners in AWS for your CI/CD jobs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W4UItFALBcdj_I__ibt14A.png" /></figure><h4>Creating the runners in Bitbucket</h4><p>For these tests I created runners at workspace level, these runners will be available to pipelines in all the repositories of the workspace.</p><p>Runners can also be configured at repository level.</p><p>In workspace settings, there is a workspace runners section, simply add runners there.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*corBc081g5zK13CbnCighA.png" /></figure><p>For docker runners, it will display a docker runcommand that is used to start a runner.</p><p>The original command requires a bit of tweaking to run it as a daemon, it is intended to be run interactively.</p><p>So I simply add nohupat the start and &amp;at the end, so the process remains on background and remove -it from the docker command we don’t need an interactive terminal here. This same command can be converted to a systemd service easily, I’m not doing that because my runners will be disposable.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6079d6703e181e62b20919b9ed757668/href">https://medium.com/media/6079d6703e181e62b20919b9ed757668/href</a></iframe><p>This command contains secrets, so we require a secure place to store it.</p><p>So we save these commands in SSM parameter store as a secure string, one per runner in this case.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Qcpyw8extmy-RibfN-E8hQ.png" /></figure><blockquote>This is the only manual part in this process, there is no api for creating bitbucket runners at this time.</blockquote><blockquote>This issue request could use some up votes :-)</blockquote><blockquote><a href="https://jira.atlassian.com/browse/BCLOUD-21309">[BCLOUD-21309] Have public API endpoints for pipelines runners — Create and track feature requests for Atlassian products.</a></blockquote><h4>AWS <a href="http://ssm_access_for_instances/">Spot fleet</a></h4><p>Spot fleet provides you with a way to run groups of spot instances with some rules and maintain that capacity from multiple instance pools and AZs.</p><p>Optionally, you can run on-demand spot mixed capacity for stateless critical apps.</p><p>In this case, I am using only spot with diversifiedas the fleet allocation strategy, I want to minimize the interruptions. So If I distribute my load between instance families and availability zones, the probabilities of the whole fleet being interrupted should go down.</p><p>The spot fleet will make sure of maintaining fleet_type=&quot;mantain”the capacity from availability zones and instances families available.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d47d3e291540765d574af97a04bd13f9/href">https://medium.com/media/d47d3e291540765d574af97a04bd13f9/href</a></iframe><h4>AWS Parameter Store</h4><p><a href="#8149">As I showed before</a>, the configuration of the Bitbucket runners is stored in SSM parameter store as a secure string encrypted with a customer key.</p><p>This secures the communication of the keys to register as a runner in Bitbucket pipelines.</p><h4>Terraform template files for user data.</h4><p>With a bit of Ansible help, to prepare the instances to run docker in a vanilla Redhat machine using <a href="https://galaxy.ansible.com/geerlingguy/docker">this</a> awesome Ansible role.</p><p>I’m calling the role directly with some extra-vars and -m include_role.</p><p>The complete userdata.sh template looks like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fef68e5648f16b5ca1efc0b3e3b93f48/href">https://medium.com/media/fef68e5648f16b5ca1efc0b3e3b93f48/href</a></iframe><h4>The Bitbucket pipeline</h4><p>With public Bitbucket runners, we can create the self-hosted runners executing terraform.</p><p>Here is a very simple custom pipeline where you can pass an action variable to execute the terraform command plan, apply, destroy.</p><blockquote>It assumes you can access your AWS account from Bitbucket pipelines, you should have at least your AWS keys as repository variables.</blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b13676e882a34e962acd01c00b9c5ff7/href">https://medium.com/media/b13676e882a34e962acd01c00b9c5ff7/href</a></iframe><p>You can execute by run pipeline, select custom and pass the action to execute.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LPwXHL4HAt8dv6wiv39iuQ.png" /></figure><p>After running the pipeline you should see your runners registered and start using them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/910/1*9llcPBCCgh_hZym2paz4vQ.png" /></figure><p>Then adding runs-on your tasks and a label that you added in the runners the tasks will run in your infrastructure.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/52646649b106ada96ae20542b0de329a/href">https://medium.com/media/52646649b106ada96ae20542b0de329a/href</a></iframe><p><a href="https://github.com/agrana/bb-runners-spot-fleet">Finally this is the GitHub repo with the complete solution.</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=12005513f85b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Working with Ansible EC2 dynamic inventory in production]]></title>
            <link>https://medium.com/@alfonso.grana/working-with-ansible-ec2-dynamic-inventory-in-production-73984d60a288?source=rss-59049c2b51b7------2</link>
            <guid isPermaLink="false">https://medium.com/p/73984d60a288</guid>
            <category><![CDATA[ec2]]></category>
            <category><![CDATA[ansible-inventory]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[ansible-dynamic-inventory]]></category>
            <category><![CDATA[ansible]]></category>
            <dc:creator><![CDATA[Alfonso]]></dc:creator>
            <pubDate>Mon, 11 Jul 2022 11:43:31 GMT</pubDate>
            <atom:updated>2022-09-06T13:59:12.726Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*sUJdwn6Be_tftcnhUYZZpQ.png" /><figcaption>AI Generated Image “Warehouse in the clouds”</figcaption></figure><h4>Motivation</h4><p>If you manage EC2 instances with Ansible, you will get great benefits by querying AWS for your instances with AWS dynamic inventory.</p><p>It will make your inventory shorter and keep up with the dynamisms of the cloud without having to run intermediate glue scripts.</p><p>It will load the metadata of your instances like tags, so it can be used in your play books.</p><h4>Authentication</h4><p>Using keys way</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f2acc467b64165155d7cdeb95d92a115/href">https://medium.com/media/f2acc467b64165155d7cdeb95d92a115/href</a></iframe><p>Using a profile</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a81bcbfb943228b9b2073066178c1dd9/href">https://medium.com/media/a81bcbfb943228b9b2073066178c1dd9/href</a></iframe><p>The STS way</p><p>After authenticating you can switch to a different role, this way you can manage multiple AWS accounts with the same inventory file.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e3ee0ca3c4582d7b244f4b69434fcf4f/href">https://medium.com/media/e3ee0ca3c4582d7b244f4b69434fcf4f/href</a></iframe><h4>Regions</h4><p>When I started using the AWS dynamic inventory, I found it extremely slow, like 20 seconds to start showing progress slow.</p><p>Until I found out that by default I went over all the available AWS Regions and that made it slow.</p><p>If you don’t need to go over all the AWS regions, which I hope is the case.</p><p>You should filter regions, populating the list of regions in your configuration.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c51dbe96472f9d996f36d5825d957f2c/href">https://medium.com/media/c51dbe96472f9d996f36d5825d957f2c/href</a></iframe><h4>Group Mappings</h4><p>The most useful functionality of the dynamic inventory is its ability to build your Ansible groups from the metadata of your cloud instances, like tags.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/985c5e5c7d000a30128e73e1549801a7/href">https://medium.com/media/985c5e5c7d000a30128e73e1549801a7/href</a></iframe><p>In this example, Ansible will create groups for all the environments.</p><p>And for each of the roles that the instance has in the tag role separated by comas.</p><h4>Filters</h4><p>This is a very important point if you have multiple environments in a single AWS account.</p><p>And if you want to avoid getting stopped or terminated instances in your results.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7d0ae1e62dc714308ba53a4495c09c5f/href">https://medium.com/media/7d0ae1e62dc714308ba53a4495c09c5f/href</a></iframe><h4>Testing the Inventory</h4><p>Before starting executing playbooks it is always good to review your inventory and how your groups are being formed in Ansible.</p><pre>ansible-inventory -i aws_ec2.yml --graph</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=73984d60a288" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>