Learning the AWS cloud, I found Bash commands that made me think about what the key tools are for a cloud engineer. Here I present a practical compilation in Spanish with examples that are easy to adapt and best practice tips with production environments and our clients at Q2BSTUDIO in mind, a company specialized in custom software development, custom applications, artificial intelligence, cybersecurity, and aws and azure cloud services.
1. List EC2 instances and their tags
#!/bin/bash; echo Fetching EC2 instances and their tags...; aws ec2 describe-instances --query Reservations[].Instances[].[InstanceId,Tags] --output table
This command allows you to quickly review instances and metadata without additional tools. The brackets act as wildcards to bring in all reservations.
2. Sync and back up an S3 bucket
#!/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
Daily use for copies, versioning, and archiving with infrequent access storage class to optimize costs.
3. IAM key rotation
#!/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
Rotating keys regularly is an essential cybersecurity practice to maintain access hygiene and minimize risks.
4. Query CPU utilization of an EC2 instance with 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
Useful for point-in-time monitoring and for triggering scaling policies or alerts. Integrable with business intelligence tools and Power BI dashboards.
5. Terminate unused instances by tag to save costs
#!/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
Automates cleanup of development environments and avoids unnecessary bills.
Additional best practices
- Use IAM profiles with least privilege permissions and assumable roles to avoid using permanent keys. - Monitor costs and use standardized tags to group resources by project, client, or environment. - Integrate scripts with CI CD pipelines and alerts in observability tools. - Document and version scripts in private repositories and apply security reviews.
About Q2BSTUDIO
At Q2BSTUDIO we are a custom software and application development company that also offers solutions in artificial intelligence, AI for businesses, AI agents, cybersecurity, aws and azure cloud services, and business intelligence services. We implement custom software and custom applications that integrate artificial intelligence models, automations, and secure practices for clients who want to modernize operations and leverage data with Power BI and other platforms.
Keywords and positioning
custom applications, custom software, artificial intelligence, cybersecurity, aws and azure cloud services, business intelligence services, AI for businesses, AI agents, power bi
If you need us to adapt any of these scripts to your infrastructure, integrate them into pipelines, or deploy secure and scalable cloud solutions, at Q2BSTUDIO we can help. Tell us what automations you use and we can turn them into managed solutions that improve security, cost, and performance.



