RousselTMLEARNING

Cloud computing

Monitoring and securing AWS: CloudWatch, CloudTrail, Config, KMS and GuardDuty

Operate and protect an AWS environment: CloudWatch metrics, logs and alarms, the CloudTrail API call log, compliance with AWS Config, encryption with KMS, secrets with Secrets Manager, threat detection with GuardDuty and Security Hub.

1. CloudWatch #

Metrics, logs and alarms.

Principles #

AWS monitoring and security services
CloudTrail and Config feed detections; Security Hub centralizes findings.
  • Metrics: published automatically by services (EC2 CPU, ALB latency…); the CloudWatch agent adds memory and disk.
  • Logs: log groups, queries with Logs Insights, retention to define (unlimited by default).
  • Alarms: threshold or anomaly detection, SNS, Auto Scaling or EC2 actions.

Examples #

aws cloudwatch put-metric-alarm --alarm-name api-5xx --namespace AWS/ApplicationELB \
  --metric-name HTTPCode_Target_5XX_Count --dimensions Name=LoadBalancer,Value=app/api/abc123 \
  --statistic Sum --period 300 --evaluation-periods 2 --threshold 20 --comparison-operator GreaterThanThreshold \
  --alarm-actions arn:aws:sns:eu-west-3:123456789012:astreinte
aws logs put-retention-policy --log-group-name /aws/lambda/api --retention-in-days 30
# Logs Insights : erreurs par minute
# fields @timestamp, @message | filter @message like /ERROR/ | stats count() by bin(1m)

2. Audit and compliance #

CloudTrail and AWS Config.

CloudTrail #

CloudTrail records API calls (console, CLI, SDK): who, when, from where, with what result. Create an organization-wide, multi-region trail to an S3 bucket in an account dedicated to logs, with integrity validation.

aws cloudtrail lookup-events --lookup-attributes AttributeKey=EventName,AttributeValue=DeleteBucket --max-results 5

AWS Config #

AWS Config records the configuration history of each resource and evaluates rules (public bucket, unencrypted volume, security group open to 0.0.0.0/0 on port 22), with optional automatic remediation.

3. Protecting #

Encryption, secrets, threats.

Services #

ServiceRole
KMSManaged encryption keys, used by S3, EBS, RDS…; logged in CloudTrail
Secrets ManagerStorage and automatic rotation of secrets (database passwords, API keys)
GuardDutyDetection of suspicious activity (compromised credentials, mining, abnormal calls)
Security HubConsolidated findings and best-practice checks (AWS framework, CIS)
AWS WAF, ShieldWeb application firewall in front of CloudFront and ALB, DDoS protection
Good practice: Enable GuardDuty, Security Hub and Config in all accounts and all regions in use, with a delegated administrator account for security.

Related articles

Observability on AWS: CloudWatch, X-Ray, Application Signals, ADOT, Managed Prometheus and Grafana

A complete overview of observability on AWS: CloudWatch components (metrics, logs, alarms, Application Signal…

Understanding AWS: global infrastructure, accounts, tools and pricing

The essential basics for getting started with Amazon Web Services: regions, availability zones and points of …

IAM: identities, roles and policies on AWS

Secure access to AWS with IAM: users, groups, roles and JSON policies, permission evaluation, MFA, IAM Identi…

Keep learning

Support us

♥ SUPPORT US

Support RousselTM Learning

Courses, articles, labs and certificates stay free with no intrusive ads. A voluntary contribution, of any amount you choose, pays for hosting, lab environments and new content.

Contribute with PayPal Any amount · card or PayPal accountLearn more
QR code PayPal
Or scan this QR code with your phone

Thank you, every contribution counts!