As your https://towardsthecloud.com/aws-cdk applications grow, it becomes increasingly important to maintain a well-organized project structure. When working on smaller projects using infrastructure as code, where you deploy single applications that don’t demand extensive maintenance or collaboration from multiple teams, it’s recommended to structure your AWS CDK project in a way that enables you to deploy both the application and infrastructure using a single stack. However, if your use case involves multiple microservices and numerous stateful resources, such as databases within a single AWS CDK application, it’s wise to organize your AWS CDK project to ensure easy extensibility and seamless deployment of the components you’ve built.

src ├── assets │ ├── ecs │ │ ├── service1 │ │ └── service2 │ └── lambda │ ├── function1 │ └── function2 ├── bin │ ├── nameStacks.ts ├── lib │ ├── aspects │ │ ├── index.ts │ │ ├── permissionBoundaryAspect.ts │ │ ├── s3Aspect.ts │ │ └── vpcAspect.ts │ ├── constructs │ │ ├── index.ts │ │ └── ecsCronTasks.ts │ │ └── ecsALBTasks.ts │ ├── base │ │ ├── index.ts │ │ └── vpcStack.ts │ ├── database │ │ ├── index.ts │ │ └── rdsStack.ts │ ├── storage │ │ ├── index.ts │ │ ├── s3Stack.ts │ ├── compute │ │ ├── index.ts │ │ ├── lambdaStack.ts │ │ └── ecsStack.ts │ └── api │ └── index.ts └── main.ts

Combining stateful and stateless resources in a single stack can lead to challenges when it comes to maintainability as your AWS CDK project grows over time.

Related Articles