0Pricing
AWS Solutions Architect · Lesson

KMS, ACM, and Encryption Patterns

Manage encryption keys with AWS KMS, provision and rotate TLS certificates with ACM, and choose between client-side, server-side, and transit encryption.

KMS, ACM, and Encryption Patterns is a free AWS Solutions Architect lesson on CoddyKit — lesson 1 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the AWS Solutions Architect learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

Encryption on AWS: Overview

Encryption is a fundamental security control that protects data confidentiality even if storage media is compromised or access is gained through other means. AWS provides encryption for data at rest (stored in databases, S3, EBS) and in transit (moving across networks). Key services: AWS Key Management Service (KMS) manages encryption keys for at-rest encryption. AWS Certificate Manager (ACM) provisions and manages TLS certificates for in-transit encryption. Understanding when and how to apply each is essential for the Security Architecture domain of SAA-C03.

# Encryption coverage on AWS:
# At rest (KMS):
#   S3, EBS, RDS, DynamoDB, EFS, SQS,
#   Lambda env vars, Secrets Manager, SSM Parameter Store

# In transit (ACM/TLS):
#   ALB listeners (HTTPS), API Gateway, CloudFront,
#   Direct Connect, VPN, inter-service communication

# Both:
#   S3 Server-Side Encryption + HTTPS only policy

AWS KMS: Key Management Service

AWS KMS is a fully managed service for creating and controlling encryption keys. KMS uses Hardware Security Modules (HSMs) to protect keys — the key material never leaves the HSM unencrypted. KMS integrates with most AWS services for server-side encryption. Types of keys: AWS Managed Keys (free, auto-rotated annually, you cannot control them directly), Customer Managed Keys (CMK) ($1/month each, you control rotation, key policy, and deletion). Custom Key Store uses your own CloudHSM cluster for compliance requirements that mandate dedicated HSMs.

# Create a Customer Managed Key (CMK)
aws kms create-key \
  --description 'Production database encryption key' \
  --key-usage ENCRYPT_DECRYPT \
  --origin AWS_KMS \
  --tags TagKey=Purpose,TagValue=RDS-Encryption

# Create an alias for the key
aws kms create-alias \
  --alias-name alias/prod-db-key \
  --target-key-id arn:aws:kms:us-east-1:123:key/abc-def

# CMK costs: $1/month + $0.03 per 10,000 API calls

KMS Key Policies and Grants

Every KMS key has a key policy — a resource-based policy that controls who can use and manage the key. Unlike IAM policies which are identity-based, key policies are required: the key policy must explicitly grant access for IAM policies to take effect. Best practice: separate key administration (who can manage the key) from key usage (which services and roles can encrypt/decrypt). Use key grants for temporary delegated access — for example, grant an EMR cluster temporary use of a KMS key for a job without modifying the key policy.

# KMS key policy: grant RDS and admin access
{
  'Statement': [
    {
      'Sid': 'Enable root account full access',
      'Principal': {'AWS': 'arn:aws:iam::123:root'},
      'Action': 'kms:*',
      'Effect': 'Allow'
    },
    {
      'Sid': 'Allow RDS to use this key',
      'Principal': {'Service': 'rds.amazonaws.com'},
      'Action': ['kms:Encrypt','kms:Decrypt','kms:GenerateDataKey'],
      'Effect': 'Allow'
    }
  ]
}

KMS Envelope Encryption

KMS uses envelope encryption to protect large amounts of data efficiently. You cannot encrypt more than 4 KB directly with a KMS key. Instead: KMS generates a Data Encryption Key (DEK) — a random key used to encrypt your actual data locally. The DEK is then encrypted by your KMS key (the Key Encryption Key). You store the encrypted DEK alongside the encrypted data. To decrypt, you first call KMS to decrypt the DEK, then use the plaintext DEK locally to decrypt the data. This is how S3, EBS, and RDS encryption work under the hood.

# Generate a Data Key (for envelope encryption)
aws kms generate-data-key \
  --key-id alias/my-key \
  --key-spec AES_256

# Response contains:
# Plaintext: base64-encoded DEK (use to encrypt data locally)
# CiphertextBlob: KMS-encrypted DEK (store alongside data)

# To decrypt:
# 1. Call kms:Decrypt(CiphertextBlob) -> plaintext DEK
# 2. Use plaintext DEK to decrypt data locally
# 3. Zeroize plaintext DEK from memory
aws kms decrypt --ciphertext-blob fileb://encrypted-dek.bin

KMS Key Rotation

Key rotation is a security best practice that periodically replaces cryptographic key material, limiting the exposure window if a key is compromised. For Customer Managed Keys, you can enable automatic annual rotation — KMS generates new key material and uses it for new encrypt operations, while retaining old key material to decrypt existing data. AWS Managed Keys rotate automatically every year. Imported key material does NOT support automatic rotation (you must manually rotate). After rotation, new KMS operations use the new key material automatically without application changes.

# Enable automatic annual key rotation
aws kms enable-key-rotation \
  --key-id alias/prod-db-key

# Verify rotation is enabled
aws kms get-key-rotation-status \
  --key-id alias/prod-db-key

# Manual rotation (for imported key material):
# 1. Create a new CMK
# 2. Update all services to use new key
# 3. Re-encrypt existing data with new key
# 4. Schedule old key for deletion (minimum 7-day waiting period)

S3 Server-Side Encryption Options

S3 supports three server-side encryption options: SSE-S3 — S3 manages keys using AES-256, free, minimum control. SSE-KMS — uses a KMS key (AWS managed or CMK), provides key audit trail in CloudTrail, supports key policies, costs per KMS API call. SSE-C — you provide and manage the key material with each request; S3 never stores the key. Use SSE-KMS when you need audit control over who used the key and when. Use SSE-S3 for low-sensitivity data where simplicity and cost matter. Enforce encryption with a bucket policy that denies PutObject without encryption.

# Enforce SSE-KMS on all new S3 objects
aws s3api put-bucket-policy \
  --bucket my-secure-bucket \
  --policy '{
    "Statement": [{
      "Effect": "Deny",
      "Principal": "*",
      "Action": "s3:PutObject",
      "Resource": "arn:aws:s3:::my-secure-bucket/*",
      "Condition": {
        "StringNotEquals": {
          "s3:x-amz-server-side-encryption": "aws:kms"
        }
      }
    }]
  }'

# Set default encryption for bucket
aws s3api put-bucket-encryption \
  --bucket my-secure-bucket \
  --server-side-encryption-configuration '{"Rules":[{"ApplyServerSideEncryptionByDefault":{"SSEAlgorithm":"aws:kms","KMSMasterKeyID":"alias/my-key"}}]}'

AWS Certificate Manager (ACM)

AWS Certificate Manager (ACM) provisions, manages, and auto-renews SSL/TLS certificates for AWS services at no cost. ACM certificates can be used with ALB, NLB, CloudFront, API Gateway, and AppSync. ACM handles the certificate lifecycle automatically — it renews certificates 60 days before expiry and deploys the renewal transparently. You can request certificates for domains you own (validated via DNS or email) or import third-party certificates. ACM certificates are NOT downloadable — they are bound to the AWS service they are associated with.

# Request a public ACM certificate
aws acm request-certificate \
  --domain-name app.example.com \
  --subject-alternative-names '*.example.com' \
  --validation-method DNS

# ACM returns a CNAME record to add to Route 53
# Add the CNAME -> ACM validates domain ownership
# Certificate is issued and auto-renews annually

# Attach to ALB listener (HTTPS:443)
aws elbv2 create-listener \
  --load-balancer-arn <ALB-ARN> \
  --protocol HTTPS --port 443 \
  --certificates CertificateArn=arn:aws:acm:us-east-1:123:certificate/abc \
  --default-actions Type=forward,TargetGroupArn=<TG-ARN>

ACM Private Certificate Authority

ACM Private CA (Certificate Authority) lets you create a fully managed, private CA hierarchy for issuing certificates to internal resources — EC2 instances, containers, internal APIs, and IoT devices. Unlike public ACM certificates (used with internet-facing services), private CA certificates can be issued for any internal hostname or IP address. Use Private CA for: mutual TLS (mTLS) between microservices, certificate-based authentication for VPN, and compliance requirements for internal PKI. Private CA costs $400/month for the CA plus $0.75 per certificate issued.

# Create ACM Private Certificate Authority
aws acm-pca create-certificate-authority \
  --certificate-authority-type ROOT \
  --certificate-authority-configuration '{
    "KeyAlgorithm": "RSA_2048",
    "SigningAlgorithm": "SHA256WITHRSA",
    "Subject": {
      "Country": "US",
      "Organization": "Example Corp",
      "CommonName": "Example Corp Internal CA"
    }
  }'

# Issue certificate from private CA
aws acm request-certificate \
  --domain-name internal-service.example.internal \
  --certificate-authority-arn arn:aws:acm-pca:us-east-1:123:certificate-authority/xxx

EBS and RDS Encryption

For EBS volume encryption, enable it at volume creation time (or copy an existing volume with encryption enabled). All data on the volume, including snapshots, is encrypted using the KMS key you specify. EBS encryption is transparent to the operating system — no application changes needed. For RDS encryption, enable it when creating the DB instance; you cannot encrypt an existing unencrypted RDS instance directly. Workaround: create an encrypted snapshot from an unencrypted instance, then restore to a new encrypted instance. Both EBS and RDS encrypted snapshots stay encrypted when copied.

# Enable account-level EBS default encryption
aws ec2 enable-ebs-encryption-by-default
aws ec2 modify-ebs-default-kms-key-id \
  --kms-key-id alias/prod-ebs-key

# Encrypt an existing unencrypted RDS instance:
# 1. Create unencrypted snapshot
aws rds create-db-snapshot \
  --db-instance-identifier mydb \
  --db-snapshot-identifier mydb-plain-snapshot

# 2. Copy snapshot with encryption
aws rds copy-db-snapshot \
  --source-db-snapshot-identifier mydb-plain-snapshot \
  --target-db-snapshot-identifier mydb-encrypted-snapshot \
  --kms-key-id alias/prod-db-key

Client-Side vs Server-Side Encryption

Understanding the distinction between server-side and client-side encryption is important for the SAA-C03 exam. Server-side encryption: AWS encrypts data after receiving it and decrypts before delivering it — the data is in plaintext between your application and AWS. Client-side encryption: you encrypt data before sending it to AWS — AWS stores only ciphertext and never sees the plaintext. Use client-side encryption for the highest data sensitivity where you cannot trust the cloud provider to handle plaintext, such as healthcare records or financial data under strict regulations.

# Client-side encryption with AWS Encryption SDK
# (conceptual Python example)

# 1. Application encrypts data locally using KMS DEK
# from aws_encryption_sdk import KmsKeyProvider, encrypt

# key_provider = KmsKeyProvider(key_ids=['alias/my-key'])
# ciphertext, _ = encrypt(
#     source=b'Sensitive patient data',
#     key_provider=key_provider
# )

# 2. Send ciphertext to S3
# s3.put_object(Bucket='hipaa-data', Key='record.enc', Body=ciphertext)

# AWS only stores ciphertext - cannot decrypt without your key policy

KMS Cross-Account Access

KMS keys can be shared across AWS accounts for cross-account encryption scenarios. For example, if Account A's application writes encrypted data to an S3 bucket owned by Account B, Account A's KMS key must allow Account B's principal to use it. Configure the KMS key policy in Account A to grant cross-account access, then create an IAM policy in Account B to allow the role to use Account A's key. This pattern is common in data-sharing and multi-account architectures where a central account manages encryption keys.

# KMS key policy: allow cross-account access
# (in Account A's key policy)
{
  'Sid': 'Allow Account B to use this key',
  'Effect': 'Allow',
  'Principal': {
    'AWS': 'arn:aws:iam::999999999999:root'
  },
  'Action': [
    'kms:Encrypt',
    'kms:Decrypt',
    'kms:ReEncrypt*',
    'kms:GenerateDataKey*',
    'kms:DescribeKey'
  ],
  'Resource': '*'
}

# Account B IAM policy also needed to allow the role to use it

Quick Check

Test your understanding of AWS Solutions Architect (SAA-C03) concepts from this lesson.

Lesson Recap

In this lesson you learned: KMS manages encryption keys with HSM protection and supports CMKs for fine-grained access control and audit trails, ACM provisions and auto-renews TLS certificates for AWS services at no charge, and encryption can be applied server-side (KMS) or client-side, with server-side being the most common pattern for AWS-native workloads. Enforce encryption with bucket policies that deny unencrypted operations. Next up we explore GuardDuty, Inspector, and Macie.

Frequently asked questions

Is the “KMS, ACM, and Encryption Patterns” lesson free?

Yes — the full text of “KMS, ACM, and Encryption Patterns” is free to read here on the web, and the AWS Solutions Architect course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the AWS Solutions Architect course, upgrade to CoddyKit PRO.

What will I learn in “KMS, ACM, and Encryption Patterns”?

Manage encryption keys with AWS KMS, provision and rotate TLS certificates with ACM, and choose between client-side, server-side, and transit encryption. You practise AWS Solutions Architect with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start AWS Solutions Architect?

No prior experience is required. AWS Solutions Architect on CoddyKit is structured for beginners through advanced learners; this is — lesson 1 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “KMS, ACM, and Encryption Patterns” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this AWS Solutions Architect lesson?

Yes. Every AWS Solutions Architect lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. KMS, ACM, and Encryption Patterns
  2. GuardDuty, Inspector, and Macie
  3. Secrets Manager and Parameter Store
  4. WAF, Shield, and Network Firewall
← Back to AWS Solutions Architect