S3 Bucket Policy Project 5: HTTPS Enforce (aws:SecureTransport)
Gauri Sawant (पुणे) compliance: प्रत्येक S3 call TLS. aws:SecureTransport false → Deny. Browser upgrade लपवतो — curl http:// ने test.
या chapter मध्ये तुम्ही काय शिकाल
- HTTPS enforce का
- SecureTransport JSON
- curl tests
- TLS version
- Interview
1. Story
Dr. Anil Krishnan (चेन्नई) व Jonas Becker (Frankfurt). Auditor: HTTP अजून शक्य आहे का?
2. SecureTransport का?
हे का लागतं?
HTTP = wire leak. SecureTransport false → Deny.
- एक Deny
- सगळे principals
- TLS version वेगळं
- curl http test
3. Policy
हे काय आहे?
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "DenyInsecureTransport",
"Effect": "Deny",
"Principal": "*",
"Action": "s3:*",
"Resource": [
"arn:aws:s3:::rb-secure-uploads-ap-south-1",
"arn:aws:s3:::rb-secure-uploads-ap-south-1/*"
],
"Condition": {
"Bool": { "aws:SecureTransport": "false" }
}
}
]
}
Line-by-line
- Clear Sid.
- Deny.
- *.
- s3:*.
- Both ARNs.
- Non-TLS only.
4. CLI
कसं करायचं (step by step)
aws s3api put-bucket-policy --bucket rb-secure-uploads-ap-south-1 --policy file://https-only.json
# (empty success)
echo secret > t.txt
aws s3 cp t.txt s3://rb-secure-uploads-ap-south-1/t.txt
# upload success over HTTPS CLI
5. Allow/deny
# ALLOW — HTTPS
curl -s -o /dev/null -w "%{http_code}\n" -I \
https://rb-secure-uploads-ap-south-1.s3.ap-south-1.amazonaws.com/t.txt
# 403 without public read is OK for private buckets; use signed HTTPS CLI for content:
aws s3 cp s3://rb-secure-uploads-ap-south-1/t.txt - # works (HTTPS)
# DENY — force HTTP (note: may redirect; use --http1.1 and endpoint that speaks HTTP)
aws s3 cp s3://rb-secure-uploads-ap-south-1/t.txt /tmp/x --no-sign-request --endpoint-url http://s3.ap-south-1.amazonaws.com
# AccessDenied when policy sees SecureTransport=false
6. TLS version
SecureTransport = TLS होते का. TLS 1.2+ pin = CF/ALB policies — फक्त bool नाही.
7. Multi-industry
Healthcare, SaaS, fintech, edtech.
8. AccessDenied debugging आणि Policy Simulator
AccessDenied क्रम: BPA → bucket Deny → IAM Allow → KMS → VPCe → ACL. Simulator BPA/VPC/KMS miss करू शकतो — खऱ्या CLI ने test.
# Decode
aws s3api get-bucket-policy --bucket BUCKET --query Policy --output text | python3 -m json.tool
aws s3api get-public-access-block --bucket BUCKET
aws iam simulate-principal-policy --policy-source-arn ARN \
--action-names s3:GetObject --resource-arns arn:aws:s3:::BUCKET/key.txt
aws cloudtrail lookup-events --lookup-attributes AttributeKey=EventName,AttributeValue=GetObject --max-items 5
9. Lab: HTTPS-only
Org block नसेल तर ap-south-1 (Mumbai). आधी budget alert.
कसं करायचं (step by step)
- Policy on.
- HTTPS allow.
- HTTP deny.
- Evidence.
Cleanup (billing थांबवा)
- Cleanup.
- Empty bucket.
10. सामान्य errors आणि fixes
प्रत्येक row = खरी चूक. Panic करण्याआधी fix वाचा.
| Error / लक्षण | Fix |
|---|---|
| IAM Allow + Deny | Bucket Deny / BPA. |
| JSON reject | json.tool + file://. |
| Simulator ≠ CLI | Real CLI. |
| Wrong ARN | /* vs bare. |
| Condition typo | Exact spelling. |
| Principal | Resource policy needs it. |
| Account BPA | Check account switches. |
| KMS layer | Key policy + IAM. |
| Browser OK? | curl http. |
| TLS pin? | Separate control. |
11. Troubleshooting checklist
- Region + endpoint.
- Policy + BPA.
- Lab user.
- Sid binary search.
- CloudTrail.
- KMS test.
- VPCe path.
- Lock cleanup.
12. FAQ
प्र. Bucket = IAM?
नाही — resource vs identity; Deny wins; cross-account दोन्ही.
प्र. ACL 2026?
Owner enforced; logs कधी ACL.
प्र. BPA?
Public ACL/policy blocks.
प्र. AccessDenied fast?
Layer checklist; * नको.
प्र. Replace IAM?
नाही.
प्र. Presigned http?
Use https.
प्र. CF origin?
HTTPS only.
प्र. Cost?
Negligible.
13. Interview Q&A
प्र. Condition?
SecureTransport false → Deny.
प्र. TLS1.0?
Pin separately.
प्र. Audit demo?
HTTPS ok / HTTP deny.
प्र. * Deny?
OK for this.
प्र. Website?
Use CF HTTPS.
प्र. Bool JSON?
"false" string.
14. Tips — English, मराठी आणि हिंदी
Ravindra Bagale's Tip (EN)
Always keep a SecureTransport Deny on buckets that hold credentials-adjacent data — it is cheap insurance.
Ravindra Bagale's Tip (MR)
Credentials-adjacent buckets वर SecureTransport Deny — स्वस्त insurance.
Tip (HI)
संवेदनशील bucket पर SecureTransport Deny सस्ता बीमा है।
घरी करून बघा
- Capture both.
- Explain aloud.
- Merge Sid.
थोडक्यात सांगायचं तर
- SecureTransport Deny.
- curl http.
- Version separate.
- IAM still.
- Use CF HTTPS.
15. Policy save करण्याआधी checklist
- Business rule एका वाक्यात.
- Allow vs Deny-unless; Deny wins.
- ARN shapes.
- Condition keys.
- BPA first.
- Allow+deny plan.
- Cleanup plan.
- json.tool.
16. Policy Simulator walkthrough
Simulator identity/resource typos साठी चांगला; BPA/VPCe/KMS miss होऊ शकतात. नंतर खऱ्या path वरून CLI.
- Simulator → user/role.
- Action + ARN.
- Include bucket policy.
- CLI confirm.
- Mismatch → layers.
17. Copy-paste runbook
# 0) Region + names
export AWS_REGION=ap-south-1
export BUCKET=rb-lab-$(date +%s)-ap-south-1
# 1) Create + show BPA
aws s3api create-bucket --bucket $BUCKET --region $AWS_REGION \
--create-bucket-configuration LocationConstraint=$AWS_REGION
aws s3api get-public-access-block --bucket $BUCKET || true
# 2) Validate + apply policy
python3 -m json.tool policy.json >/dev/null
aws s3api put-bucket-policy --bucket $BUCKET --policy file://policy.json
aws s3api get-bucket-policy --bucket $BUCKET --query Policy --output text | python3 -m json.tool | head
# 3) Allow test + Deny test (fill per project)
# ... project-specific curls / aws s3 cp ...
# 4) Cleanup
aws s3 rm s3://$BUCKET --recursive || true
aws s3api delete-bucket-policy --bucket $BUCKET || true
aws s3api delete-bucket --bucket $BUCKET
18. Industry story bank
वरील प्रत्येक project एक industry story वापरतो. इतर industries मध्ये फक्त bucket/principal/Condition बदला.
- Healthcare: SSE-KMS + OrgID + MFA.
- Fintech: IP + HTTPS + OAC.
- EdTech: OAC only.
- Logistics: VPCe.
- Media: Object Lock.
- Retail: prefix public read.
- SaaS: prefix homes.
- Gov: OrgID + MFA + Lock.
19. AccessDenied debugging flowchart
- Error code + request id.
- Bucket + region.
- BPA.
- Explicit Deny.
- Conditions.
- KMS key policy.
- OAC id.
- VPCe path.
- Simulator + CLI.
- Support last.
20. PR review checklist
- Valid JSON.
- Required fields.
- No open write.
- Tests.
- Cleanup.
सराव Tasks
Milan Furniture हा मिलान मधला फर्निचर व्यवसाय आहे. Giulia Rossi त्यांचं IT व cloud काम पाहतात. त्यांचे पैसे EUR मध्ये मोजले जातात आणि AWS resources eu-south-1 Region मध्ये चालतात. खालच्या tasks मध्ये तुम्ही या lesson मध्ये शिकलेलं वापरून त्यांची खरी कामं करता. सगळी नावं, account IDs, IP addresses व numbers सरावासाठी काल्पनिक आहेत.
0 / 16
सोपं Policy
का: HTTP Deny.
काय करायचं: milanfurniture-tls policy.
- Task वाचा आणि ते कोणत्या AWS service बद्दल आहे ते ठरवा.
- aws लिहा, मग service चं नाव, मग operation (action शब्द).
- प्रत्येक आवश्यक flag (--name) व त्यापुढे task मधली value लिहा.
- Flags कोणत्याही क्रमाने चालतात. Check answer दाबा.
सोपं List
का: HTTPS.
काय करायचं: milanfurniture-tls list.
- Task वाचा आणि ते कोणत्या AWS service बद्दल आहे ते ठरवा.
- aws लिहा, मग service चं नाव, मग operation (action शब्द).
- प्रत्येक आवश्यक flag (--name) व त्यापुढे task मधली value लिहा.
- Flags कोणत्याही क्रमाने चालतात. Check answer दाबा.
सोपं HTTP
का: Fence.
काय करायचं: HTTP deny तर 1.
- Task मधले numbers लिहून घ्या.
- कागदावर step by step काढा.
- Box मध्ये फक्त final उत्तर लिहा.
- Check answer दाबा.
सोपं HTTPS
का: Allow.
काय करायचं: HTTPS तर 1.
- Task मधले numbers लिहून घ्या.
- कागदावर step by step काढा.
- Box मध्ये फक्त final उत्तर लिहा.
- Check answer दाबा.
सोपं Head
का: Exists.
काय करायचं: milanfurniture-tls head.
- Task वाचा आणि ते कोणत्या AWS service बद्दल आहे ते ठरवा.
- aws लिहा, मग service चं नाव, मग operation (action शब्द).
- प्रत्येक आवश्यक flag (--name) व त्यापुढे task मधली value लिहा.
- Flags कोणत्याही क्रमाने चालतात. Check answer दाबा.
सोपं BPA
का: BPA.
काय करायचं: milanfurniture-tls BPA.
- Task वाचा आणि ते कोणत्या AWS service बद्दल आहे ते ठरवा.
- aws लिहा, मग service चं नाव, मग operation (action शब्द).
- प्रत्येक आवश्यक flag (--name) व त्यापुढे task मधली value लिहा.
- Flags कोणत्याही क्रमाने चालतात. Check answer दाबा.
मध्यम Put
का: Allow.
काय करायचं: put note.txt.
- Task वाचा आणि ते कोणत्या AWS service बद्दल आहे ते ठरवा.
- aws लिहा, मग service चं नाव, मग operation (action शब्द).
- प्रत्येक आवश्यक flag (--name) व त्यापुढे task मधली value लिहा.
- Flags कोणत्याही क्रमाने चालतात. Check answer दाबा.
मध्यम Get
का: Read.
काय करायचं: get note.txt.
- Task वाचा आणि ते कोणत्या AWS service बद्दल आहे ते ठरवा.
- aws लिहा, मग service चं नाव, मग operation (action शब्द).
- प्रत्येक आवश्यक flag (--name) व त्यापुढे task मधली value लिहा.
- Flags कोणत्याही क्रमाने चालतात. Check answer दाबा.
मध्यम Allow
का: Baseline.
काय करायचं: Get/Put allow.
- { "Version": "2012-10-17", "Statement": [ ... ] } ने सुरू करा.
- प्रत्येक statement मध्ये Effect, Action व Resource लिहा.
- Task ला लागेल तेवढंच द्या (least privilege).
- Double quotes व commas नीट वापरा. Check answer दाबा.
मध्यम Bool
का: Condition.
काय करायचं: false.
- Task मधल्या top-level keys पासून सुरू करा.
- Child keys 2 spaces ने indent करा (tabs नकोत).
- प्रत्येक property मध्ये task मधली value भरा.
- Check answer दाबा. Keys चा क्रम महत्त्वाचा नाही.
मध्यम Presign
का: Bind.
काय करायचं: Presign HTTP तर 1.
- Task मधले numbers लिहून घ्या.
- कागदावर step by step काढा.
- Box मध्ये फक्त final उत्तर लिहा.
- Check answer दाबा.
मध्यम Bool
का: Type.
काय करायचं: Bool तर 1.
- Task मधले numbers लिहून घ्या.
- कागदावर step by step काढा.
- Box मध्ये फक्त final उत्तर लिहा.
- Check answer दाबा.
मध्यम Enc
का: SSE.
काय करायचं: milanfurniture-tls enc.
- Task वाचा आणि ते कोणत्या AWS service बद्दल आहे ते ठरवा.
- aws लिहा, मग service चं नाव, मग operation (action शब्द).
- प्रत्येक आवश्यक flag (--name) व त्यापुढे task मधली value लिहा.
- Flags कोणत्याही क्रमाने चालतात. Check answer दाबा.
अवघड Deny HTTP
का: TLS.
काय करायचं: deny HTTP.
- { "Version": "2012-10-17", "Statement": [ ... ] } ने सुरू करा.
- प्रत्येक statement मध्ये Effect, Action व Resource लिहा.
- Task ला लागेल तेवढंच द्या (least privilege).
- Double quotes व commas नीट वापरा. Check answer दाबा.
अवघड Deny
का: Deny.
काय करायचं: prefer_explicit_deny.
- Task मधल्या top-level keys पासून सुरू करा.
- Child keys 2 spaces ने indent करा (tabs नकोत).
- प्रत्येक property मध्ये task मधली value भरा.
- Check answer दाबा. Keys चा क्रम महत्त्वाचा नाही.
अवघड Del
का: Cleanup.
काय करायचं: milanfurniture-tls del.
- Task वाचा आणि ते कोणत्या AWS service बद्दल आहे ते ठरवा.
- aws लिहा, मग service चं नाव, मग operation (action शब्द).
- प्रत्येक आवश्यक flag (--name) व त्यापुढे task मधली value लिहा.
- Flags कोणत्याही क्रमाने चालतात. Check answer दाबा.
उजळणी, मुलाखत आणि तुलना cards
हा lesson काही मिनिटांत revise करा. Cards phone वर save करा किंवा PNG download करा. प्रत्येक card वरचा QR हा lesson उघडतो.








अजून cards: Ravi Sir's Cards.