Ravindra BagaleCourses & study guides English Track your progress

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

Identity -> edge -> IAM -> secrets -> dataWebhook वर admin नाही
Rotate+scan
Users: Cognito / JWT / authorizer Edge: WAF + API throttles IAM: least privilege execution roles Secrets: Secrets Manager / SSM Data: encryption + no PII in logs Defense in layers, not one checkbox
IAM, Cognito, secrets, WAF together.

4. How: checklist

कसं करायचं (step by step)

LayerDoDon't
AuthCognito/JWTOpen hope
IAMScoped+conditionsAdmin on Lambda
SecretsOne secret getPlaintext git
EdgeWAF+throttleInfinite burst
LogsRedactLog 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)

  1. STS.
  2. List policies.
  3. No plaintext.
  4. WAF sketch.

Cleanup (billing थांबवा)

  1. No Admin.
  2. 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

  1. Region confirm करा.
  2. CloudWatch Logs + request id.
  3. Execution role permissions.
  4. DLQ + oldest message age.
  5. curl -v + CORS.
  6. SFN event history.
  7. Linked chapter पुन्हा वाचा.
  8. Cost: concurrency/retries.

11. सामान्य errors आणि fixes

प्रत्येक row = खरी चूक. Panic करण्याआधी fix वाचा.

Error / लक्षणFix
Admin LambdaScope down.
Env secretSecrets Mgr.
No authAuthorizer.
No WAFWAF+rate.
PII logsRedact.
Trust claimsValidate.
Star DDBARN+cond.
Long keysRoles/OIDC.
DeputySourceArn.

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।

घरी करून बघा

  1. List policies.
  2. Secrets home.

थोडक्यात सांगायचं तर

  1. गोष्टी पासून सुरू, मग services.
  2. Existing chapters link — labs copy नको.
  3. Failure साठी design.
  4. Measure → मग पैसे.

15. Architecture decision checklist

  1. User journey 5 bullets, no AWS names.
  2. Sync vs async mark.
  3. Failure mode.
  4. Idempotency key.
  5. Data from access patterns.
  6. Cost 1x and 10x.
  7. Quotas ap-south-1.
  8. Auth decision.
  9. On-call + alarm.
  10. Deep chapter link.
  11. मग 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
DLQFail झालेले messages
ChoreographyEvents; conductor नाही
OrchestrationSFN central
Fan-outएक → अनेक
Fan-inअनेक → join
Strangler figMonolith peel
SagaSteps + compensate
Provisioned concurrencyWarm N; pay

19. Practice: मोठ्याने explain

  1. 60s: serverless security गोष्ट.
  2. 60s: sync vs async checkout.
  3. 60s: Lambda नको कधी.
  4. 60s: DLQ + idempotency.
  5. Record ×2.

20. Safe lab hygiene

  • Tag owner+expiry.
  • Budget alarm आधी.
  • Read-only first.
  • Cleanup.
  • No secrets in env/screenshots.
  • No provisioned on hello.

22. Myths

Mythखरं
Servers नाहीतServers आहेत; manage नको
नेहमी स्वस्तSteady वर EC2
No OpsIAM/data/alarms
एक LambdaBounded contexts
Queues optionalLoad leveler

23. Serverless error budget

Checkout error budget 0.1% असेल तर aggressive retries email duplicates देऊन budget जाळू शकतात. Money SLO ≠ notify SLO.

  1. दोन SLOs.
  2. Money retries bounded.
  3. Notify best-effort.
  4. 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

  1. Double charge headline.
  2. DLQ drain plan.
  3. Cognito outage mode.
  4. Runbook.

27. Currency / locale

Currencies आणि names rotate करा — global mental model.

28. Stolen secret

  1. Secret in git.
  2. Rotate SM.
  3. WAF+sig.
  4. Git scan.

29. Anti-patterns

  • Shared role.
  • Auth off prod.
  • Log Authz.

उजळणी, मुलाखत आणि तुलना cards

हा lesson काही मिनिटांत revise करा. Cards phone वर save करा किंवा PNG download करा. प्रत्येक card वरचा QR हा lesson उघडतो.

उजळणी card: Security in layers. One checkbox fails. Five layers. Scoped secrets. Rotate same day.
उजळणी card: Security in layers · PNG download करा · Card page उघडा
उजळणी card: Lambda roles right. Exec vs invoke. ARN + conditions. Per-function roles. Validate JWT.
उजळणी card: Lambda roles right · PNG download करा · Card page उघडा
तुलना: Admin on Lambda vs Least privilege. Admin on Lambda: Admin. Least privilege: Scoped.
तुलना: Admin on Lambda vs Least privilege · PNG download करा · Card page उघडा
तुलना: Plaintext env/git vs Secrets Manager. Plaintext env/git: Git paste. Secrets Manager: Vault.
तुलना: Plaintext env/git vs Secrets Manager · PNG download करा · Card page उघडा
मुलाखत card: Least privilege?. Only needed. Deny default. Access review.
मुलाखत card: Least privilege? · PNG download करा · Card page उघडा
मुलाखत card: Cognito vs authorizer?. Tokens + validate. Custom when needed. Authorizer context.
मुलाखत card: Cognito vs authorizer? · PNG download करा · Card page उघडा
मुलाखत card: Is WAF enough?. Not alone. Bots + rate. Name groups.
मुलाखत card: Is WAF enough? · PNG download करा · Card page उघडा
मुलाखत card: Where do secrets live?. Not git. Rotate + scope. CloudTrail + versions.
मुलाखत card: Where do secrets live? · PNG download करा · Card page उघडा

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

सराव Tasks

या scenario बद्दल

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.

कसं करायचं:
  1. Task मधले numbers लिहून घ्या.
  2. कागदावर step by step काढा.
  3. Box मध्ये फक्त final उत्तर लिहा.
  4. Check answer दाबा.

सोपं Cog

का: Idea.

काय करायचं: Cognito तर 1.

कसं करायचं:
  1. Task मधले numbers लिहून घ्या.
  2. कागदावर step by step काढा.
  3. Box मध्ये फक्त final उत्तर लिहा.
  4. Check answer दाबा.

सोपं Sec

का: Idea.

काय करायचं: Not git तर 1.

कसं करायचं:
  1. Task मधले numbers लिहून घ्या.
  2. कागदावर step by step काढा.
  3. Box मध्ये फक्त final उत्तर लिहा.
  4. Check answer दाबा.

सोपं WAF

का: Idea.

काय करायचं: WAF तर 1.

कसं करायचं:
  1. Task मधले numbers लिहून घ्या.
  2. कागदावर step by step काढा.
  3. Box मध्ये फक्त final उत्तर लिहा.
  4. Check answer दाबा.

सोपं Log

का: Idea.

काय करायचं: No Authz log तर 1.

कसं करायचं:
  1. Task मधले numbers लिहून घ्या.
  2. कागदावर step by step काढा.
  3. Box मध्ये फक्त final उत्तर लिहा.
  4. Check answer दाबा.

सोपं Thr

का: Idea.

काय करायचं: Throttle तर 1.

कसं करायचं:
  1. Task मधले numbers लिहून घ्या.
  2. कागदावर step by step काढा.
  3. Box मध्ये फक्त final उत्तर लिहा.
  4. Check answer दाबा.

सोपं PII

का: Idea.

काय करायचं: Redact तर 1.

कसं करायचं:
  1. Task मधले numbers लिहून घ्या.
  2. कागदावर step by step काढा.
  3. Box मध्ये फक्त final उत्तर लिहा.
  4. Check answer दाबा.

सोपं STS

का: Whoami.

काय करायचं: whoami.

कसं करायचं:
  1. Task वाचा आणि ते कोणत्या AWS service बद्दल आहे ते ठरवा.
  2. aws लिहा, मग service चं नाव, मग operation (action शब्द).
  3. प्रत्येक आवश्यक flag (--name) व त्यापुढे task मधली value लिहा.
  4. Flags कोणत्याही क्रमाने चालतात. Check answer दाबा.

मध्यम Exec

का: Idea.

काय करायचं: Exec role तर 1.

कसं करायचं:
  1. Task मधले numbers लिहून घ्या.
  2. कागदावर step by step काढा.
  3. Box मध्ये फक्त final उत्तर लिहा.
  4. Check answer दाबा.

मध्यम Admin

का: Idea.

काय करायचं: No Admin तर 1.

कसं करायचं:
  1. Task मधले numbers लिहून घ्या.
  2. कागदावर step by step काढा.
  3. Box मध्ये फक्त final उत्तर लिहा.
  4. Check answer दाबा.

मध्यम Auth

का: Idea.

काय करायचं: Authorizer तर 1.

कसं करायचं:
  1. Task मधले numbers लिहून घ्या.
  2. कागदावर step by step काढा.
  3. Box मध्ये फक्त final उत्तर लिहा.
  4. Check answer दाबा.

मध्यम Rot

का: Idea.

काय करायचं: Rotate तर 1.

कसं करायचं:
  1. Task मधले numbers लिहून घ्या.
  2. कागदावर step by step काढा.
  3. Box मध्ये फक्त final उत्तर लिहा.
  4. Check answer दाबा.

मध्यम Deputy

का: Idea.

काय करायचं: SourceArn तर 1.

कसं करायचं:
  1. Task मधले numbers लिहून घ्या.
  2. कागदावर step by step काढा.
  3. Box मध्ये फक्त final उत्तर लिहा.
  4. Check answer दाबा.

मध्यम Deny

का: LP.

काय करायचं: effect Deny.

कसं करायचं:
  1. Task मधल्या top-level keys पासून सुरू करा.
  2. Child keys 2 spaces ने indent करा (tabs नकोत).
  3. प्रत्येक property मध्ये task मधली value भरा.
  4. Check answer दाबा. Keys चा क्रम महत्त्वाचा नाही.

अवघड Depth

का: Idea.

काय करायचं: Layers तर 1.

कसं करायचं:
  1. Task मधले numbers लिहून घ्या.
  2. कागदावर step by step काढा.
  3. Box मध्ये फक्त final उत्तर लिहा.
  4. Check answer दाबा.

अवघड Inv

का: Idea.

काय करायचं: Invoke≠exec तर 1.

कसं करायचं:
  1. Task मधले numbers लिहून घ्या.
  2. कागदावर step by step काढा.
  3. Box मध्ये फक्त final उत्तर लिहा.
  4. Check answer दाबा.