Interview Prep/DevOps Fundamentals/Security basics for DevOps

What is encryption in transit and encryption at rest?

BeginnerConceptSecurity basics for DevOps
Answer

In one line: Encryption in transit protects data while it moves across a network (using TLS), and encryption at rest protects data while it's stored on disks, databases and backups — you normally need both.

Encryption in transit

  • Protects against eavesdropping and tampering on the network.
  • Uses TLS (HTTPS for web traffic, TLS for database connections, SMTP over TLS, etc.).
  • Examples:
    • HTTPS on public endpoints with certificates from Let's Encrypt (cert-manager) or AWS ACM.
    • TLS between the app and the database (sslmode=require for PostgreSQL).
    • mTLS between microservices, often handled by a service mesh (Istio, Linkerd), where both sides prove their identity.
  • Redirect HTTP to HTTPS and use modern TLS versions (1.2+, ideally 1.3).

Encryption at rest

  • Protects data if disks, snapshots or backups are stolen or accessed without permission.
  • Examples:
    • Encrypted EBS volumes, S3 buckets, RDS databases, Azure Storage — usually with one setting or by default.
    • KMS keys (AWS KMS, Azure Key Vault, GCP KMS) manage the encryption keys; customer-managed keys give you control over rotation and access.
    • Kubernetes Secrets encrypted at rest in etcd.
    • Encrypted backups.

Key management matters:

  • Encryption is only as strong as key protection.
  • Use a KMS, restrict who can use or manage keys, enable key rotation and log key usage.

Example in Terraform:

resource "aws_s3_bucket_server_side_encryption_configuration" "logs" {
  bucket = aws_s3_bucket.logs.id
  rule {
    apply_server_side_encryption_by_default {
      sse_algorithm     = "aws:kms"
      kms_master_key_id = aws_kms_key.logs.arn
    }
  }
}

Tip for interviews: give one example of each and mention KMS-managed keys — and that IaC scanners like Checkov can enforce encryption automatically.

All DevOps Fundamentals questions

More on Security basics for DevOps