Comandos Bash para Ingenieros de AWS

Guía práctica en español con comandos Bash para ingenieros cloud: gestión EC2, S3, IAM y CloudWatch en AWS/Azure, prácticas, automatización y costes para Q2BSTUDIO.

18 ago 2025 • 3 min read • Q2BSTUDIO Team

Inteligencia-Artificial-

Aprendiendo la nube AWS encontré comandos Bash que me hicieron pensar en cuáles son las herramientas clave para un ingeniero cloud. Aquí presento una recopilación práctica en español con ejemplos fáciles de adaptar y consejos de buenas prácticas pensando en entornos de producción y en nuestros clientes en Q2BSTUDIO, empresa especializada en desarrollo de software a medida, aplicaciones a medida, inteligencia artificial, ciberseguridad y servicios cloud aws y azure.

1. Listar instancias EC2 y sus etiquetas

#!/bin/bash; echo Fetching EC2 instances and their tags...; aws ec2 describe-instances --query Reservations[].Instances[].[InstanceId,Tags] --output table

Este comando permite revisar rápidamente instancias y metadatos sin herramientas adicionales. Los corchetes actúan como comodines para traer todas las reservas.

2. Sincronizar y respaldar un bucket S3

#!/bin/bash; SOURCE_BUCKET=my-source-bucket; DEST_BUCKET=my-backup-bucket; DATE=$(date +%Y-%m-%d); echo Backing up $SOURCE_BUCKET to $DEST_BUCKET/$DATE...; aws s3 sync s3://$SOURCE_BUCKET s3://$DEST_BUCKET/$DATE --storage-class STANDARD_IA

Uso diario para copias, versionado y archivado con clase de almacenamiento de acceso infrecuente para optimizar costes.

3. Rotación de claves IAM

#!/bin/bash; USER_NAME=your-iam-user; echo Creating new access key...; NEW_KEY=$(aws iam create-access-key --user-name $USER_NAME); echo Disabling old access keys...; OLD_KEYS=$(aws iam list-access-keys --user-name $USER_NAME --query AccessKeyMetadata[*].AccessKeyId --output text); for KEY in $OLD_KEYS; do aws iam update-access-key --user-name $USER_NAME --access-key-id $KEY --status Inactive; done

Rotar claves con regularidad es una práctica esencial de ciberseguridad para mantener higiene en accesos y minimizar riesgos.

4. Consultar utilización de CPU de una instancia EC2 con CloudWatch

#!/bin/bash; INSTANCE_ID=i-xxxxxxxxxxxxxxxxx; REGION=us-west-2; START_TIME=$(date -u -d now-10minutes +%Y-%m-%dT%H:%M:%SZ); END_TIME=$(date -u +%Y-%m-%dT%H:%M:%SZ); aws cloudwatch get-metric-statistics --namespace AWS/EC2 --metric-name CPUUtilization --dimensions Name=InstanceId,Value=$INSTANCE_ID --start-time $START_TIME --end-time $END_TIME --period 300 --statistics Average --region $REGION --output table

Útil para monitoreo puntual y para activar políticas de escalado o alertas. Integrable con herramientas de inteligencia de negocio y dashboards en Power BI.

5. Terminar instancias no usadas por etiqueta para ahorrar costes

#!/bin/bash; TAG_KEY=Environment; TAG_VALUE=Dev; echo Finding EC2 instances with tag $TAG_KEY=$TAG_VALUE...; INSTANCE_IDS=$(aws ec2 describe-instances --filters Name=tag:$TAG_KEY,Values=$TAG_VALUE Name=instance-state-name,Values=running --query Reservations[].Instances[].InstanceId --output text); echo Terminating instances $INSTANCE_IDS; aws ec2 terminate-instances --instance-ids $INSTANCE_IDS

Automatiza la limpieza de entornos de desarrollo y evita facturas innecesarias.

Buenas prácticas adicionales

- Usar perfiles de IAM con permisos mínimos y roles asumibles para evitar el uso de claves permanentes. - Monitorizar costes y utilizar etiquetas estandarizadas para poder agrupar recursos por proyecto, cliente o entorno. - Integrar scripts con pipelines CI CD y con alertas en herramientas de observabilidad. - Documentar y versionar scripts en repositorios privados y aplicar revisiones de seguridad.

Sobre Q2BSTUDIO

En Q2BSTUDIO somos una empresa de desarrollo de software y aplicaciones a medida que además ofrece soluciones en inteligencia artificial, ia para empresas, agentes IA, ciberseguridad, servicios cloud aws y azure y servicios inteligencia de negocio. Implementamos software a medida y aplicaciones a medida que integran modelos de inteligencia artificial, automatizaciones y prácticas seguras para clientes que quieren modernizar operaciones y explotar datos con Power BI y otras plataformas.

Palabras clave y posicionamiento

aplicaciones a medida, software a medida, inteligencia artificial, ciberseguridad, servicios cloud aws y azure, servicios inteligencia de negocio, ia para empresas, agentes IA, power bi

Si necesitas que adaptemos alguno de estos scripts a tu infraestructura, integrarlo en pipelines o desplegar soluciones cloud seguras y escalables, en Q2BSTUDIO podemos ayudar. Cuéntanos qué automatizaciones usas y podemos convertirlas en soluciones gestionadas que mejoren seguridad, coste y rendimiento.

A BREAK?

Play for a moment before you go

OUR SERVICES

How we can help you

Artificial intelligence

AI agents, chatbots, and intelligent assistants that automate tasks and serve your customers 24/7 to improve the efficiency of your business.

More info

Software Development

Web, mobile, and desktop applications, intranets, e-commerce, SaaS, and management platforms designed for your company's specific needs.

More info

Cloud services

Migration, infrastructure, managed hosting, high availability, and security on Microsoft Azure and Amazon Web Services to help your business scale without limits.

More info

Cybersecurity and pentesting

Security audits, penetration testing and protection of applications, data and infrastructure on-premise and cloud, with ethical hacking and regulatory compliance.

More info

Business Intelligence

Dashboards and data analysis with Power BI: we integrate your sources, design dashboards and KPIs and turn your data into decisions.

More info

Process automation

We automate repetitive tasks and connect your applications with n8n, Power Automate, Make, and RPA, eliminating manual work and increasing productivity.

More info

Training for Companies

We train your teams in technology with criteria: web development, databases, Git, best practices and security, automation with n8n, artificial intelligence for companies and creation of AI solutions with Azure AI Foundry.

More info

Code Auditing

We audit the code that you, your team or an AI create: we tell you what is good and what to improve, we secure it and make it ready for production, web or app.

More info

AI Image Generation

We create for you the images that your business needs with artificial intelligence: product, networks, advertising, illustration and avatars. You tell us what you want and we deliver it ready to use.

More info

AI Video Generation

We create videos with artificial intelligence for you: promotional, networking, virtual presenters, dubbing and animations. You tell us the idea and we will deliver it assembled and ready to publish.

More info

AI Conversational Avatars

We create conversational avatars with AI – digital humans with a face and voice – that serve your customers and teams with the knowledge of your company, on your website, interactive monitors, WhatsApp or Teams.

More info

Online Marketing and AI

Google Ads, Meta Ads, LinkedIn Ads and AI Engine Positioning (GEO/AEO): we attract customers and make your brand appear where they search for you, also on ChatGPT, Gemini and Perplexity.

More info

Do you have a project in mind?

Tell us your vision and we'll turn it into a software solution. Whatever the scope, we make your idea real.

Live Chat