Daniel López Azaña

Theme

Social Media

Blog

Tag: Code Snippets

Script to automatically change all gp2 volumes to gp3 with aws-cli

Script to automatically change all gp2 volumes to gp3 with aws-cli

Last December Amazon announced its new EBS gp3 volumes, which offer better performance and a cost saving of 20% compared to those that have been used until now (gp2). Well, after successfully testing these new volumes with multiple clients, I can do nothing but recommend their use, because they are all advantages and in these 2 and a half months that have passed since the announcement I have not noticed any problems or side effects.

How to automatically update all your AWS EC2 security groups when your dynamic IP changes

AWS security groups

One of the biggest annoyances when working with AWS and your Internet connection has a dynamic IP is that when it changes, you immediately stop accessing to all servers and services protected by an EC2 security group whose rules only allow traffic to certain specific IP’s instead of allowing open connections to everyone (0.0.0.0.0/0).

Certainly the simplest thing to do is always allowing traffic on a given port to everyone, so that even if you have a dynamic IP on your Internet connection you will always be able to continue accessing even if it changes. But opening traffic on a port to everyone is not the right way to proceed from a security point of view, because then any attacker will be able to access that port without restrictions, and that is not what you want.

How to know how many cores and processors has a Linux box

cpu-cores

The simplest and shortest method to measure the number of processors present on a Linux box, which is also widely extended as it’s part of coreutils is:

Another way to get the same result which also allows us to obtain additional information from our processor are the lscpu command:

Or we can examine the cpuinfo file from /proc filesystem:

There are many additional details about these processors in /proc/cpuinfo file, including the CPU model and number of cores:

Using PHP to backup MySQL databases

diagrama-backup-mysql-php

This post shows how to perform a partial or full backup of MySQL databases using only PHP code. This is very useful for example when a client doesn’t provide you with access data to the database of a web application and you only have an FTP connection available, or when you do have the connection data to the database but you can’t access it through the network (only available from localhost) and you can’t use tools like mysqldump to back up the information you need because you don’t have privileges for this, or simply because you have no access to a shell to which connect and run commands.