Sub topic 8
Your duties for data protection and encryption
This chapter covers the data-protection duties that stay with you under the shared responsibility model. It assumes you know the basics of EC2, S3, and IAM, and that you can read a short AWS CLI command. It also assumes you know what symmetric encryption and TLS are. AWS supplies the encryption features and the key infrastructure. You decide whether to use them, which keys to use, and who may use those keys.
Where the line falls for data
AWS protects the systems that store your data. It secures the facilities, the hardware, and the virtualization layer. It also operates the KMS hardware security modules that hold key material. AWS does not decide what your data is, how sensitive it is, or who should read it. Those decisions are yours for every service, whether it is infrastructure, container, or abstracted.
Your data-protection duties fall into six groups:
- Classify the data so you know what needs protection.
- Choose and enable encryption at rest.
- Enforce encryption in transit.
- Manage keys and decide who can use them.
- Control retention, backup, and deletion.
- Verify that all of this stays configured.
Classify before you protect
Encryption choices depend on how sensitive the data is. Define a small set of tiers, for example public, internal, confidential, and regulated. Record each tier's requirements, such as which key type to use and how long to keep the data.
Tag resources with their tier so that tooling can act on it. A tag such as data-classification=confidential lets you write Config rules, IAM conditions, and cost reports against it. Amazon Macie can scan S3 buckets for sensitive data such as personal information, and it helps find data that is in the wrong tier. Macie reports what it finds. Acting on the findings is your job.
Encryption at rest: what is on by default and what is not
Defaults differ by service. Do not assume "AWS encrypts it" without checking the service.
| Data store | Default behavior | Your duty |
|---|---|---|
| S3 | New objects are encrypted with SSE-S3 automatically. | Switch to SSE-KMS when you need key-level access control and audit. |
| EBS | Volumes are unencrypted unless you request encryption or enable account-level default. | Turn on encryption by default per Region. |
| RDS | Instances are unencrypted unless you enable encryption at creation. | Enable at creation. Existing instances need a snapshot-copy migration. |
| DynamoDB | Always encrypted at rest with an AWS owned key. | Choose an AWS managed or customer managed key if you need more control. |
EBS: enable encryption by default
Account-level default encryption makes every new volume and snapshot copy in a Region encrypted. The setting is per Region, so repeat it for each Region you use.
aws ec2 enable-ebs-encryption-by-default --region us-east-1
aws ec2 get-ebs-encryption-by-default --region us-east-1The second command should return "EbsEncryptionByDefault": true. Existing volumes stay unencrypted. The setting only affects new ones.
S3: choose the encryption mode
S3 supports four approaches:
- SSE-S3: S3 manages the keys. It is the default, and it costs nothing extra.
- SSE-KMS: A KMS key encrypts the data. Every use of the key appears in CloudTrail, and the key policy adds a second access check.
- SSE-C: You supply the key with each request. AWS does not store it. Lose the key and you lose the data.
- Client-side encryption: You encrypt before upload. AWS only ever sees ciphertext.
This command sets SSE-KMS as the bucket default. It uses a customer managed key behind the alias alias/app-data. Bucket Keys reduce the number of calls to KMS, which lowers cost.
aws s3api put-bucket-encryption \
--bucket amzn-s3-demo-bucket \
--server-side-encryption-configuration '{
"Rules": [{
"ApplyServerSideEncryptionByDefault": {
"SSEAlgorithm": "aws:kms",
"KMSMasterKeyID": "alias/app-data"
},
"BucketKeyEnabled": true
}]
}'RDS: encryption is a creation-time choice
You cannot switch encryption on for a running unencrypted RDS instance. The migration path is to snapshot, copy the snapshot with a KMS key, and restore from the encrypted copy:
aws rds create-db-snapshot \
--db-instance-identifier orders-db \
--db-snapshot-identifier orders-db-plain
aws rds copy-db-snapshot \
--source-db-snapshot-identifier orders-db-plain \
--target-db-snapshot-identifier orders-db-encrypted \
--kms-key-id alias/app-data
aws rds restore-db-instance-from-db-snapshot \
--db-instance-identifier orders-db-v2 \
--db-snapshot-identifier orders-db-encryptedWait for each snapshot to reach the available state before the next step. Then repoint your application and delete the old instance and the unencrypted snapshot. Leaving that snapshot behind keeps a plaintext copy of your data.
Encryption in transit
AWS endpoints support TLS. Whether your clients and policies require it is up to you. Three common enforcement points:
- S3: deny any request that does not use TLS with a bucket policy condition.
- RDS: require SSL through the parameter group. The parameter is
rds.force_sslfor PostgreSQL andrequire_secure_transportfor MySQL. - Load balancers: use HTTPS listeners with a current TLS security policy, and redirect HTTP to HTTPS.
Save this policy as tls-only.json:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "DenyInsecureTransport",
"Effect": "Deny",
"Principal": "*",
"Action": "s3:*",
"Resource": [
"arn:aws:s3:::amzn-s3-demo-bucket",
"arn:aws:s3:::amzn-s3-demo-bucket/*"
],
"Condition": {
"Bool": { "aws:SecureTransport": "false" }
}
}
]
}Then apply it:
aws s3api put-bucket-policy \
--bucket amzn-s3-demo-bucket \
--policy file://tls-only.jsonput-bucket-policy replaces the whole policy. If the bucket already has a policy, merge this statement into it first.
Key management
KMS offers three kinds of keys, and the choice changes how much control you have.
| Key type | Who manages it | Policy control | Typical use |
|---|---|---|---|
| AWS owned key | AWS, invisible to you | None | Service defaults such as DynamoDB. |
| AWS managed key | AWS, visible in your account | Fixed by the service | Quick encryption with CloudTrail visibility. |
| Customer managed key | You | Full key policy, grants, rotation, disabling | Regulated data, cross-account sharing, strict audit needs. |
AWS secures the KMS service and the HSMs. Everything around a customer managed key is yours:
- Key policy. The key policy is the primary access document for a key. If it does not allow access, IAM policies alone cannot grant it unless the key policy delegates to IAM. Review who can administer the key and who can use it. Keep those as separate roles.
- Rotation. Automatic rotation for customer managed symmetric keys is off until you enable it. Rotation changes the backing key material. The key ID and ARN stay the same, so applications are unaffected.
- Deletion. Scheduling key deletion has a waiting period of 7 to 30 days. After the key is deleted, everything encrypted under it is unrecoverable. Prefer disabling a key to deleting it.
aws kms enable-key-rotation \
--key-id alias/app-data \
--rotation-period-in-days 365
aws kms get-key-rotation-status --key-id alias/app-dataBackup, retention, and deletion
AWS makes S3 and EBS durable, which means hardware failure rarely loses data. Durability does not protect you from your own mistakes or from an attacker with delete permissions. These duties stay with you:
- Enable S3 versioning, and add Object Lock for data that must not be altered.
- Schedule backups with AWS Backup and copy them to a second account or Region for critical data.
- Set lifecycle rules so data is deleted when your retention policy says it should be. Keeping data longer than needed is also a risk.
- Encrypt backups. A snapshot of an encrypted volume is encrypted, but a backup of unencrypted data is not.
Verify your side
Use AWS Config managed rules to detect drift. Useful ones for this chapter are encrypted-volumes, rds-storage-encrypted, s3-bucket-server-side-encryption-enabled, and s3-bucket-ssl-requests-only. List the rules that currently report non-compliant resources:
aws configservice describe-compliance-by-config-rule \
--compliance-types NON_COMPLIANTConfig only evaluates rules you have deployed, and it only records resource types you have enabled in the configuration recorder. An empty result can mean "all compliant" or "nothing is being checked." Confirm that the rules exist before you trust a clean report.
Common errors
- Assuming defaults match your policy. S3 encrypts new objects by default, but a regulated tier may require SSE-KMS with your own key.
- Forgetting that EBS defaults are per Region. A new Region starts with default encryption off.
- Leaving old plaintext copies. Unencrypted snapshots, AMIs, and exported files persist after a migration.
- Overbroad key policies. A key policy that grants
kms:*to the whole account root effectively delegates control to IAM, so any IAM administrator can use the key. - Cross-account surprises. Sharing an encrypted snapshot requires sharing the customer managed key too. AWS managed keys cannot be shared.
- Encryption mistaken for access control. Encryption at rest protects against media theft and some misconfigurations. It does not stop an authorized principal from reading data through the service.
Exercise
Your team has an unencrypted RDS instance holding confidential data. A teammate proposes running a command to turn on encryption for the running instance. What do you tell them, and what are the steps you take instead? Name one leftover item that you must also remove.
Show answer
RDS encryption cannot be enabled on an existing instance. Create a snapshot, copy it with a KMS key (for example a customer managed key) to produce an encrypted snapshot, restore a new instance from that copy, repoint the application, and delete the old instance. Also delete the original unencrypted snapshot, since it still holds a plaintext copy of the data.
Exercise
A Config report shows no non-compliant resources for encryption, yet an auditor finds an unencrypted EBS volume in eu-west-1. Give two possible reasons.
Show answer
The encrypted-volumes rule may not be deployed in eu-west-1, because Config rules and the configuration recorder are set up per Region. Alternatively, the recorder may not be recording EBS volumes, so the rule has nothing to evaluate. Account-level EBS default encryption also applies only to new volumes, so a volume created before it was enabled stays unencrypted.