Task 1.3 · 22 min read
Data Security Controls
Services in this lesson
- AWS KMSin scope
- AWS Certificate Manager (ACM)in scope
- Amazon S3in scope
- AWS Backupin scope
- Amazon Maciein scope
- Amazon RDSin scope
What the exam tests
- Whether you pick the right key type. An AWS managed key suits data nobody needs to control. A customer managed key suits data whose key policy, rotation or disablement you must control.
- Whether you know that a key policy grants access that an IAM (Identity and Access Management) policy alone can't.
- Whether you protect data in transit with TLS (Transport Layer Security, the encryption behind HTTPS). That means ACM (AWS Certificate Manager) public certificates on load balancers and CloudFront, and policies that refuse plain requests. ACM renews them automatically with DNS validation (proving you own the domain through a DNS record).
- Whether you know what key rotation does. It changes the key material (the secret value inside the key) for new data, and it never re-encrypts old data.
- Whether you stop accidental exposure at the right layer. S3 Block Public Access is an account- or bucket-level switch that refuses public bucket policies and ACLs (access control lists). Amazon Macie scans S3 for sensitive data, such as personal data, that you didn't know you had.
- Whether you match retention and recovery to the requirement: Object Lock modes, legal hold (a lock with no end date), lifecycle expiration, versioning and replication. AWS Backup stores copies, called recovery points, in a vault, and vault lock protects them from deletion.
The core concept
Data security has three jobs. Keep data unreadable to the wrong people, keep it from being changed or deleted when it must not be, and keep a usable copy when something breaks.
Each job has its own AWS control. Exam questions usually describe one job and offer controls for the other two as distractors.
An analogy: a self-storage facility
Picture a self-storage facility that keeps your boxes of paperwork:
- Every box has its own lock and key. That box key is a data key, and each object gets its own.
- You seal each box key in an envelope taped to the box, and only the manager's master seal opens envelopes. That seal is a KMS key in AWS KMS (Key Management Service).
- A list at the manager's desk says who may ask for an envelope to be opened. That's the key policy.
- Some boxes sit in a unit with a time lock that nobody, not even the owner, can open before a set date. That's S3 Object Lock in compliance mode.
- You keep copies of key papers at a second facility across town. Those are replication and backups.
Where the analogy breaks: the real KMS key never leaves KMS, and only the sealed data key sits beside the object. Replication also sends mistakes to the second site automatically.
Follow one file through it
The diagram shows the three jobs side by side. The walkthrough below follows one file through it.
Lena runs the export job for a clinic. Her application in the production account (111122223333) uploads a patient export to an S3 bucket named clinic-exports.
- The upload travels over HTTPS. S3's own endpoint already speaks TLS, and a bucket policy that denies requests where
aws:SecureTransportisfalsemakes TLS mandatory. If the upload goes through the clinic's own endpoint, an Application Load Balancer (ALB) or a CloudFront custom domain, that endpoint's ACM certificate covers the client-to-endpoint hop. - S3 encrypts the object with SSE-KMS. SSE-KMS is server-side encryption with a KMS key. The object gets its own data key, and S3 encrypts the file with it.
- The KMS key protects only the data key. KMS generates the data key that S3 uses, plus a copy encrypted under the KMS key. S3 stores that encrypted copy next to the object, and the file itself never goes to KMS: this is envelope encryption.
- The key policy gates every use. Before KMS generates or decrypts a data key, it checks the key policy. If neither the key policy nor an IAM policy it delegates to allows Lena's role, the upload or later read fails.
- Object Lock protects the version. The bucket keeps versions, and a default retention period in compliance mode locks each new one. Deleting that version before the date fails.
- One copy leaves production's reach. Replication copies the object to a bucket in another Region, which can stay in the same account. AWS Backup copies its recovery points from a locked vault to a locked vault in a separate account, out of production's reach.
Now suppose an attacker steals an administrator's credentials. They can't delete the locked versions, because compliance mode stops every user. They can't erase the AWS Backup copies in the other account's locked vault either.
Whether they can read the data depends on the key policy. A key policy that delegates to the account's IAM policies lets an IAM administrator decrypt, which is why you keep it narrow.
The rules the exam tests
- Match the control to the job. The key policy guards reading. Object Lock and vault lock guard deletion. Replication and backup guard against loss.
- A KMS key protects data keys, not whole data sets. That's why one key can protect gigabytes of S3 objects.
- The key policy comes first. Without its allow, an IAM policy that allows
kms:Decryptgrants nothing. - Compliance mode is final. No user, including the root user, can shorten or remove it before retention ends. Governance mode can be bypassed.
- Rotation changes the key material for new data. It never re-encrypts old data.
- A legal hold has no end date. It stays until someone removes it.
- A copy is not a lock. Replication mirrors every change, damage included. AWS Backup keeps dated recovery points, so you can restore from before the damage.
A question about stopping an admin from deleting a locked file is not a KMS question. A question about decrypting a file is not an Object Lock question.
The walkthrough used a customer managed key. Here is how it differs from the other key options.
Which key: AWS managed or customer managed?
- An AWS managed key is created by AWS for one service in your account, such as
aws/s3. AWS sets its key policy and rotation, and you can't edit or disable it. - A customer managed key is one you create in KMS. You write its key policy, choose its rotation, and can disable it or schedule its deletion.
- SSE-S3 (server-side encryption with S3 managed keys) is the default for every S3 bucket. It needs no KMS key at all.
Deep diveRotation: what it changes and what it doesn't
Automatic rotation works on customer managed symmetric keys. The default period is one year, and you can set a custom period from 90 to 2,560 days. AWS managed keys rotate on AWS's own schedule, which you can't change.
Rotation creates new key material for new encryption. It keeps the old material, so existing data still decrypts.
Rotation doesn't re-encrypt existing ciphertext (encrypted data), and it doesn't fix a leaked data key. If a data key may be exposed, re-encrypt the data separately.
Deep diveMulti-Region keys
A multi-Region key is a KMS key with the same key material and key ID as a related key in another Region. Data encrypted in one Region can be decrypted in the other. You don't re-encrypt it or make a cross-Region call to KMS.
Pick one when data is encrypted in one Region and must be decrypted or processed in another. Typical cases are a disaster recovery failover or an active-active design. Keep a single-Region key otherwise.
You create and manage each multi-Region key yourself. S3 replication still re-encrypts objects under the destination Region's key.
Decision guide
| If the question says… | Reach for… | Because… |
|---|---|---|
| "encrypt with our own key", "disable the key", "auditors review the key policy" | A customer managed KMS key with a key policy you write | You can't edit, disable or change rotation of an AWS managed key |
| "encrypt S3 objects with no key management effort", "no key policy to maintain" | SSE-S3 (the S3 default) or an AWS managed key | SSE-S3 needs no KMS key. An AWS managed key needs no policy from you. |
| "another account must decrypt our data" | A key policy allowing the other account's role, plus that role's IAM policy | Cross-account use needs both sides. IAM can't grant what the key policy doesn't allow |
| "rotate the key every year", "rotate on a schedule shorter than a year" | Automatic rotation on a customer managed symmetric key, custom period 90 to 2,560 days | New key material for new data. Old material still decrypts existing data |
| "encrypt an existing unencrypted RDS instance" | Snapshot, copy the snapshot with encryption on, restore from the copy | RDS (Relational Database Service) sets encryption only at creation |
| "HTTPS for a public site on an ALB or CloudFront", "free certificate that renews itself" | An ACM public certificate, validated by DNS, on the integrated service | Renews automatically while the DNS record stays. No charge on integrated services |
| "never public, even after a future bucket policy" | S3 Block Public Access at the account level | Overrides bucket policies and ACLs on every bucket, including future ones |
| "find which buckets hold personal data or card numbers" | Amazon Macie sensitive data discovery | Macie inspects objects and reports the buckets, so you write no scanner |
| "nobody can delete for seven years, not even root" | S3 Object Lock in compliance mode with a retention period | Nobody, including root, can shorten or remove it until retention ends |
| "protect a file during an investigation, with no end date" | An S3 Object Lock legal hold | Stays until removed. Needs no retention period |
| "admins may fix mistakes, but deletes must be recoverable" | S3 versioning plus Object Lock governance mode | Blocks normal users; a few roles keep a documented way back |
| "backups that an attacker or admin can't delete" | AWS Backup vault lock in compliance mode, with minimum and maximum retention | Once final, no user or AWS can delete recovery points or shorten retention |
| "isolate backups from the production account" | An AWS Backup copy job to a vault in another account, with a customer managed KMS key | A compromise of production can't reach the copies |
| "replicate objects to another Region or account" | S3 Cross-Region Replication or cross-account replication, versioning on both buckets | Replication requires versioning on source and destination |
| "delete objects after N days", "remove old versions after 90 days" | An S3 Lifecycle expiration rule, with noncurrent (older) version expiration | Runs on schedule with no script. It's a cleanup rule, not a lock |
| "all requests must use HTTPS", "refuse plain HTTP" | A bucket policy that denies requests where aws:SecureTransport is false | The key is false without TLS, and the deny beats every allow |
Deep diveCross-account details for backups and replication
AWS Backup requires a customer managed KMS key on the destination vault for cross-account copies of resources it doesn't fully manage.
Cross-account replication of SSE-KMS objects needs a customer managed key. Its key policy must let the source bucket owner use it. AWS managed keys don't allow cross-account use.
Lifecycle expiration is not a lock. Without Object Lock, a user with delete permission can still remove an object before it expires.
Correct pattern
REFERENCE PATTERN: a bucket for regulated customer exports. It uses a customer managed key, can never be public, keeps every version, locks each object for seven years, and sends a copy to a second Region.
1. Key policy. This is the first gate. It must name the account so that IAM policies can grant use of the key later.
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AccountAdministratorsAndIamPolicies",
"Effect": "Allow",
"Principal": { "AWS": "arn:aws:iam::111122223333:root" },
"Action": "kms:*",
"Resource": "*"
}
]
}
Here :root means the whole account, not that every user gets full access. It hands the decision to the account's IAM policies. In production, keep the key policy narrow, for example by naming the data-owning application's role.
2. The bucket, with versioning and Object Lock. Create the bucket first, because every later setting needs it to exist. Turning Object Lock on at creation also turns versioning on, since Object Lock works only on versioned buckets.
The default retention below applies to every new object.
aws s3api create-bucket --bucket <your-bucket-name> --region <region> \
--create-bucket-configuration LocationConstraint=<region> \
--object-lock-enabled-for-bucket
aws s3api put-object-lock-configuration --bucket <your-bucket-name> \
--object-lock-configuration '{"ObjectLockEnabled":"Enabled","Rule":{"DefaultRetention":{"Mode":"COMPLIANCE","Years":7}}}'
3. Bucket encryption and blocked public access. Turn on all four Block Public Access settings. Set SSE-KMS as the bucket default with an S3 Bucket Key, which cuts KMS requests for busy buckets.
aws s3api put-public-access-block --bucket <your-bucket-name> \
--public-access-block-configuration \
BlockPublicAcls=true,IgnorePublicAcls=true,BlockPublicPolicy=true,RestrictPublicBuckets=true
aws s3api put-bucket-encryption --bucket <your-bucket-name> \
--server-side-encryption-configuration '{"Rules":[{"ApplyServerSideEncryptionByDefault":{"SSEAlgorithm":"aws:kms","KMSMasterKeyID":"<your-key-arn>"},"BucketKeyEnabled":true}]}'
4. Replication to a second Region. Replication needs versioning on both buckets. If the source uses Object Lock, the destination must too, so the copy gets the same protection.
5. Backup on top. An AWS Backup plan stores recovery points in a vault locked in compliance mode. A copy rule sends them to a vault in another account.
Replication keeps a live copy. Backup keeps dated recovery points you can restore from, which is a different job.
Read the pattern from the outside in:
- No policy or ACL can make the bucket public while Block Public Access is on.
- Every object is encrypted under a key whose use the key policy controls.
- Every version is locked in compliance mode, so deleting a locked version before its date fails.
- Replication keeps a copy in a second Region. The AWS Backup copy in another account's locked vault is the one production can't erase.
Compliance mode is final, so a retention period set wrong can't be shortened. Test with governance mode first.
Traps
| The trap | Why it fails | Correct pattern |
|---|---|---|
Granting kms:Decrypt in a role's IAM policy and expecting cross-account use | KMS checks the key policy first. It looks right because IAM policies work everywhere else | Add the role to the key policy and keep the IAM policy as the role's grant |
| Choosing an AWS managed key as "simpler" when auditors must control and disable it | You can't edit its key policy or disable it. The simplicity is real; the control isn't | A customer managed key with a key policy you write |
| Expecting rotation to re-encrypt old data | Existing ciphertext isn't rewritten, and rotation doesn't fix a leaked data key | Rotate for key hygiene; re-encrypt data separately if a data key leaks |
| Governance mode for "no one may delete for seven years" | Users with s3:BypassGovernanceRetention can still delete | Compliance mode |
| Expecting a legal hold to end with the investigation | A legal hold never expires, so data can stay locked longer than policy says | Remove the hold when the matter closes; use retention for time-based rules |
| A public-read bucket policy, expected to win because it's more specific | Block Public Access, at account or bucket level, overrides the public policy | Keep it on; serve public content through CloudFront with origin access control |
| Running a standard ACM public certificate on your own server | It works only with integrated services and can't be exported | Use it on the ALB or CloudFront, or request an exportable certificate |
| Requesting a CloudFront certificate in the wrong Region | CloudFront reads certificates only from US East (N. Virginia) | Request it in US East (N. Virginia) |
| Enabling encryption on a running RDS instance by flipping a setting | RDS sets encryption only at creation | Snapshot, copy with encryption on, restore a new instance |
| Calling recovery points immutable under vault lock governance mode | Users with the right permissions can remove a governance lock | Vault lock in compliance mode, with deliberate minimum and maximum retention |
| Treating replication as a backup | Overwrites and mistakes replicate too, including ransomware overwrites | Keep versions, Object Lock and backups; replicate for availability |
Deep diveExportable ACM public certificates
An exportable public certificate can run on your own server. It has a 198-day validity, and ACM renews it 45 days before expiry. You must deploy each renewal yourself.
Request it with DNS validation. It's billed at issuance and again at each renewal, so check the ACM pricing page for current rates.
A standard public certificate requested for an integrated service has no charge.
Deep diveWhat replication copies, and what it doesn't
Replication copies new writes and overwrites. It copies a delete marker (the placeholder S3 adds when you delete an object in a versioned bucket) only when delete marker replication is on.
A delete of a specific version ID doesn't replicate, so the copy keeps that version. An overwrite still replicates, which is why replication isn't a backup.
Compare
| Characteristic | AWS managed key | Customer managed key |
|---|---|---|
| Created by | AWS, for one service (for example aws/s3) | You, in KMS |
| Key policy | Set by AWS; you can't edit it | Written by you, one per key |
| Rotation | Automatic on AWS's schedule; you can't change it | Optional; default one year, custom 90 to 2,560 days |
| Can you disable it | No | Yes; schedule deletion with a 7 to 30 day wait |
| Cross-account use | Not available | Through the key policy |
| Monthly fee | None for the key itself | A fee per key, plus request charges |
| Typical exam cue | "least effort", "no policy to manage" | "control", "audit the key policy", "disable" |
Protections against exposure and deletion differ in who can turn them off:
| Control | Protects against | Who can remove it |
|---|---|---|
| S3 Block Public Access | Public exposure through a policy or ACL | An account or bucket admin who turns it off |
| S3 Object Lock, governance mode | Deletes and overwrites by normal users | Users with s3:BypassGovernanceRetention |
| S3 Object Lock, compliance mode | Deletes and overwrites by every user, root too | Nobody, until retention ends |
| S3 Object Lock legal hold | Deletes and overwrites while the hold is on | A user with s3:PutObjectLegalHold |
| AWS Backup vault lock, compliance mode | Deleting recovery points, shortening retention | Nobody, after the cooling-off period (minimum 72 hours) |
Two confusions need care. Versioning alone doesn't stop deletes: a user with delete permission can remove the current version, and older ones with the right permissions.
AWS Backup and S3 replication also look alike. Replication mirrors every change, damage included. AWS Backup keeps dated recovery points, so you can restore from before the damage.
Worked exam scenario
Exam scenario
A healthcare company exports patient records to Amazon S3 as objects. Auditors require that no user, including the root user, can delete or change any record for 7 years. The company must also encrypt the records with a key it controls and be able to disable that key during an incident. The company wants the least operational overhead. Which solution meets these requirements?
- A.Enable S3 Object Lock in governance mode with a 7-year default retention, and encrypt with SSE-S3.
- B.Enable S3 Object Lock in compliance mode with a 7-year default retention, and encrypt with SSE-KMS using a customer managed key with a key policy the company writes.
- C.Enable S3 versioning and a bucket policy that denies s3:DeleteObject, and encrypt with an AWS managed KMS key.
- D.Enable S3 Cross-Region Replication to a second bucket, and encrypt with SSE-KMS using an AWS managed key.
Show the walkthrough
- Find the requirements. "No user, including the root user" points to compliance mode, and "7 years" to a retention period. "A key it controls" that it can "disable" points to a customer managed key.
- Read the qualifier. "Least operational overhead" means a native feature, not a custom scanner or copy job.
- Eliminate option a. Users with
s3:BypassGovernanceRetentioncan delete under governance mode. SSE-S3 also gives the company no key it controls, so it fails twice. - Eliminate option c. Anyone allowed to edit the bucket policy, including root, can remove the deny, so the records aren't immutable. The company also can't disable an AWS managed key.
- Eliminate option d. Replication is a copy, not a lock. A user with delete permission on the source can still remove a version, and overwrites replicate. An AWS managed key also fails the key-control requirement.
- Land on option b. Compliance mode meets the no-user rule for the retention period, and default retention applies to each new record. The customer managed key meets both key requirements.
Answer: B
Check your understanding
Build it
Do the data security lab. You create a customer managed key with a key policy, and a bucket with Object Lock and SSE-KMS. Then you try to delete a locked version and to make the bucket public, and watch both attempts fail.
Neighboring topics live elsewhere. IAM roles, cross-account access and SCPs that can block KMS actions are in 1.1 Secure access. Security groups, Secrets Manager and WAF are in 1.2 Secure workloads.
Recovery time and recovery point objectives, and choosing a disaster recovery strategy, are in 2.2 High availability. Moving older objects to cheaper storage classes is in 4.1 Storage cost.
Key takeaways
- Use a customer managed KMS key when you must control its key policy, rotation or disablement. Use an AWS managed key when nobody needs that control.
- KMS encrypts data keys, not whole data sets. Cross-account use needs the key policy to allow it; an IAM policy alone never does.
- ACM public certificates on load balancers and CloudFront renew themselves while their DNS validation record stays. CloudFront certificates come from US East (N. Virginia).
- Turn on S3 Block Public Access before you write any bucket policy, and use Macie to find sensitive data you didn't expect.
- Compliance mode stops every user, including root. Governance mode can be bypassed, and a legal hold stays until removed. Lock backup vaults in compliance mode and copy them to another account or Region.
- Match each control to the failure it stops: KMS for who reads, ACM for TLS, Block Public Access before bucket policies, Object Lock against deletes, and locked cross-account backups.
Hands-on lab: Object Lock, Legal Hold and Block Public Access
Sources
- https://docs.aws.amazon.com/kms/latest/developerguide/rotate-keys.html
- https://docs.aws.amazon.com/kms/latest/developerguide/rotating-keys-enable.html
- https://aws.amazon.com/certificate-manager/pricing/
- https://docs.aws.amazon.com/AmazonS3/latest/userguide/replication-what-is-isnot-replicated.html
- https://docs.aws.amazon.com/AmazonS3/latest/userguide/delete-marker-replication.html
- https://docs.aws.amazon.com/kms/latest/developerguide/key-policies.html
- https://docs.aws.amazon.com/kms/latest/developerguide/key-policy-default.html
- https://docs.aws.amazon.com/kms/latest/developerguide/concepts.html
- https://docs.aws.amazon.com/kms/latest/developerguide/multi-region-keys-overview.html
- https://docs.aws.amazon.com/kms/latest/developerguide/deleting-keys-scheduling-key-deletion.html
- https://docs.aws.amazon.com/kms/latest/APIReference/API_Encrypt.html
- https://docs.aws.amazon.com/kms/latest/APIReference/API_GenerateDataKey.html
- https://docs.aws.amazon.com/kms/latest/APIReference/API_ScheduleKeyDeletion.html
- https://docs.aws.amazon.com/kms/latest/cryptographic-details/key-deletion.html
- https://aws.amazon.com/kms/pricing/
- https://docs.aws.amazon.com/AmazonS3/latest/userguide/default-bucket-encryption.html
- https://docs.aws.amazon.com/AmazonS3/latest/userguide/bucket-encryption.html
- https://docs.aws.amazon.com/acm/latest/userguide/gs-acm-request-public.html
- https://docs.aws.amazon.com/acm/latest/userguide/managed-renewal.html
- https://docs.aws.amazon.com/acm/latest/userguide/email-renewal-validation.html
- https://docs.aws.amazon.com/acm/latest/userguide/acm-exportable-certificates.html
- https://docs.aws.amazon.com/acm/latest/userguide/acm-overview.html
- https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/cnames-and-https-procedures.html
- https://docs.aws.amazon.com/AmazonS3/latest/userguide/configuring-block-public-access-account.html
- https://docs.aws.amazon.com/AmazonS3/latest/userguide/access-control-block-public-access.html
- https://docs.aws.amazon.com/AmazonS3/latest/userguide/about-object-ownership.html
- https://docs.aws.amazon.com/macie/latest/user/what-is-macie.html
- https://docs.aws.amazon.com/macie/latest/user/discovery-jobs.html
- https://docs.aws.amazon.com/AmazonS3/latest/userguide/object-lock.html
- https://docs.aws.amazon.com/AmazonS3/latest/userguide/object-lock-configure.html
- https://docs.aws.amazon.com/AmazonS3/latest/userguide/object-lock-managing.html
- https://docs.aws.amazon.com/AmazonS3/latest/API/API_CreateBucket.html
- https://docs.aws.amazon.com/AmazonS3/latest/userguide/lifecycle-expire-general-considerations.html
- https://docs.aws.amazon.com/AmazonS3/latest/userguide/example-bucket-policies.html
- https://docs.aws.amazon.com/acm/latest/userguide/force-certificate-renewal.html
- https://docs.aws.amazon.com/AmazonS3/latest/userguide/replication-requirements.html
- https://docs.aws.amazon.com/AmazonS3/latest/userguide/setting-repl-config-perm-overview.html
- https://docs.aws.amazon.com/AmazonS3/latest/userguide/replication-config-for-kms-objects.html
- https://docs.aws.amazon.com/aws-backup/latest/devguide/vault-lock.html
- https://docs.aws.amazon.com/aws-backup/latest/devguide/cross-region-backup.html
- https://docs.aws.amazon.com/aws-backup/latest/devguide/encryption.html
- https://docs.aws.amazon.com/AWSCloudFormation/latest/TemplateReference/aws-properties-backup-backupvault-lockconfigurationtype.html
- https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Overview.Encryption.html
- https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_CopySnapshot.html
- https://docs.aws.amazon.com/config/latest/developerguide/s3-account-level-public-access-blocks.html
- https://docs.aws.amazon.com/whitepapers/latest/aws-overview/security-services.html
Last reviewed