Serverless Security Patterns: IAM, Cognito, Secrets आणि WAF
Serverless security layers: Cognito/JWT, WAF+throttle, least-privilege IAM, secrets बाहेर, PII नाही logs मध्ये. एक checkbox पुरेसे नाही.
या chapter मध्ये तुम्ही काय शिकाल
- Auth map
- Least privilege
- Secrets
- WAF+throttle
- Deep links
1. रोजचे: leaked key
Mei (SGD) key in env+git. Secrets Manager + scan = रोक.
Roles: IAM roles; users: Cognito; data IAM: DynamoDB security; edge: WAF.
2. का layers?
हे का लागतं?
Lambda magic नाही. Broad roles, public API, env secrets = usual breach. Layers.
हे काय आहे?
Cognito = identity. IAM = AWS API rights. Secrets = runtime creds. WAF = web ACL.
3. Vertical diagram
4. How: checklist
कसं करायचं (step by step)
| Layer | Do | Don't |
|---|---|---|
| Auth | Cognito/JWT | Open hope |
| IAM | Scoped+conditions | Admin on Lambda |
| Secrets | One secret get | Plaintext git |
| Edge | WAF+throttle | Infinite burst |
| Logs | Redact | Log Authz |
5. Commands
STS
aws sts get-caller-identity
अर्थ: IAM edit आधी principal.
Get role
aws iam get-role --role-name checkout-api-role --query 'Role.{Arn:Arn,Trust:AssumeRolePolicyDocument}'
aws iam list-attached-role-policies --role-name checkout-api-role
अर्थ: Attach आधी read.
Secrets list
aws secretsmanager list-secrets --region ap-south-1 \
--query 'SecretList[].Name' --output text
अर्थ: Secrets inventory.
Throttle
aws apigateway get-stages --rest-api-id APIID --region ap-south-1 \
--query 'item[].{S:stageName,T:throttleSettings}'
अर्थ: Rate limits ठेवा.
6. Industries
- Fintech IAM.
- PHI+rotate.
- Ecommerce WAF.
- SaaS claims.
- Gov IdP.
7. Lab
8. Lab - security pass
Org block नसेल तर ap-south-1 (Mumbai). आधी budget alert.
कसं करायचं (step by step)
- STS.
- List policies.
- No plaintext.
- WAF sketch.
Cleanup (billing थांबवा)
- No Admin.
- Revoke widen.
9. एकाच pattern — वेगवेगळ्या industries
- Fintech (Aisha, Lagos): payment webhooks → SQS → Lambda.
- Ecommerce (Rohan, Pune): checkout API; inventory SNS fan-out.
- Healthcare (Mei, Singapore): SNS SMS; PHI + fine-grained IAM.
- EdTech (Diego, São Paulo): EventBridge nightly cleanup.
- Logistics (Fatima, Casablanca): EventBridge + saga.
- Media (Kenji, Osaka): S3 → Lambda thumbs + fan-out.
- SaaS (Priya, Bengaluru): Cognito + per-tenant partition.
- Gov (Omar, Amman): strangler fig per form route.
10. Troubleshooting checklist
- Region confirm करा.
- CloudWatch Logs + request id.
- Execution role permissions.
- DLQ + oldest message age.
- curl -v + CORS.
- SFN event history.
- Linked chapter पुन्हा वाचा.
- Cost: concurrency/retries.
11. सामान्य errors आणि fixes
प्रत्येक row = खरी चूक. Panic करण्याआधी fix वाचा.
| Error / लक्षण | Fix |
|---|---|
| Admin Lambda | Scope down. |
| Env secret | Secrets Mgr. |
| No auth | Authorizer. |
| No WAF | WAF+rate. |
| PII logs | Redact. |
| Trust claims | Validate. |
| Star DDB | ARN+cond. |
| Long keys | Roles/OIDC. |
| Deputy | SourceArn. |
12. FAQ
प्र. Pools?
Users vs AWS creds.
प्र. Authorizer?
Custom vs JWT.
प्र. SSM vs SM?
Rotation vs config.
प्र. WAF alone?
No.
प्र. IAM link?
IAM chapter.
13. Interview Q&A (Beginner / Mid / Senior + MNC)
प्र. Beginner LP
Only needed.
प्र. Secrets where
Not git.
प्र. Mid JWT
Authorizer claims.
प्र. Exec vs invoke
Can-call vs who-calls.
प्र. Senior depth
Many layers.
प्र. MNC
Reviews+rotation.
14. Tips — English, मराठी आणि हिंदी
Ravindra Bagale's Tip (EN)
Layers: identity, edge, IAM, secrets, clean logs — review them every release.
Ravindra Bagale's Tip (MR)
Layers: identity, edge, IAM, secrets, clean logs — प्रत्येक release.
Tip (HI)
Layers: identity, edge, IAM, secrets, clean logs — हर release।
घरी करून बघा
- List policies.
- Secrets home.
थोडक्यात सांगायचं तर
- गोष्टी पासून सुरू, मग services.
- Existing chapters link — labs copy नको.
- Failure साठी design.
- Measure → मग पैसे.
15. Architecture decision checklist
- User journey 5 bullets, no AWS names.
- Sync vs async mark.
- Failure mode.
- Idempotency key.
- Data from access patterns.
- Cost 1x and 10x.
- Quotas ap-south-1.
- Auth decision.
- On-call + alarm.
- Deep chapter link.
- मग console/IaC.
16. Copy-paste quick commands
# Region and identity
aws configure get region
aws sts get-caller-identity
# Lambda landscape
aws lambda list-functions --region ap-south-1 --max-items 20 \
--query 'Functions[].{N:FunctionName,R:Runtime,T:Timeout,M:MemorySize}' --output table
aws lambda get-account-settings --region ap-south-1
# API Gateway (HTTP APIs)
aws apigatewayv2 get-apis --region ap-south-1 --query 'Items[].{N:Name,Id:ApiId,Ep:ProtocolType}' --output table
# Queues and topics
aws sqs list-queues --region ap-south-1
aws sns list-topics --region ap-south-1 --query 'Topics[].TopicArn'
# Event buses and state machines
aws events list-event-buses --region ap-south-1
aws stepfunctions list-state-machines --region ap-south-1 --query 'stateMachines[].name'
# DynamoDB tables (names only)
aws dynamodb list-tables --region ap-south-1
Sandbox + read-only IAM.
17. अजून industry आणि stack stories
- Fintech Lagos: webhook → SQS → idempotent ledger.
- Ecommerce Pune: throttle + fan-out.
- Healthcare SG: SNS + PHI IAM.
- EdTech: EventBridge cleanup.
- Logistics: bus + saga.
- Media: avoid recursive S3.
- SaaS: tenant partition.
- Gov: strangler peel.
- Startup: Function URL → HTTP API.
- Retail: FIFO vs Standard.
- Python: thin handlers.
- Node: async/await.
- Java: SnapStart.
- .NET: package size.
- Go: static binary.
- PHP: hybrid.
18. Glossary
| Term | अर्थ |
|---|---|
| Cold start | पहिल्या invoke ची init |
| Idempotency | दोनदा = तोच effect |
| DLQ | Fail झालेले messages |
| Choreography | Events; conductor नाही |
| Orchestration | SFN central |
| Fan-out | एक → अनेक |
| Fan-in | अनेक → join |
| Strangler fig | Monolith peel |
| Saga | Steps + compensate |
| Provisioned concurrency | Warm N; pay |
19. Practice: मोठ्याने explain
- 60s: serverless security गोष्ट.
- 60s: sync vs async checkout.
- 60s: Lambda नको कधी.
- 60s: DLQ + idempotency.
- Record ×2.
20. Safe lab hygiene
- Tag owner+expiry.
- Budget alarm आधी.
- Read-only first.
- Cleanup.
- No secrets in env/screenshots.
- No provisioned on hello.
21. या chapter च्या links
- Compute: Lambda.
- HTTP: API Gateway.
- Data: DynamoDB.
- Messaging: SQS/SNS.
- Events: EventBridge.
- Workflows: Step Functions.
- build-* projects link.
22. Myths
| Myth | खरं |
|---|---|
| Servers नाहीत | Servers आहेत; manage नको |
| नेहमी स्वस्त | Steady वर EC2 |
| No Ops | IAM/data/alarms |
| एक Lambda | Bounded contexts |
| Queues optional | Load leveler |
23. Serverless error budget
Checkout error budget 0.1% असेल तर aggressive retries email duplicates देऊन budget जाळू शकतात. Money SLO ≠ notify SLO.
- दोन SLOs.
- Money retries bounded.
- Notify best-effort.
- Money page; notify ticket.
24. Regional notes (ap-south-1)
- Labs Mumbai.
- Feature availability.
- Data residency.
- Latency India.
25. Naming conventions
# Suggested prefixes
# Lambda: pay-intake-prod, pay-worker-prod
# SQS: pay-orders.fifo / pay-orders-dlq
# SNS: pay-order-events
# EB bus: pay.domain
# SFN: pay-refund-saga
# DDB: pay-orders-prod
env + domain नावात ठेवा. CloudWatch grep सोपा.
26. Pre-mortems
- Double charge headline.
- DLQ drain plan.
- Cognito outage mode.
- Runbook.
27. Currency / locale
Currencies आणि names rotate करा — global mental model.
28. Stolen secret
- Secret in git.
- Rotate SM.
- WAF+sig.
- Git scan.
29. Anti-patterns
- Shared role.
- Auth off prod.
- Log Authz.
उजळणी, मुलाखत आणि तुलना cards
हा lesson काही मिनिटांत revise करा. Cards phone वर save करा किंवा PNG download करा. प्रत्येक card वरचा QR हा lesson उघडतो.








अजून cards: Ravi Sir's Cards.
सराव Tasks
London Legal LLP हा लंडन मधला कायदा सेवा व्यवसाय आहे. Oliver Hughes त्यांचं IT व cloud काम पाहतात. त्यांचे पैसे GBP मध्ये मोजले जातात आणि AWS resources eu-west-2 Region मध्ये चालतात. खालच्या tasks मध्ये तुम्ही या lesson मध्ये शिकलेलं वापरून त्यांची खरी कामं करता. सगळी नावं, account IDs, IP addresses व numbers सरावासाठी काल्पनिक आहेत.
0 / 16
सोपं LP
का: Idea.
काय करायचं: LP तर 1.
- Task मधले numbers लिहून घ्या.
- कागदावर step by step काढा.
- Box मध्ये फक्त final उत्तर लिहा.
- Check answer दाबा.
सोपं Cog
का: Idea.
काय करायचं: Cognito तर 1.
- Task मधले numbers लिहून घ्या.
- कागदावर step by step काढा.
- Box मध्ये फक्त final उत्तर लिहा.
- Check answer दाबा.
सोपं Sec
का: Idea.
काय करायचं: Not git तर 1.
- Task मधले numbers लिहून घ्या.
- कागदावर step by step काढा.
- Box मध्ये फक्त final उत्तर लिहा.
- Check answer दाबा.
सोपं WAF
का: Idea.
काय करायचं: WAF तर 1.
- Task मधले numbers लिहून घ्या.
- कागदावर step by step काढा.
- Box मध्ये फक्त final उत्तर लिहा.
- Check answer दाबा.
सोपं Log
का: Idea.
काय करायचं: No Authz log तर 1.
- Task मधले numbers लिहून घ्या.
- कागदावर step by step काढा.
- Box मध्ये फक्त final उत्तर लिहा.
- Check answer दाबा.
सोपं Thr
का: Idea.
काय करायचं: Throttle तर 1.
- Task मधले numbers लिहून घ्या.
- कागदावर step by step काढा.
- Box मध्ये फक्त final उत्तर लिहा.
- Check answer दाबा.
सोपं PII
का: Idea.
काय करायचं: Redact तर 1.
- Task मधले numbers लिहून घ्या.
- कागदावर step by step काढा.
- Box मध्ये फक्त final उत्तर लिहा.
- Check answer दाबा.
सोपं STS
का: Whoami.
काय करायचं: whoami.
- Task वाचा आणि ते कोणत्या AWS service बद्दल आहे ते ठरवा.
- aws लिहा, मग service चं नाव, मग operation (action शब्द).
- प्रत्येक आवश्यक flag (--name) व त्यापुढे task मधली value लिहा.
- Flags कोणत्याही क्रमाने चालतात. Check answer दाबा.
मध्यम Exec
का: Idea.
काय करायचं: Exec role तर 1.
- Task मधले numbers लिहून घ्या.
- कागदावर step by step काढा.
- Box मध्ये फक्त final उत्तर लिहा.
- Check answer दाबा.
मध्यम Admin
का: Idea.
काय करायचं: No Admin तर 1.
- Task मधले numbers लिहून घ्या.
- कागदावर step by step काढा.
- Box मध्ये फक्त final उत्तर लिहा.
- Check answer दाबा.
मध्यम Auth
का: Idea.
काय करायचं: Authorizer तर 1.
- Task मधले numbers लिहून घ्या.
- कागदावर step by step काढा.
- Box मध्ये फक्त final उत्तर लिहा.
- Check answer दाबा.
मध्यम Rot
का: Idea.
काय करायचं: Rotate तर 1.
- Task मधले numbers लिहून घ्या.
- कागदावर step by step काढा.
- Box मध्ये फक्त final उत्तर लिहा.
- Check answer दाबा.
मध्यम Deputy
का: Idea.
काय करायचं: SourceArn तर 1.
- Task मधले numbers लिहून घ्या.
- कागदावर step by step काढा.
- Box मध्ये फक्त final उत्तर लिहा.
- Check answer दाबा.
मध्यम Deny
का: LP.
काय करायचं: effect Deny.
- Task मधल्या top-level keys पासून सुरू करा.
- Child keys 2 spaces ने indent करा (tabs नकोत).
- प्रत्येक property मध्ये task मधली value भरा.
- Check answer दाबा. Keys चा क्रम महत्त्वाचा नाही.
अवघड Depth
का: Idea.
काय करायचं: Layers तर 1.
- Task मधले numbers लिहून घ्या.
- कागदावर step by step काढा.
- Box मध्ये फक्त final उत्तर लिहा.
- Check answer दाबा.
अवघड Inv
का: Idea.
काय करायचं: Invoke≠exec तर 1.
- Task मधले numbers लिहून घ्या.
- कागदावर step by step काढा.
- Box मध्ये फक्त final उत्तर लिहा.
- Check answer दाबा.