Living Systems Handbook microservices as humans Bipin Singh
Anatomy of one human

The immune system and the ID card

2 min readChapter 10 of 34By Bipin Singh

Your immune system decides what belongs in your body and attacks what doesn't. Your ID card proves who you are when you enter a building. A microservice needs both: protection against unwanted callers and inputs, and an identity that limits what it is allowed to do.

The ID card: the service's own identity (IAM role)

Every Lambda function runs with an IAM execution role — its ID card. The card lists exactly which doors it opens.

Key idea

Least privilege: the Waiter's ID card opens the Waiter's table and lets it post on the notice board. It doesn't open the Cashier's table — even if a bug or attacker tries.

With CDK, you grant permissions precisely instead of writing broad policies:

ordersTable.grantReadWriteData(placeOrderFn);   // only this table
eventBus.grantPutEventsTo(placeOrderFn);         // only this bus
paymentsSecret.grantRead(chargeFn);              // only this secret

The skin and front door: who may call the service

Caller Protection
App users (people) Amazon Cognito user pools issue tokens; API Gateway's JWT authorizer checks them before your code runs
Other services inside AWS IAM authorization on APIs (signed requests), or EventBridge/SQS permissions — services never share passwords
Partners and third parties API keys with usage plans, or OAuth client credentials
The whole internet AWS WAF rules (block SQL injection, bad bots, too many requests), throttling on API Gateway

Antibodies: validating everything

Treat every input as potentially harmful:

Protecting memory

Secrets

Immune memory: learning from attacks

A security checklist for one human

Tip

In CDK, the grant… methods are your friend: they generate least-privilege policies automatically and keep permissions next to the code that needs them.

Bipin Singh
Written by Bipin Singh

Senior Full-Stack Engineer · AI & AWS. I design and build serverless systems on AWS — and love explaining them simply.

Work with me