You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm building a serverless API using AWS CDK, and one of the main challenges I'm facing is how to properly organize my stacks or even whether I should split the resources into multiple stacks at all.
Setup:
In my project, I'm deploying a VPC, EC2 bastion server, Aurora, Lambda, API Gateway, Cognito, and a few other resources.
Right now, I'm considering splitting them into three stacks:
1- VPC, security groups, EC2 bastion server, and Aurora
2- Lambda function
3- API Gateway, Cognito, and other remaining resources
The Problem:
According to the AWS CDK documentation, it's recommended to separate stateful resources (like RDS) into their own stack, and to group as many other resources into the same stack as possible. On the other hand, it's also valid to organize resources based on deployment needs. Some people even suggest putting everything into a single stack.
Given all that, the configuration above seems to make the most sense to me for the following reasons:
On the first deploy, I need to manually set the RDS (Aurora) secrets in my Lambda environment variables, so deploying the infrastructure stack first, then deploying the rest, seems like a clean approach.(I guess)
The Lambda function is likely to be updated frequently during the first few months, so having it in a separate stack would make redeployments quicker and easier.
Having three stacks isn’t overly complex, so I don’t expect it to be too difficult to manage.
Since I'm not that familiar with CDK and its behavior under the hood, I've been really curious if this setup is actually solid and what would guys change if you were in my shoes.
Any feedback or suggestions would be greatly appreciated!
Thanks a lot!
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hey, everyone!
I'm building a serverless API using AWS CDK, and one of the main challenges I'm facing is how to properly organize my stacks or even whether I should split the resources into multiple stacks at all.
Setup:
In my project, I'm deploying a VPC, EC2 bastion server, Aurora, Lambda, API Gateway, Cognito, and a few other resources.
Right now, I'm considering splitting them into three stacks:
1- VPC, security groups, EC2 bastion server, and Aurora
2- Lambda function
3- API Gateway, Cognito, and other remaining resources
The Problem:
According to the AWS CDK documentation, it's recommended to separate stateful resources (like RDS) into their own stack, and to group as many other resources into the same stack as possible. On the other hand, it's also valid to organize resources based on deployment needs. Some people even suggest putting everything into a single stack.
Given all that, the configuration above seems to make the most sense to me for the following reasons:
On the first deploy, I need to manually set the RDS (Aurora) secrets in my Lambda environment variables, so deploying the infrastructure stack first, then deploying the rest, seems like a clean approach.(I guess)
The Lambda function is likely to be updated frequently during the first few months, so having it in a separate stack would make redeployments quicker and easier.
Having three stacks isn’t overly complex, so I don’t expect it to be too difficult to manage.
Since I'm not that familiar with CDK and its behavior under the hood, I've been really curious if this setup is actually solid and what would guys change if you were in my shoes.
Any feedback or suggestions would be greatly appreciated!
Thanks a lot!
Beta Was this translation helpful? Give feedback.
All reactions