Here's a comparison of Amazon S3 Default Encryption vs. Bucket Policies, focusing on their purpose, scope, and use cases:
Amazon S3 – Default Encryption
Feature |
Description |
Purpose |
Automatically encrypts objects when they are uploaded to
the bucket, ensuring compliance with encryption-at-rest requirements. |
Applies
To |
Every new object uploaded to the bucket after default
encryption is configured. |
Control
Level |
Bucket-level
setting – applies encryption automatically to all objects in the bucket. |
Supported
Encryption Methods |
SSE-S3 (AES-256), SSE-KMS (AWS Key Management Service) |
Use
Case |
Ensures that all data stored in S3 is encrypted without
needing each upload request to explicitly specify encryption headers. |
Limitations |
Doesn't prevent unencrypted uploads if you’re not using
bucket policies; encryption is automatic but not enforced by default if
clients specify their own encryption. |
Auditability |
Encryption status is visible in object metadata. Combined
with CloudTrail for audit logs. |
Amazon S3 – Bucket Policies
Feature |
Description |
Purpose |
Define fine-grained access control rules for who can
perform what actions on the bucket and its contents. |
Applies
To |
IAM principals (users, roles, accounts), request
conditions, actions (e.g., GetObject, PutObject) |
Control
Level |
IAM
policy-style JSON document attached to the bucket – highly
customizable. |
Use
Case |
Restrict access to specific IPs, enforce MFA, require
HTTPS, enforce encryption policies (e.g.,
deny unencrypted uploads) |
Example
Security Enforcement |
You can write a bucket policy to deny all |
Auditability |
Changes can be tracked using AWS CloudTrail. Can be
combined with AWS Config for compliance tracking. |
Best
Practice: Use Both Together
Combine Them For |
Benefit |
Default
Encryption + Bucket Policy |
Ensures automatic
encryption and enforces
encryption compliance via policy. |
Default
Encryption |
Handles cases where the user doesn’t specify encryption –
ensures data is still encrypted. |
Bucket
Policy |
Can reject
uploads if the correct encryption method is not used (e.g.,
mandate SSE-KMS). |
Example Bucket Policy to Enforce SSE-KMS
# json
{
"Version":
"2012-10-17",
"Statement":
[
{
"Sid":
"DenyUnEncryptedObjectUploads",
"Effect":
"Deny",
"Principal":
"*",
"Action":
"s3:PutObject",
"Resource":
"arn:aws:s3:::twteh-s3bucke/*",
"Condition":
{
"StringNotEquals":
{
"s3:x-amz-server-side-encryption":
"aws:kms"
}
}
}
]
}
No comments:
Post a Comment