S3 Bucket Policy to Enforce HTTPS and Encryption — Best Practices
Exhibit
Refer to the exhibit.
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Deny",
"Principal": "*",
"Action": "s3:*",
"Resource": "arn:aws:s3:::example-bucket/*",
"Condition": {
"Bool": {
"aws:SecureTransport": "false"
}
}
},
{
"Effect": "Allow",
"Principal": "*",
"Action": [
"s3:GetObject",
"s3:PutObject"
],
"Resource": "arn:aws:s3:::example-bucket/*",
"Condition": {
"StringEquals": {
"s3:x-amz-server-side-encryption": "AES256"
}
}
}
]
}A data engineer applies the bucket policy shown in the exhibit to an S3 bucket. The bucket contains sensitive data that must be encrypted at rest and accessed only over HTTPS. Which of the following statements is true?
Quick Answer
The correct answer is that the policy enforces that all PutObject requests must include the x-amz-server-side-encryption header with value AES256. This is because the bucket policy uses a Deny effect with a condition key of `s3:x-amz-server-side-encryption`, explicitly blocking any upload that lacks the header set to `AES256`, thereby mandating server-side encryption with S3-managed keys (SSE-S3) for data at rest. On the AWS Certified Data Engineer Associate DEA-C01 exam, this scenario tests your ability to read S3 bucket policy conditions and distinguish between enforcing encryption in transit (HTTPS) versus at rest (SSE). A common trap is confusing the `aws:SecureTransport` condition for HTTPS with the `s3:x-amz-server-side-encryption` condition; remember that HTTPS enforcement uses a separate Boolean condition. Memory tip: “AES256 for the file, HTTPS for the aisle” — the header locks the object’s content, while the transport condition secures the upload path.
⚠ Common exam trap
AWS often tests the distinction between SSE-S3 (`AES256`) and SSE-KMS (`aws:kms`) in bucket policy conditions, and candidates may mistakenly think the policy requires KMS when it actually specifies AES256.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
The policy enforces that all PutObject requests must include the x-amz-server-side-encryption header with value AES256.
The bucket policy includes a condition that denies PutObject requests unless the `s3:x-amz-server-side-encryption` header is present and set to `AES256`. This enforces server-side encryption with S3-managed keys (SSE-S3) for all uploads, ensuring data at rest is encrypted.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
The policy allows both HTTP and HTTPS access.
Why it's wrong here
The Deny statement blocks requests that do not use SecureTransport, so only HTTPS is allowed.
- ✗
The policy allows anonymous access to list objects in the bucket.
Why it's wrong here
The Allow statement only grants GetObject and PutObject, not ListBucket, so anonymous listing is not allowed.
- ✓
The policy enforces that all PutObject requests must include the x-amz-server-side-encryption header with value AES256.
Why this is correct
The Allow statement requires the condition s3:x-amz-server-side-encryption equals AES256 for PutObject.
- ✗
The policy requires the use of AWS KMS for server-side encryption.
Why it's wrong here
The policy specifies AES256, which is SSE-S3, not KMS.
Quick reference
AWS S3 Storage Class Comparison
| Storage Class | Min Duration | Retrieval | Use Case |
|---|---|---|---|
| S3 Standard | None | Immediate | Frequently accessed data |
| S3 Standard-IA | 30 days | Immediate | Infrequent access, rapid retrieval |
| S3 One Zone-IA | 30 days | Immediate | Non-critical infrequent data |
| S3 Intelligent-Tiering | None | Immediate–hours | Unknown or changing access patterns |
| S3 Glacier Instant | 90 days | Milliseconds | Archive with instant retrieval |
| S3 Glacier Flexible | 90 days | Minutes–hours | Archive, flexible retrieval |
| S3 Glacier Deep Archive | 180 days | Hours | Long-term compliance archive |
Go deeper
Related to this question
About these practice questions
One of 1,711 original DEA-C01 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →
Same concept, more angles
5 more ways this is tested on DEA-C01
These questions test the same concept from different angles. Work through them to make sure you can recognise it however the exam phrases it.
Variation 1. Refer to the exhibit. A data engineer applies this bucket policy to an S3 bucket. A user within the 10.0.0.0/24 IP range attempts to upload an object to the bucket using an HTTP (non-HTTPS) request. What is the outcome?
hard- A.The upload succeeds because the Allow statement grants permission.
- B.The upload succeeds because the user's IP is allowed.
- C.The upload fails because the user's IP is not in the allowed range for PutObject.
- ✓ D.The upload fails because the request is not using HTTPS.
Why D: The bucket policy includes a condition `aws:SecureTransport` set to `false`, which explicitly denies any request that does not use HTTPS. Since the user is making an HTTP (non-HTTPS) request, the Deny statement overrides any Allow statement, causing the upload to fail. The correct answer is D.
Variation 2. Refer to the exhibit. A data engineer has attached this bucket policy to an S3 bucket. What is the effect of this policy?
hard- A.It enforces server-side encryption for all objects written to the bucket.
- ✓ B.It allows the DataLakeRole to read and write objects, but only over HTTPS.
- C.It allows anonymous access to the bucket for HTTPS requests.
- D.It denies all access to the bucket except for requests from the DataLakeRole.
Why B: The bucket policy uses a condition key `aws:SecureTransport` set to `true`, which restricts access to HTTPS (TLS) connections only. The `Principal` is `DataLakeRole`, and the `Action` includes `s3:GetObject` and `s3:PutObject`, so the policy allows that role to read and write objects exclusively over HTTPS, enforcing encrypted data in transit.
Variation 3. Refer to the exhibit. A data engineer has attached this bucket policy to an S3 bucket named data-lake-bucket. The engineer wants to allow only GET requests from the corporate network (10.0.0.0/16) over HTTPS. However, users report that they cannot access objects even when connected to the corporate network. What is the issue?
hard- A.The Deny statement should include a condition on the source IP.
- B.The Allow statement should include a condition for SecureTransport.
- C.The Allow statement should specify s3:GetObject instead of s3:GetObject.
- ✓ D.The Deny statement blocks all requests that are not using HTTPS, including those from the corporate network.
Why D: The Deny statement with `aws:SecureTransport` set to `false` blocks all HTTP requests. Since the Allow statement only permits GET requests from the corporate network (10.0.0.0/16) but does not require HTTPS, any request from that network that uses HTTP is denied by the explicit Deny. The Deny statement overrides the Allow, so even legitimate corporate users are blocked if they use HTTP.
Variation 4. A data engineer reviews this IAM policy attached to an S3 bucket. What is the effect of this policy?
medium- A.Denies PutObject when encryption is not SSE-KMS.
- B.Denies all PutObject requests.
- ✓ C.Allows PutObject only when the object is encrypted with SSE-KMS.
- D.Allows PutObject only when the object is NOT encrypted with SSE-KMS.
Why C: The IAM policy uses a Deny effect with a StringNotEquals condition on s3:x-amz-server-side-encryption for aws:kms. This means that if the encryption header is anything other than aws:kms (i.e., not SSE-KMS), the request is denied. The net effect is that PutObject is allowed only when the object IS encrypted with SSE-KMS.
Variation 5. An IAM policy is attached to a user who tries to upload an object to the S3 bucket example-bucket using the AWS CLI without specifying the --server-side-encryption flag. What will happen?
hard- ✓ A.The upload fails with an AccessDenied error.
- B.The upload succeeds and the object is encrypted with SSE-S3 by default.
- C.The upload fails because the user does not have permission to use KMS.
- D.The upload succeeds because the policy allows s3:PutObject.
Why A: The IAM policy denies s3:PutObject unless the request includes the `x-amz-server-side-encryption` header with a value of `AES256`. Since the user did not specify `--server-side-encryption` in the AWS CLI command, the request lacks this required header, causing S3 to evaluate the policy and return an AccessDenied error. The upload fails before any default encryption setting on the bucket is applied.
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This DEA-C01 practice question is part of Courseiva's free Amazon Web Services certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the DEA-C01 exam.