
Aim to reduce inter-service dependencies by identifying:
- Shared databases that need decoupling.
- Synchronous calls that can be turned into asynchronous messaging.
- Code or library dependencies crossing service boundaries.
2. Separate and modularize codebase
Refactor the code into separate repositories or modules, each representing a bounded context or microservice. This clear separation supports independent deployment pipelines and ownership.
import * as cdk from 'aws-cdk-lib';
import * as lambda from 'aws-cdk-lib/aws-lambda';
import * as apigw from 'aws-cdk-lib/aws-apigateway';
export class OrderServiceStack extends cdk.Stack {
constructor(scope: cdk.App, id: string, props?: cdk.StackProps) {
super(scope, id, props);
const orderLambda = new lambda.Function(this, 'OrderHandler', {
runtime: lambda.Runtime.NODEJS_18_X,
handler: 'order.handler',
code: lambda.Code.fromAsset('lambda/order-service'),
});
new apigw.LambdaRestApi(this, 'OrderAPI', {
handler: orderLambda,
restApiName: 'Order Service',
});
}
}Consolidate infra-as-code with AWS CDK to manage each microservice’s infrastructure, including APIs, storage and permissions.

