Skip to content

Commit b4772cf

Browse files
committed
fix!: reuse budget topics
1 parent 08656c7 commit b4772cf

File tree

12 files changed

+580
-208
lines changed

12 files changed

+580
-208
lines changed

API.md

+148-20
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/.astro/settings.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"_variables": {
3-
"lastUpdateCheck": 1736237451595
3+
"lastUpdateCheck": 1740059306253
44
}
55
}

docs/src/content/docs/components/account-management/budgets.mdx

+68-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Tags used for budget filters must be activated as Cost Allocation Tags in your a
1515
Budget notifications are sent via Amazon SNS, which can be configured for the following delivery methods:
1616
- **Email**: Each email address must confirm the notification opt-in the first time it is deployed.
1717
- **Slack**: Notifications are sent to a designated Slack channel. The Slack workspace must be linked to the Management
18-
Account. For setup details, see the SOP [AWS Chatbot and Slack Integration](sop-account-setup#aws-chatbot-and-slack-integration).
18+
Account. For setup details, see the SOP [AWS Chatbot and Slack Integration](/sop/account-setup#aws-chatbot-and-slack-integration).
1919

2020
Below is an example of creating a budget for resources tagged with `Owner: backend`. Notifications will be sent to a
2121
specified Slack channel and email address once the budget exceeds $100.
@@ -41,7 +41,7 @@ specified Slack channel and email address once the budget exceeds $100.
4141
},
4242
amount: 100,
4343
subscribers: {
44-
slack: slackBudgetNotifications,
44+
slack: [slackBudgetNotifications],
4545
emails: ['[email protected]'],
4646
},
4747
},
@@ -71,7 +71,7 @@ specified Slack channel and email address once the budget exceeds $100.
7171
},
7272
"amount": 100,
7373
"subscribers": {
74-
"slack": slack_budget_notifications,
74+
"slacks": [slack_budget_notifications],
7575
"emails": ["[email protected]"],
7676
},
7777
},
@@ -82,6 +82,71 @@ specified Slack channel and email address once the budget exceeds $100.
8282
</Fragment>
8383
</DualCode>
8484

85+
## Reusing the same SNS Topic
86+
87+
Each budget creates a unique SNS topic with the name `${budget.name}-topic`. If multiple budgets share the same
88+
subscribers, you can use a single SNS topic to reduce the number of resources and subscription confirmations.
89+
To do this, set the `snsTopicName` property in `BudgetSubscribers`. For example:
90+
91+
<DualCode>
92+
<Fragment slot="ts">
93+
```ts {5}
94+
import {App} from 'aws-cdk-lib';
95+
import { DataLandingZone, SlackChannel } from 'aws-data-landing-zone';
96+
97+
const subscribers: BudgetSubscribers = {
98+
snsTopicName: 'budgets',
99+
slacks: [{
100+
slackChannelConfigurationName: 'budget-alerts',
101+
slackWorkspaceId: 'YourWorkspaceId',
102+
slackChannelId: 'YourChannelId',
103+
}],
104+
emails: ["[email protected]"],
105+
};
106+
107+
const app = new App();
108+
const dlz = new DataLandingZone(app, {
109+
budgets: [
110+
...Defaults.budgets(100, 20, subscribers),
111+
{ name: 'budget-high', amount: 1_000, subscribers },
112+
{ name: 'budget-high-1', amount: 2_000, subscribers },
113+
],
114+
...
115+
});
116+
```
117+
</Fragment>
118+
<Fragment slot="python" >
119+
```python {5}
120+
import aws_cdk as cdk
121+
import aws_data_landing_zone as dlz
122+
123+
budget_subscribers = dlz.BudgetSubscribers(
124+
sns_topic_name= "budgets",
125+
slacks=[
126+
dlz.SlackChannel(
127+
slack_channel_configuration_name="budget-alerts",
128+
slack_workspace_id="YourWorkspaceId",
129+
slack_channel_id="YourChannelId",
130+
)
131+
],
132+
emails=[
133+
134+
]
135+
)
136+
137+
app = cdk.App()
138+
dlz.DataLandingZone(app,
139+
budgets=[
140+
*dlz.Defaults.budgets(org_total=500, infra_dlz=20, subscribers=budget_subscribers),
141+
dlz.DlzBudgetProps(name="budget-high", amount=1_000, subscribers=budget_subscribers),
142+
dlz.DlzBudgetProps(name="budget-high-1", amount=2_000, subscribers=budget_subscribers)
143+
],
144+
...
145+
)
146+
```
147+
</Fragment>
148+
</DualCode>
149+
85150
## Defaults
86151

87152
The construct provides two default budgets available via `Defaults.budgets`. These include:

docs/src/content/docs/components/security/security-hub.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ in all regions of all accounts. Security Hub should be accessed through the Audi
1010
Security Hub notifications are delivered via Amazon SNS, with support for the following methods:
1111
- **Email**: Each email address must confirm the notification opt-in the first time it is deployed.
1212
- **Slack**: Notifications are sent to a designated Slack channel. The Slack workspace must be linked to the Management
13-
Account. For setup details, see the SOP [AWS Chatbot and Slack Integration](sop-account-setup#aws-chatbot-and-slack-integration).
13+
Account. For setup details, see the SOP [AWS Chatbot and Slack Integration](/sop/account-setup#aws-chatbot-and-slack-integration).
1414

1515
:::note
1616
Email notifications are unstructured JSON and may appear messy. Slack notifications are well-formatted and easy to read.

0 commit comments

Comments
 (0)