DVA-C03 Encryption and Sensitive Data: KMS, S3 Encryption, Certificates and Secrets
Implementing encryption and managing sensitive data on AWS means choosing where and with which key data is encrypted at rest and in transit, issuing and renewing TLS certificates, finding and masking personal data, and storing application secrets so they rotate without breaking anything. This lesson covers DVA-C03 Task 2.2 end to end: KMS key types and permissions, S3 server-side encryption options, client-side and envelope encryption, encryption context, key rotation, encryption in EBS, RDS and DynamoDB, TLS on load balancers and databases, ACM and AWS Private CA, development certificates and SSH keys, Amazon Macie and CloudWatch Logs data protection, and Secrets Manager versus Parameter Store.
On this page10 sections
- Encryption at rest, encryption in transit and who controls the key
- Amazon S3 server-side encryption options
- Server-side or client-side encryption: choosing where data is encrypted
- Envelope encryption with KMS data keys
- Who may use a KMS key: key policies, IAM, cross-account access and encryption context
- Managing KMS keys from code: aliases, rotation, imported material and multi-Region keys
- Encryption across AWS services: EBS, RDS, DynamoDB and data in transit
- Certificates: ACM public, exportable and private certificates, AWS Private CA and development keys
- Finding, masking and restricting sensitive data (PII and PHI)
- Secrets Manager and Parameter Store: storing, retrieving and rotating secrets
- Choose between AWS owned, AWS managed and customer managed KMS keys, and between SSE-S3, SSE-KMS, DSSE-KMS, SSE-C and client-side encryption
- Implement envelope encryption with GenerateDataKey and GenerateDataKeyWithoutPlaintext, and use encryption context for integrity and tenant isolation
- Grant the right KMS permissions for same-account and cross-account use, and rotate keys without breaking existing ciphertext
- Apply encryption at rest to EBS, RDS and DynamoDB, and enforce and verify TLS for S3, load balancers and databases
- Select and renew certificates with ACM and AWS Private CA, and create certificates and SSH keys for development
- Find, mask and restrict PII and PHI with Amazon Macie, CloudWatch Logs data protection and S3 tag-based policies, and know the current pattern for masking data in messages
- Store, retrieve, cache and rotate secrets with Secrets Manager and Parameter Store
Encryption at rest, encryption in transit and who controls the key
Encryption at rest protects data where it is stored (S3 objects, EBS volumes, database storage, logs); encryption in transit protects data while it moves between a client and a service, or between two services, using TLS. Most AWS storage services encrypt at rest with keys from AWS Key Management Service (AWS KMS), and the real design decision for a developer is usually which kind of key and who may use it, not whether to encrypt.
| Key type | Who manages it | Can you edit its key policy? | Visible in your account / CloudTrail? | Cross-account use |
|---|---|---|---|---|
| AWS owned key | AWS, shared across accounts | No | No — you never see it | Not applicable |
AWS managed key (aws/s3, aws/dynamodb, aws/rds…) | AWS, created in your account for one service | No | Yes, use is logged | No — its key policy only trusts your account through that service |
| Customer managed key | You | Yes | Yes, every use is logged | Yes, through its key policy plus the caller's IAM policy |
Choose a customer managed key when a requirement says the team must write the key policy itself, share encrypted data with another account, disable the key in an emergency to cut off access, or control the rotation schedule. An AWS managed key gives you an audit trail but no say over its policy; an AWS owned key gives you neither.
Disabling a customer managed key immediately stops every encrypt and decrypt with it, which makes the data it protects unreadable until the key is re-enabled. Scheduling a key for deletion starts a mandatory 7–30 day waiting period; once it is deleted, data encrypted under it is lost for good, so disabling is the reversible emergency switch.
Amazon S3 server-side encryption options
Amazon S3 encrypts every new object at rest; you choose how through the bucket's default encryption setting or per-request headers. Since January 2023 the baseline is SSE-S3, so an object is never stored unencrypted, but SSE-S3 gives you no key policy and no per-use CloudTrail record of a KMS key.
| Option | Who holds the key | What it gives you |
|---|---|---|
| SSE-S3 | S3 (S3 managed keys) | Encryption at rest with no extra cost or setup; no key policy, no KMS audit trail. |
SSE-KMS with aws/s3 | KMS, AWS managed key | Key use logged in CloudTrail; key policy fixed by AWS; cannot be shared with another account. |
| SSE-KMS with a customer managed key | KMS, your key | Your key policy, rotation control, cross-account sharing, CloudTrail record of every use; the caller needs KMS permissions. |
| DSSE-KMS | KMS | Dual-layer server-side encryption: two independent layers of encryption applied by S3, for frameworks that demand two layers without client-side code. |
| SSE-C | You, sent with every request over HTTPS | S3 encrypts with your key and discards it; you must supply the same key to read. Blocked by default on new general purpose buckets (see below). |
S3 Bucket Keys
With SSE-KMS, S3 normally asks KMS for a data key for each object, so a bucket receiving millions of small objects generates millions of KMS requests: that costs money and can hit the account's KMS request quota, producing throttling errors. An S3 Bucket Key lets S3 create a short-lived bucket-level key from your KMS key and derive object keys from it locally, cutting KMS requests (and cost) dramatically while every object stays encrypted under the same KMS key. It is a checkbox in the bucket's default encryption settings — no code change. Because the number of KMS requests is what drives cost and throttling, a Bucket Key changes the bill and the request rate without changing which KMS key protects the data.
SSE-C on new buckets
Since April 2026, new general purpose buckets block SSE-C by default: their default encryption configuration lists SSE-C under blocked encryption types (BlockedEncryptionTypes in PutBucketEncryption), and any write that carries the customer-key headers fails with 403 AccessDenied, whatever the IAM policy allows. If an application genuinely needs SSE-C (for example keys held in an on-premises HSM), update the bucket's default encryption configuration to stop blocking it; adding IAM or bucket-policy allows does not help because the block is not a permissions problem.
Server-side or client-side encryption: choosing where data is encrypted
Server-side encryption means the AWS service receives your plaintext (over TLS) and encrypts it before writing to disk; client-side encryption means your application encrypts the data before sending it, so the service only ever stores ciphertext. Choose client-side encryption when a requirement says that AWS, the storage service, or people with full permissions on that service (for example DynamoDB or S3 administrators) must never see the plaintext.
| Requirement | Approach |
|---|---|
| Encrypted at rest, audit key use, control the key policy | Server-side: SSE-KMS (customer managed key), DynamoDB/RDS with a customer managed key |
| Plaintext must never leave the application's servers | Client-side: AWS Encryption SDK with a KMS keyring, then upload |
| Hide specific DynamoDB attributes from table administrators, keep other attributes readable and queryable | Client-side, attribute-level: AWS Database Encryption SDK for DynamoDB, plus kms:Decrypt granted only to the service that may read them |
Server-side encryption with a customer managed key does not hide data from a principal who can read the table or bucket: the service decrypts transparently for anyone it authorises. Only client-side encryption plus tight control of kms:Decrypt separates "can read the data store" from "can read the data". The AWS Database Encryption SDK encrypts and signs chosen attributes per item, leaves the others in plaintext (so keys and indexes keep working) and offers searchable encryption through beacons.
Don't build your own cryptography
The AWS Encryption SDK implements envelope encryption, authenticated encryption (AES-GCM), key commitment and a portable message format for you. Calling KMS Encrypt directly is limited to 4 KB of plaintext. Writing envelope logic yourself on top of a low-level AES library means owning nonce handling, key commitment and the stored format; the SDK exists so application teams do not write cryptographic code.
Data key caching and fewer KMS calls
By default the Encryption SDK asks KMS for a new data key for each message. At thousands of messages a second that means thousands of GenerateDataKey calls and KMS throttling. Data key caching (a caching cryptographic materials manager) reuses a data key within limits you set — maximum age, maximum number of messages and maximum bytes — trading a little key reuse for far fewer KMS calls. Newer SDK versions offer the AWS KMS Hierarchical keyring for the same purpose. The limits are the point of the feature: they bound how much data, and for how long, any single data key protects.
Envelope encryption with KMS data keys
Envelope encryption encrypts the data with a data key locally and then protects the data key with a KMS key, storing only the encrypted data key beside the ciphertext. It exists because the KMS Encrypt operation accepts at most 4 KB of plaintext and because sending bulk data to KMS for every operation would be slow and expensive. The KMS key itself never leaves KMS.
| KMS operation | Returns | Use it when |
|---|---|---|
Encrypt / Decrypt | Ciphertext / plaintext of up to 4 KB | Small secrets such as a password or a configuration value |
GenerateDataKey | Plaintext data key and CiphertextBlob (the same key encrypted under the KMS key) | You will encrypt data right now: use Plaintext in memory, store CiphertextBlob, then discard the plaintext key |
GenerateDataKeyWithoutPlaintext | Only CiphertextBlob | One component creates the key, another encrypts later; the creator must never handle plaintext key material |
GenerateRandom | Random bytes, not tied to any KMS key | Nonces or tokens — not a protected data key |
ReEncrypt | Ciphertext under a different KMS key (or context), without exposing plaintext to you | Moving ciphertext to another key |
The flow
- Encrypt: call
GenerateDataKey(for exampleKeySpec='AES_256'), encrypt the data locally with the plaintext key, store the ciphertext together with theCiphertextBlob, and drop the plaintext key from memory. - Decrypt: read the stored
CiphertextBlob, call KMSDecryptto recover the plaintext data key (this needskms:Decrypton the KMS key), then decrypt the data locally.
key = kms.generate_data_key(KeyId='alias/app-data',
KeySpec='AES_256')
sealed = seal_locally(key['Plaintext'], document)
s3.put_object(Bucket=BUCKET, Key=name, Body=sealed,
Metadata={'wrapped-key':
b64encode(key['CiphertextBlob']).decode()})
del key # the plaintext key lives only in memory
The security of the scheme rests on one rule: store the encrypted data key, never the plaintext one. If the plaintext data key sits next to the data, anyone who can read the store can decrypt it, and KMS access control no longer matters. The point of envelope encryption is that reading the data requires a kms:Decrypt call that the key policy and IAM can allow or deny, and that CloudTrail records.
Who may use a KMS key: key policies, IAM, cross-account access and encryption context
Access to a KMS key is decided by its key policy first: no principal can use a key unless the key policy allows it, either directly or through the default statement that lets the account's IAM policies grant access. With that default statement in place, a role in the same account needs an IAM policy allowing the specific KMS action on the key's ARN.
The permissions SSE-KMS needs
| Operation | S3 permission | KMS permission on the bucket's key |
|---|---|---|
Upload (PutObject, multipart upload) | s3:PutObject | kms:GenerateDataKey (multipart uploads also need kms:Decrypt) |
Download (GetObject) | s3:GetObject | kms:Decrypt |
S3 calls KMS with the caller's identity, so an S3 permission alone never reads or writes an SSE-KMS object: KMS authorises the caller separately against that object's key. SSE-S3 objects involve no KMS key and need no KMS permission. The same applies to DynamoDB, SQS, SNS and other services that call KMS on your behalf: the caller's identity needs the KMS permission too. The condition key kms:ViaService can limit a permission to requests that arrive through a named service (for example only through S3).
Cross-account use needs both sides
For a principal in account B to use a key in account A, both of these must allow it:
- the key policy in account A must allow account B (or the specific role) the action, for example
kms:Decrypt; and - an IAM policy in account B must allow the role that action on the key's full key ARN. KMS authorises cross-account use against the key ARN, not an alias.
Because an AWS managed key's policy cannot be edited, objects encrypted with aws/s3 cannot be decrypted from another account. To share them, re-encrypt them (for example with a copy-in-place) under a customer managed key whose key policy admits the other account. Grants are a third mechanism: programmatic, scoped permissions, often created by AWS services (for example EBS for an attached volume). A grant can also name a principal in another account as grantee (CreateGrant), and it lasts until it is retired or revoked.
Encryption context: binding ciphertext to its purpose
An encryption context is a set of non-secret key–value pairs (for example {"tenant": "t-42"}) passed with a symmetric KMS encryption request and cryptographically bound to the ciphertext as additional authenticated data. Decryption succeeds only when the caller supplies exactly the same encryption context; a missing or different pair makes Decrypt fail with InvalidCiphertextException, even when IAM allows kms:Decrypt. The fix is to pass the original pairs again, not to change permissions or the algorithm.
- The context is not secret: it appears in plaintext in CloudTrail logs, which makes it useful for auditing which record or tenant a decryption was for. Never put sensitive data in it.
- It works as an authorisation input through policy conditions:
kms:EncryptionContext:key— requires a specific value for a specific key, for example allowing a tenant's worker role to decrypt only whenkms:EncryptionContext:tenantequals its own tenant ID. This gives tenant isolation on one shared KMS key.kms:EncryptionContextKeys— only checks which keys are present, not their values, so it cannot stop one tenant decrypting another's data.
The AWS Encryption SDK and AWS Database Encryption SDK pass an encryption context for you and store it in their message format, so you get the binding without managing it by hand.
Managing KMS keys from code: aliases, rotation, imported material and multi-Region keys
Applications should reference KMS keys by alias (for example alias/app-data) rather than by hard-coded key ID or ARN. An alias is account- and Region-scoped, so the same name can point at a different key in development and production, and UpdateAlias repoints it to a new key without a redeploy. Aliases work for cryptographic operations in your own account; cross-account callers must use the key ARN.
Rotation
| Key | How to rotate | What changes |
|---|---|---|
| Symmetric, KMS-generated key material | Automatic rotation with a period you choose (90–2,560 days, for example 365), or RotateKeyOnDemand | New key material; same key ID, ARN and aliases. For KMS-generated material, KMS keeps every previous version, so old ciphertext still decrypts — no code change, no re-encryption job. |
| Symmetric key with imported key material | Import new material into the same key with ImportKeyMaterial, then call RotateKeyOnDemand (automatic rotation is not available) | Same key ARN, so grants and key policies in other accounts keep working. Old ciphertext still decrypts only while the earlier material stays imported: you manage every key material of an imported-material key, and the key becomes unusable as soon as any of its materials expires or is deleted. |
| Asymmetric, HMAC or custom key store keys | Manual: create a new key and repoint the alias | New key ID; callers that use the old ARN must change. |
| AWS managed keys | AWS rotates them every year | You cannot change the schedule. |
Manual rotation (new key + alias) changes the key ARN, which breaks anything that references the ARN, such as key policies or grants in partner accounts.
Multi-Region keys
A multi-Region key is a set of related keys in different Regions that share the same key ID and key material, so ciphertext produced in one Region can be decrypted in another without a cross-Region call. They pay off for client-side encryption (Encryption SDK, Database Encryption SDK) of data that moves between Regions. They do not share a key across accounts, and S3 cross-Region replication treats them as single-Region keys and re-encrypts objects in the destination Region.
Encryption across AWS services: EBS, RDS, DynamoDB and data in transit
Each storage service has its own rule for when encryption at rest can be switched on, and that rule decides the steps a developer takes.
| Service | How encryption at rest works | Changing it later |
|---|---|---|
| Amazon EBS | Per volume; EBS encryption by default is an account setting per Region that encrypts every new volume, even when the launch template or script does not ask | An existing unencrypted volume cannot be encrypted in place: snapshot it, then create a new encrypted volume from the snapshot (directly, or from an encrypted copy of the snapshot) and swap it in |
| Amazon RDS / Aurora | Chosen at creation with a KMS key | You cannot turn it on for an existing unencrypted instance or create an encrypted read replica of it: take a snapshot, copy the snapshot with encryption enabled, restore a new instance from the copy and point the application at it |
| Amazon DynamoDB | Always encrypted; the default is an AWS owned key, or choose the AWS managed key aws/dynamodb or a customer managed key | Switch the key of an existing table in place, with the table online — no export or migration |
For DynamoDB, a customer managed key is the only option that lets your team write the key policy and disable the key to cut off access; aws/dynamodb is logged but its policy cannot be edited.
Encryption in transit
- Amazon S3: a bucket policy statement that denies all S3 actions when
aws:SecureTransportisfalserejects every plain-HTTP request from any client, without touching anyone's IAM permissions. - Load balancers: an ALB HTTPS listener with an ACM certificate encrypts client → ALB. For encryption on every hop, set the target group protocol to HTTPS and serve TLS on the targets with a certificate installed on each instance (the ALB does not validate target certificates, so a self-signed or private certificate works there). A Network Load Balancer with TCP listeners passes TLS through to the targets, which then terminate it themselves.
- Databases: make the server require TLS —
require_secure_transport=ONfor RDS for MySQL/MariaDB,rds.force_ssl=1for RDS for PostgreSQL, set in a custom DB parameter group — and make clients verify the server certificate against the RDS CA bundle (for example MySQLssl-mode=VERIFY_IDENTITY, PostgreSQLsslmode=verify-full).REQUIRED/requireencrypts without checking who answered, so a spoofed endpoint goes unnoticed. - AWS APIs: SDKs and the CLI call HTTPS endpoints by default; FIPS endpoints are for FIPS 140-validated cryptography, not a substitute for client-side encryption.
Certificates: ACM public, exportable and private certificates, AWS Private CA and development keys
AWS Certificate Manager (ACM) issues and renews TLS certificates for AWS services, and AWS Private CA runs a private certificate authority hierarchy you own. Pick by who must trust the certificate and where it is installed.
| Certificate | Trusted by | Where it can be used | Renewal |
|---|---|---|---|
| ACM public certificate | Browsers and public clients | Integrated services only (ALB, CloudFront, API Gateway…); private key cannot be exported | Automatic when DNS-validated and in use; email validation needs someone to approve renewal |
| ACM exportable public certificate | Public clients | Anywhere, including your own EC2/NGINX or on-premises servers (extra charge) | ACM renews it; you re-export and redeploy after each renewal |
| Imported certificate (third-party CA) | Depends on the CA | Integrated services | Never renewed by ACM — you re-import; ACM only sends expiry events |
| ACM private certificate from AWS Private CA | Clients that trust your private root | Integrated services (for example an internal ALB) and exportable to your own hosts | ACM-managed renewal when requested through ACM |
Certificate issued directly by AWS Private CA (IssueCertificate) | Clients that trust your private root | Wherever you install it, for example mutual TLS between microservices | Your responsibility; if you import it into ACM, ACM will not renew it |
Rules that decide ACM questions
- ACM certificates are Regional. A load balancer or API uses a certificate in its own Region, but Amazon CloudFront only uses certificates from ACM in us-east-1 (N. Virginia); a certificate in any other Region never appears in the distribution's list. Request (or import) one in us-east-1.
- Public certificates need a publicly resolvable domain you can validate. Internal names that exist only in a private hosted zone (for example
api.corp.internal) need a private certificate. - To stop an imported certificate from causing an outage, replace it with an ACM-issued certificate that is DNS-validated, so renewal is automatic from then on.
AWS Private CA
Use AWS Private CA when you need your own CA hierarchy for internal names or mutual TLS (clients presenting certificates too) without running CA software. A general-purpose CA issues certificates of any validity and supports revocation through CRLs (published to S3) and OCSP. A CA in short-lived certificate mode issues certificates valid for at most seven days, at a lower monthly and per-certificate price; it suits workloads that request a fresh certificate per job and simply let it expire instead of revoking it.
Certificates and SSH keys for development
- EC2 key pairs:
aws ec2 create-key-pair(RSA or ED25519) returns the private key once; AWS keeps only the public key, so a lost private key cannot be downloaded again. Create a new key pair (or generate one locally withssh-keygenand register it withimport-key-pair) and add its public key to the instance's~/.ssh/authorized_keys, for example through EC2 Instance Connect, Session Manager or by attaching the root volume to another instance. - Self-signed certificates: for a test HTTPS endpoint that has no public domain and is called only by clients you control, generate one with OpenSSL (for example
openssl req -x509 -newkey rsa:2048 -nodes -days 30 …) and add it to those clients' trust stores. It costs nothing; it must never face real users.
Finding, masking and restricting sensitive data (PII and PHI)
AWS splits sensitive-data protection into three jobs: find it where it is stored, mask it where it flows (logs, messages), and limit who can read it. Personally identifiable information (PII) and protected health information (PHI) are the usual examples.
| Job | Service / feature | What it does |
|---|---|---|
| Find PII/PHI in S3 | Amazon Macie | Automated sensitive data discovery samples all your buckets continuously; discovery jobs scan chosen buckets. Uses managed data identifiers and your own custom data identifiers (regular expressions plus optional keywords). Produces findings — it does not move, block or delete anything. |
| Mask PII in logs | CloudWatch Logs data protection policies | Applied to a log group (or account-wide); managed or custom data identifiers mask matching values as events are ingested; audit findings can go to CloudWatch Logs, S3 or Firehose. |
| Mask PII in messages | A Lambda subscriber using Amazon Bedrock Guardrails | The function receives each message, applies a guardrail to redact or block sensitive data, and republishes the cleaned message to a second topic. Amazon SNS message data protection (data protection policies on a topic) is no longer available to new customers since 30 April 2026; accounts that already use it keep it, without further enhancements. |
| Threat detection (not PII discovery) | GuardDuty, Inspector | Suspicious activity and software vulnerabilities — they do not classify the contents of objects. |
CloudWatch Logs masking rules
- Masking applies only to events ingested after the policy is in place. Older events keep their plaintext; if they must go, delete those log streams (or let retention expire them).
- Readers see masked values by default. Principals granted
logs:Unmaskon the log group can view the original values, so specific engineers can see real data during incidents while everyone else sees it masked. - It is configuration on the log group, so applications keep logging as before. KMS encryption of a log group is a separate control: it protects the stored data, while a data protection policy controls what authorised readers see.
Acting on Macie findings
Macie publishes findings to Amazon EventBridge (and AWS Security Hub). An EventBridge rule that targets a Lambda function or ticketing workflow is the way to automate a response. To restrict access to objects Macie flags without moving them or editing every role, have that function tag each flagged object (for example classification=phi) and add a bucket policy that denies s3:GetObject when s3:ExistingObjectTag/classification is phi, except for the compliance role. s3:ExistingObjectTag checks tags already on the object; s3:RequestObjectTag checks tags sent in the current request, so it governs which tags a write such as PutObject or PutObjectTagging may set.
Beyond these services, limit access with least-privilege IAM, separate buckets or tables for PII/PHI stores, client-side encryption of the most sensitive attributes and kms:Decrypt granted only to the components that need plaintext. Redacting PII from prompts and responses of AI models is covered in the lesson on securing AI services (Task 2.3).
Secrets Manager and Parameter Store: storing, retrieving and rotating secrets
AWS Secrets Manager stores secrets encrypted with KMS and can rotate them on a schedule; Systems Manager Parameter Store stores configuration and SecureString parameters encrypted with KMS but has no built-in rotation. Credentials that must change automatically (database passwords, API keys with a rotation process) belong in Secrets Manager; plain configuration and static encrypted values fit Parameter Store. Plain environment variables in a task definition or function configuration are not a secret store.
| Secrets Manager | Parameter Store (SecureString) | |
|---|---|---|
| Automatic rotation | Yes — managed rotation or a rotation Lambda function | No |
| Cost | Per secret per month plus API calls | Standard parameters at no extra charge; advanced parameters and higher throughput are charged |
| Cross-Region replication | Yes (replica secrets) | No |
| Cross-account access | Resource-based secret policy (with a customer managed KMS key) | Limited (advanced parameters can be shared through AWS RAM) |
Retrieving secrets efficiently
- Lambda: calling
GetSecretValueon every invocation adds latency, cost and throttling. The AWS Parameters and Secrets Lambda Extension runs a local HTTP cache (onlocalhost:2773) with a configurable TTL, so the function reads from memory and picks up a rotated value when the TTL expires — no custom caching code. - Amazon ECS: reference the secret or parameter ARN in the container definition's
secretssection; the task execution role needssecretsmanager:GetSecretValue(orssm:GetParameters) andkms:Decryptfor a customer managed key. The value is injected when the container starts, so a running task sees a rotated value only after it is restarted. - Other code: the AWS SDK secret caching clients do the same job in-process.
Rotation
- Managed rotation needs no Lambda function. The simplest case: when creating or modifying an RDS DB instance or Aurora cluster, let RDS manage the master user password in Secrets Manager; RDS generates it, stores it encrypted and rotates it, and nobody types it anywhere. Managed external secrets extend managed rotation to credentials of onboarded third-party SaaS partners; other third-party secrets still need a custom rotation function.
- Rotation functions run four steps —
createSecret,setSecret,testSecret,finishSecret— moving the staging labelsAWSPENDING,AWSCURRENTandAWSPREVIOUSbetween versions. AWS provides templates for RDS, Aurora, Redshift and DocumentDB. - Single user strategy changes the one user's password in place: clients still holding the old password fail to log in until they re-read the secret. Alternating users strategy keeps two users and switches between them, so the previous credentials stay valid until the next rotation; it needs a separate superuser (admin) secret that can update the other user. Choose it for long-lived connection pools and cached credentials where no login may fail.
- Networking: a rotation function in private subnets must reach both the Secrets Manager API — through a Secrets Manager interface VPC endpoint or a NAT gateway — and the database, which means the database's security group must allow inbound traffic on its port from the function's security group. A Lambda function attached to a VPC has no internet access of its own, so these paths must exist inside the VPC.
Tip. Questions on this task are developer scenarios in which data must be encrypted, a certificate issued or renewed, sensitive data found or hidden, or a secret stored and rotated, usually under a constraint such as fewest changes, no code changes, no rotation code, the key ARN must not change, the table must stay online or no added AWS charges. Expect to diagnose AccessDenied and InvalidCiphertextException errors from missing KMS permissions or encryption context, to tell apart near-twin options (SSE-KMS with aws/s3 vs a customer managed key, GenerateDataKey vs GenerateDataKeyWithoutPlaintext, kms:EncryptionContext vs kms:EncryptionContextKeys, s3:ExistingObjectTag vs s3:RequestObjectTag, ACM public vs exportable vs private certificates, single user vs alternating users rotation), and to pick the managed feature over custom code. Several items are multiple response, where each correct option is one half of a working fix, such as the key policy and the IAM policy for cross-account KMS use.
- Customer managed KMS keys are the only keys whose policy you edit, share across accounts and can disable in an emergency; AWS managed keys such as aws/s3 cannot be shared.
- SSE-KMS reads need kms:Decrypt and writes need kms:GenerateDataKey; cross-account use needs the key policy and the caller's IAM policy, on the key ARN.
- S3 Bucket Keys cut SSE-KMS request volume and cost without changing the key; new general purpose buckets block SSE-C until default encryption stops blocking it.
- KMS Encrypt handles at most 4 KB: use GenerateDataKey, encrypt locally and store only the CiphertextBlob, never the plaintext data key.
- Decrypt must repeat the exact encryption context; kms:EncryptionContext:<key> conditions isolate tenants on one key.
- Automatic rotation keeps the key ID and old material; imported material rotates by importing into the same key and calling RotateKeyOnDemand.
- RDS encryption is set at creation (snapshot, encrypted copy, restore); DynamoDB switches keys in place; EBS encryption by default covers every new volume.
- CloudFront certificates must be in ACM us-east-1; only DNS-validated ACM certificates renew on their own; internal names and mutual TLS need AWS Private CA.
- Macie finds PII in S3 and reports to EventBridge; CloudWatch Logs data protection masks new events and logs:Unmask reveals them to chosen principals.
- Rotating credentials belong in Secrets Manager; use RDS-managed passwords, alternating users for connection pools, and a VPC endpoint plus database access for rotation functions.
Frequently asked questions
What is the difference between SSE-S3 and SSE-KMS in Amazon S3?
SSE-S3 encrypts objects with keys that S3 manages, at no extra cost, but gives you no key policy and no CloudTrail record of key use. SSE-KMS encrypts with an AWS KMS key: every use is logged in CloudTrail, and with a customer managed key you control the key policy, rotation and cross-account sharing. SSE-KMS callers need KMS permissions (kms:Decrypt to read, kms:GenerateDataKey to write), and high-volume buckets should enable S3 Bucket Keys to reduce KMS requests and cost.
Why does AWS KMS Encrypt fail for large files, and what should I use instead?
The KMS Encrypt operation accepts at most 4 KB of plaintext. For larger data, use envelope encryption: call GenerateDataKey, encrypt the data locally with the returned plaintext data key, store the encrypted data key (CiphertextBlob) with the ciphertext and discard the plaintext key. To decrypt, call KMS Decrypt on the stored data key. The AWS Encryption SDK implements this pattern for you.
When should I use client-side encryption instead of server-side encryption on AWS?
Use client-side encryption when the plaintext must never reach the AWS service, or when people with full permissions on the data store (for example DynamoDB or S3 administrators) must not be able to read certain data. Encrypt in the application with the AWS Encryption SDK, or the AWS Database Encryption SDK for individual DynamoDB attributes, and grant kms:Decrypt only to the components allowed to see the plaintext. Server-side encryption decrypts transparently for anyone the service authorises.
Why does KMS Decrypt return InvalidCiphertextException when IAM allows kms:Decrypt?
The usual cause is an encryption context mismatch. If data was encrypted with an encryption context, such as a tenant ID, Decrypt succeeds only when the caller passes exactly the same key-value pairs. Supplying the original encryption context fixes it; changing IAM permissions or the algorithm does not. Corrupted or truncated ciphertext produces the same error.
How do I share SSE-KMS encrypted S3 objects with another AWS account?
The objects must be encrypted with a customer managed KMS key, because the key policy of the AWS managed key aws/s3 cannot be edited to admit another account. The key policy in the owning account must allow the other account kms:Decrypt, the role in the other account needs an IAM policy allowing kms:Decrypt on the key's full ARN (not an alias), and the bucket policy must allow s3:GetObject. Existing aws/s3 objects must be re-encrypted under the customer managed key.
Why can't I select my ACM certificate in CloudFront?
Amazon CloudFront only uses certificates stored in AWS Certificate Manager in the us-east-1 (N. Virginia) Region. ACM certificates are Regional and are not copied between Regions, so a certificate requested in any other Region never appears in the distribution's list. Request or import a certificate for the same domain in us-east-1.
Should I use AWS Secrets Manager or Parameter Store for database passwords?
Use AWS Secrets Manager when the password must rotate automatically: it supports managed rotation (for example RDS-managed master user passwords) and rotation Lambda functions, plus cross-Region replication. Parameter Store SecureString parameters are encrypted with KMS and cost less, but have no built-in rotation, so they suit static secrets and configuration. Either way, cache values in your application or with the Parameters and Secrets Lambda Extension rather than calling the API on every request.
Does a CloudWatch Logs data protection policy mask logs that were already written?
No. A CloudWatch Logs data protection policy masks sensitive data only in log events ingested after the policy is applied; earlier events keep their original values and must be deleted or allowed to expire through retention if they cannot remain. Principals with the logs:Unmask permission can view the original values of masked events, which lets selected engineers see real data while other readers see it masked.
Source
This lesson covers the "Security" domain of the official DVA-C03 exam guide. Vendors revise their guides — check the source for the current version.
- AWS Certified Developer – Associate (DVA-C03) exam guide — Amazon Web Services
Sign up free to mark lessons complete, bookmark topics and track your exam readiness.