Skip to content

Reduce resources creation CloduFormation

0

Hello evryone!

Im deploying a serverles stack using AWS CDK lib, the problem is Im near to the quota (500 resources per stack) Is there any way to reduce this? Im deploying an API Rest with resources, methods and they connect to a lambda integration with an specific role (Ive created a role per specific group of lambdas). I noticed that each endpoint with lambda integration uses around 10 resources. Example apigateway endpoint: /api/customers GET lambda: get_customers() (python) role: lambda_customers_role, permisssions S3, Logs, Dynamo And it includes some env variables.

1 Answer
1

Hi, why do you want to restrict yourself to a single CloudFormation stack with CDK: it is intrinsically built to work with multiple stacks.

See https://docs.aws.amazon.com/cdk/v2/guide/stack_how_to_create_multiple_stacks.html for details on working with multiple stacks

Multiple stacks in CDK are even a best practice: https://docs.aws.amazon.com/cdk/v2/guide/best-practices.html

Separate your application into multiple stacks as dictated by deployment requirements
There is no hard and fast rule to how many stacks your application needs. You'll usually end up basing 
the decision on your deployment patterns. Keep in mind the following guidelines:

It's typically more straightforward to keep as many resources in the same stack as possible, so keep them 
together unless you know you want them separated.

Consider keeping stateful resources (like databases) in a separate stack from stateless resources. You 
can then turn on termination protection on the stateful stack. This way, you can freely destroy or 
create multiple copies of the stateless stack without risk of data loss.

Stateful resources are more sensitive to construct renaming—renaming leads to resource replacement. Therefore, don't nest stateful resources inside constructs that are likely to be moved around or renamed (unless the state can be rebuilt if lost, like a cache). This is another good reason to put stateful resources in their own stack.
EXPERT
answered 3 years ago
EXPERT
reviewed 3 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.