domingo, 7 de junio de 2026

Grandstream setup

If you want to get a proper file for the voice prompt, to reduce the codec

ffmpeg -i welcome.wav -ar 8000 -ac 1 -acodec pcm_s16le fixed.wav

Then to cut the file it is good this one
ffmpeg -i fixed.wav -t 48 -c copy inbound-welcome.wav

 

 First edit analog trunks

 

 Configure Outbound Routes

In the Main Trunk of the outbound rule set the fxo-1 

 

Create a custom voice prompt in PBX Settings - Voice Prompt - Custom Prompt



Creates an IVR in Call Features

 


 Setup a inbound route

 

 

The config like this

 

 

 

martes, 12 de mayo de 2026

Open web browser from wsl

Add these lines to .bashrc

# Open URLs in the Windows default browser from WSL
export BROWSER=wslview


Run this once (needs your password):
sudo apt-get update && sudo apt-get install -y wslu


Then reload your shell:
source ~/.bashrc


Verify:
wslview https://example.com 
# should open in Windows Firefox 

echo $BROWSER 
# should print: wslview

How this fixes your AWS SSO flow
wslu provides wslview, which hands URLs to Windows' default browser via cmd.exe.

Setting BROWSER=wslview is what the AWS CLI (and most tools) check first when they want to open a URL.

xdg-open on Ubuntu/WSL also delegates to $BROWSER for http(s):// URLs, so your earlier xdg-open error will be gone too.

jueves, 16 de abril de 2026

yamlfmt on wsl

Steps to install yamlfmt and go in wsl

sudo apt update && sudo apt install -y golang
go install github.com/google/yamlfmt/cmd/yamlfmt@latest
echo 'export PATH="$PATH:$HOME/go/bin"' >> ~/.bashrc
source ~/.bashrc

martes, 7 de abril de 2026

Mosquitto post install

 

Mosquitto comes with a password file generating utility called mosquitto_passwd.

mosquitto_passwd -c /etc/mosquitto/passwd <user>

Ensure that the file is managed by the appropriate user and group.

chown mosquitto:mosquitto /etc/mosquitto/passwd

Now restart Mosquitto server.

systemctl restart mosquitto

The command below will show what ports are listening (look for *:1883 (LISTEN))

lsof -i -P -n | grep LISTEN

jueves, 26 de marzo de 2026

Out of space lvm on lxc container proxmox

 

# List LVM volumes for the container
lvs | grep vm-101

# Check the actual size and usage
lvdisplay /dev/pve/vm-101-disk-0

# Try to mount the container's rootfs temporarily to check space
mkdir -p /tmp/ct101-check
mount /dev/pve/vm-101-disk-0 /tmp/ct101-check
df -h /tmp/ct101-check
du -sh /tmp/ct101-check/* | sort -hr | head -20


# First, unmount the temporary mount
umount /tmp/ct101-check

# Resize the rootfs to 20GB (or 30GB if you plan to run many containers)
pct resize 101 rootfs 20G

# Now start the container
pct start 101


viernes, 20 de febrero de 2026

Quick use of spectral to check openapi templates

# Now install spectral

npm init -y
npm install -g @stoplight/spectral-cli

npm install --save-dev @stoplight/spectral-cli spectral-aws-apigateway-ruleset


spectral

# Create ruleset
echo 'extends: ["spectral:oas"]' > .spectral.yaml

Or create a file with the following content

extends:
  - spectral:oas
  - spectral-aws-apigateway-ruleset


# Check openapi template
spectral lint openapi-api.yaml

Install node and go in wsl ubuntu

# Install go and set path
sudo apt update
sudo apt install golang-go
export PATH="$HOME/go/bin:$PATH"
source ~/.bashrc

# Install nodejs and npm
sudo apt install nodejs npm # Create a directory for global npm packages
mkdir -p ~/.npm-global

# Configure npm to use this directory
npm config set prefix '~/.npm-global'

# Add to your PATH (add this to ~/.bashrc to make it permanent)
export PATH="$HOME/.npm-global/bin:$PATH"

# Reload your shell
source ~/.bashrc

# Now install spectral
npm install -g @stoplight/spectral-cli

jueves, 5 de febrero de 2026

VSCode Claude Code extension doesn't login

 I was experiencing issues with the claude code extension in my new windows machine. And I had this as well with linux.

For windows I should install the claude code terminal and then login with the anthropic console.

irm https://claude.ai/install.ps1 | iex

Then edit the path on environemnt variables and add this path.

C:\Users\alega\.local\bin 

After that the vscode extension started to work.

viernes, 16 de enero de 2026

Install oasdiff

Great tool to check openapi templates


go install github.com/oasdiff/oasdiff@latest

echo 'export PATH=$PATH:$HOME/go/bin' >> ~/.bashrc

source ~/.bashrc

oasdiff

lunes, 12 de enero de 2026

Configure the Terraform AWS provider to use a different AWS profile

To to configure the Terraform VSCode Extension to use a different AWS profile

Option 1: VS Code Settings (Recommended)

Open VS Code Settings (JSON) and add:

  1. Press Ctrl+Shift+P (or Cmd+Shift+P on Mac)
  2. Type "Preferences: Open User Settings (JSON)"
  3. Add this configuration:


{
"terraform.languageServer.terraform.path": "terraform",
"terraform.languageServer.enable": true,
"terminal.integrated.env.linux": {
"AWS_PROFILE": "profile-name"
}
}


jueves, 4 de diciembre de 2025

Terraform list block

 A way to query for bunch of resources.

Create a file name.tfquery.hcl :

list "aws_instance" "aws_instances" {
provider = aws
limit = 50
config {
region = "us-east-1"
}
}


 

Then run:

terraform query
Warning: list block(s) [list.aws_instance.APIGateways] returned 0 results.

The supported resource types:

terraform providers schema -json 2>/dev/null | jq -r '.provider_schemas."registry.terraform.io/hashicorp/aws".list_resource_schemas | keys[]' | sort
aws_batch_job_queue
aws_cloudwatch_log_group
aws_iam_policy
aws_iam_role
aws_iam_role_policy_attachment
aws_instance
aws_subnet
aws_vpc 

lunes, 24 de noviembre de 2025

Delete a branch both locally and remotely



Here's how to delete a branch both locally and remotely:

Step-by-Step Deletion

Step 1: Switch to a Different Branch First

You can't delete a branch you're currently on:

# Switch to dev or main
git switch dev

Step 2: Delete Local Branch

# Delete local branch (safe delete - prevents deletion if unmerged)
git branch -d feat/-deployment

# OR force delete (if you get warnings about unmerged changes)
git branch -D feat/-deployment

Step 3: Delete Remote Branch

# Delete remote branch
git push origin --delete feat/-deployment

viernes, 14 de noviembre de 2025

AWS CLI SSO

 

To log in to AWS CLI using SSO (IAM Identity Center), follow these steps:
  • Configure your AWS CLI profile for SSO:
This step sets up the necessary configuration in your AWS CLI profile to use IAM Identity Center for authentication. You will need your SSO Start URL and SSO Region.
Código
    aws configure sso
The command will interactively prompt you for:
  • SSO Start URL: The URL for your organization's AWS access portal.
  • SSO Region: The AWS Region where your IAM Identity Center instance is located.
  • AWS Account ID: The AWS account you want to access.
  • Role Name: The IAM role (permission set) you want to assume within that account.
  • Default output format: (e.g., json, text, table)
  • Default region: The AWS Region where your commands will be sent by default.
  • Profile name: A name for this SSO profile (e.g., my-sso-profile).
To use the profile:
aws sts get-caller-identity --profile aeropay 
 
Log in to IAM Identity Center.
After configuring the profile, you need to initiate the login process to obtain temporary credentials.
Código
aws sso login --profile <your-profile-name>
export AWS_PROFILE=company-profile
 
Replace <your-profile-name> with the name you provided in the aws configure sso step. This command typically opens your default web browser to the IAM Identity Center login page, where you authenticate using your organization's credentials. Once authenticated, the AWS CLI retrieves and caches temporary credentials.
Note: If you prefer not to open a browser, you can use the --no-browser or --use-device-code options with aws sso login. Use the configured profile.
After a successful login, you can use the configured profile to execute AWS CLI commands.
Código
    aws s3 ls --profile <your-profile-name>
This command would list your S3 buckets using the credentials obtained through your SSO session.
Important Considerations:
  • AWS CLI Version:
    Ensure you are using AWS CLI version 2, as SSO integration is primarily supported in this version.
  • Session Management:
    SSO sessions have a limited duration. When your session expires, you will need to run aws sso login again to refresh your credentials.
  • Logout:
    To explicitly log out and remove cached credentials, use aws sso logout --profile <your-profile-name>

jueves, 13 de noviembre de 2025

Solaar rules for ubuntu Logitech MX Master 3S

Great rules for our Logitech

%YAML 1.3
---
- MouseGesture: Mouse Right
- KeyPress:
- [Super_L, Right]
- click
...
---
- MouseGesture: Mouse Left
- KeyPress:
- [Super_L, Left]
- click
...
---
- MouseGesture: Mouse Up
- KeyPress:
- [Super_L, a]
- click
...
---
- MouseGesture: Mouse Down
- KeyPress:
- Super_L
- click
...
---
- Test: [thumb_wheel_up, 15]
- KeyPress:
- [Control_L, Alt_L, Left]
- click
...
---
- Test: [thumb_wheel_down, 15]
- KeyPress:
- [Control_L, Alt_L, Right]
- click
...

 

jueves, 6 de noviembre de 2025

Terraform with lambda

 

 


terraform {
required_version = ">= 1.13.5"
required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 4.16.1"
}
}
}

# Configure the AWS provider
provider "aws" {
region = "us-east-1" # Replace with your desired region
}

# IAM role for Lambda execution
resource "aws_iam_role" "lambda_exec" {
name = "hello_world_lambda_role"

assume_role_policy = jsonencode({
Version = "2012-10-17"
Statement = [{
Action = "sts:AssumeRole"
Effect = "Allow"
Principal = {
Service = "lambda.amazonaws.com"
}
}]
})
}

# Attach basic Lambda execution policy
resource "aws_iam_role_policy_attachment" "lambda_policy" {
role = aws_iam_role.lambda_exec.name
policy_arn = "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
}

# Create a ZIP archive of the Lambda function
data "archive_file" "lambda_zip" {
type = "zip"
source_file = "${path.module}/lambda_function.py"
output_path = "${path.module}/lambda_function.zip"
}

# Create the Lambda function
resource "aws_lambda_function" "hello_world" {
function_name = "hello_world"
filename = data.archive_file.lambda_zip.output_path
source_code_hash = data.archive_file.lambda_zip.output_base64sha256
role = aws_iam_role.lambda_exec.arn
handler = "lambda_function.lambda_handler"
runtime = "python3.9"
environment {
variables = {
ENVIRONMENT = "production"
}
}
}

# Output the Lambda function ARN
output "lambda_function_arn" {
description = "The ARN of the Lambda function"
value = aws_lambda_function.hello_world.arn
}

# Output the Lambda function name
output "lambda_function_name" {
description = "The name of the Lambda function"
value = aws_lambda_function.hello_world.function_name
}



 

Detect lambda drift with terraform



To detect drift in your Lambda function's code using the hash, you can compare the current hash in your Terraform state with the actual deployed Lambda's hash.

terraform state show aws_lambda_function.hello_world | grep source_code_hash

aws lambda get-function --function-name hello_world --query 'Configuration.CodeSha256' --output text

Terraform import block

 Let's imagine we want to import an SNS Topic into our template.

 We should have something like this, change region, to and id of the import.

terraform {
required_version = ">= 1.13.5"
required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 4.16.1"
}
}
}

# Configure the AWS provider
provider "aws" {
region = "us-east-1" # Replace with your desired region
}

import {
to = aws_sns_topic.AleTopic
id = "arn:aws:sns:us-east-1:XXXX:AleTopic"
}

 

Run to generate the config file for that resource

terraform plan -generate-config-out=generated.tf 


A new file will be generated.

# __generated__ by Terraform
# Please review these resources and move them into your main configuration files.

# __generated__ by Terraform
resource "aws_sns_topic" "AleTopic" {
application_failure_feedback_role_arn = null
application_success_feedback_role_arn = null
application_success_feedback_sample_rate = 0
archive_policy = null
content_based_deduplication = false
delivery_policy = null
display_name = "My topic"
fifo_throughput_scope = null


Run terraform plan

 

Then run terraform apply to bring the changes to the state file. 

 

 

miércoles, 5 de noviembre de 2025

Update aws cdk to the latest version

sudo npm uninstall -g aws-cdk
sudo npm uninstall -g npm
sudo npm install -g npm@latest
sudo npm install -g aws-cdk@latest

lunes, 3 de noviembre de 2025

Import an existing resource using AWS CDK

To fully manage the existing resource with your CDK stack (allowing you to modify its properties later), you must perform a Resource Import using the cdk import CLI command, which relies on CloudFormation's import capabilities.


Let's test this with new cdk code, importing a sns topic.

cdk init app --language=python

 

Create venv

source .venv/bin/activate && pip install -r requirements.txt

 

 We would like import this resource

 

 

On the cdk code you need to write the following, referencing the topic.

from aws_cdk import (
# Duration,
Stack,
aws_sns as sns,
aws_iam as iam
)
from constructs import Construct

class CdkImportStack(Stack):

def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None:
super().__init__(scope, construct_id, **kwargs)

existing_topic = sns.Topic(self, "MyManagedTopic", topic_name="MyTopic")

 

Run cdk synth to see the cloudformation template

cdk synth


Resources:
  MyManagedTopic0CEB7327:
    Type: AWS::SNS::Topic
    Properties:
      TopicName: MyTopic
    Metadata:
      aws:cdk:path: CdkImportStack/MyManagedTopic/Resource
  CDKMetadata:
    Type: AWS::CDK::Metadata
    Properties:
      Analytics: v2:deflate64:H4sIAAAAAAAA/zPcxxxxxxx
    Metadata:
      aws:cdk:path: CdkImportStack/CDKMetadata/Default
Parameters:
  BootstrapVersion:
    Type: AWS::SSM::Parameter::Value<String>
    Default: /cdk-bootstrap/hnb659fds/version
    Description: Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]


Then run and it will ask for the topic arn

cdk import CdkImportStack

 

You will see on the cloudformation stack the resource imported

 

 

domingo, 2 de noviembre de 2025

CDK migrate, a way to migrate your cloudformation template to cdk code

 The migration from the CloudFormation template to the CDK is done with a single command: cdk migrate. Simply point to the local CloudFormation template file (let’s call it demo-template.yaml), and watch as the CLI converts the template into a CDK application. The output and result from running the command will be a directory comprised of the CDK code and dependencies, but will not deploy the stack.

You can grab the template code from cloudformation. 

cdk migrate --stack-name CdkStack --language python --from-path cleaned_template.json

 

After that the template is under cdk_stack.

 

 

Run the code to see the cdk.out code generated.

source .venv/bin/activate
pip install -r CdkStack/requirements.txt 

cd CdkStack
cdk deploy