Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Budget already exists - error #15

Open
rcoundon opened this issue Mar 13, 2023 · 4 comments
Open

Budget already exists - error #15

rcoundon opened this issue Mar 13, 2023 · 4 comments

Comments

@rcoundon
Copy link

rcoundon commented Mar 13, 2023

I've updated the definition of the ApplicationCostMonitoring parameters in a stack to include an array of subscribers.

When I try to deploy I now get:

Error creating budget: application_somename-dev_daily_6_%80_budget - the budget already exists. (Service: AWSBudgets; Status Code: 400; Error Code: DuplicateRecordException

So it seems that the construct is not properly dealing with updates to existing stacks and is trying to create a new one. Is there any way around this?

Thanks

@kkiani
Copy link
Collaborator

kkiani commented Mar 22, 2023

@rcoundon It looks like this is a CDK issue. It can happen for multiple reasons, like using the same application name to define ApplicationCostMonitoring in multiple CDK apps or somehow the CDK lost its state.

Can you please provide steps to reproduce this issue?

@rcoundon
Copy link
Author

I'm using sst.dev to deploy the application - a wrapper around CDK.

I have created a function that looks like this:

  createCostMonitoring(stack: Stack) {
    const costMonitoring = new ApplicationCostMonitoring(stack, {
      monthlyLimitInDollars: process.env.MONTHLY_COST_LIMIT ? parseInt(process.env.MONTHLY_COST_LIMIT) : 200,
      applicationName: stack.stage,
      defaultTopic: 'cost-monitoring',
      subscribers: process.env.BUDGET_SUBSCRIBERS.split(','),
    });
    costMonitoring.monitor();
  }

I then simply call that function on deployment from within the stack. With all the other constructs that I'm using (S3, DynamoDB, SQS, EventBridge Rules, API Gateway etc) CDK is smart enough to work out that they already exist and either update them or skip them on each deployment so was surprised when this didn't do the same

@kkiani
Copy link
Collaborator

kkiani commented Mar 23, 2023

@rcoundon I was able to reproduce this issue by changing the subscribers (other parameters work fine). This is a CloudFormation issue, not limited to this construct or CDK. There is an open issue for this problem here.

You can destroy your stack and deploy it again to bypass this issue, but I understand that is not ideal. The issue has been open since Feb 5, 2020! I will look for a short-term solution until they fix this issue with CloudFormation.

@rcoundon
Copy link
Author

rcoundon commented Mar 23, 2023

Thanks for investigating, I've added my vote/bump to that issue to ask for it to be addressed in case that makes any difference.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants