@infoxchange/make-it-so 2.18.1-internal-testing-add-tag-setup-6f9bc82.1 → 2.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +76 -26
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -57,6 +57,55 @@ console.log(getDeployConfig());
|
|
|
57
57
|
| smtpHost | SMTP host for the app to use | string | string |
|
|
58
58
|
| smtpPort | SMTP port for the app to use | number | number \| undefined |
|
|
59
59
|
| clamAVUrl | ClamAV instance url for the app to use | string | string |
|
|
60
|
+
| vpcHttpProxy | HTTP proxy URL for the VPC | string | string |
|
|
61
|
+
| alarmSnsTopic | SNS topic ARN for CloudWatch alarms | string | string |
|
|
62
|
+
| tags | Tags to apply to AWS resources | Record<string, string> | Record<string, string> |
|
|
63
|
+
|
|
64
|
+
</details>
|
|
65
|
+
|
|
66
|
+
### setupTags
|
|
67
|
+
|
|
68
|
+
Automatically applies various AWS tags to CDK constructs in your stack and can be customized with your own tagging
|
|
69
|
+
logic. Default behaviour:
|
|
70
|
+
|
|
71
|
+
- Applies tags from `deployConfig.tags` to the root construct
|
|
72
|
+
- Adds `guardduty-suppress: true` tag to SST "live lambda" Functions (to prevent false positive GuardDuty alerts)
|
|
73
|
+
|
|
74
|
+
```typescript
|
|
75
|
+
import { setupTags } from "@infoxchange/make-it-so/lib/tags";
|
|
76
|
+
|
|
77
|
+
// Basic usage - automatically applies tags from deployConfig
|
|
78
|
+
setupTags(app);
|
|
79
|
+
|
|
80
|
+
// Advanced usage - customize tags based on construct properties
|
|
81
|
+
setupTags(app, {
|
|
82
|
+
modifyTags: ({ node, isLeafNode, isRootNode, currentTags }) => {
|
|
83
|
+
// Add custom tags for specific construct types
|
|
84
|
+
if (node instanceof IxNextjsSite) {
|
|
85
|
+
return [...currentTags, { key: "ResourceType", value: "NextjsSite" }];
|
|
86
|
+
}
|
|
87
|
+
return currentTags;
|
|
88
|
+
},
|
|
89
|
+
});
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
<details>
|
|
93
|
+
<summary><strong>Options</strong></summary>
|
|
94
|
+
|
|
95
|
+
| Prop | Type | Description |
|
|
96
|
+
| ------------------ | --------------------------------------------------------------- | ------------------------------------------------------------------------- |
|
|
97
|
+
| scope | IConstruct | The CDK construct to apply tags to (usually your app or stack) |
|
|
98
|
+
| options | SetupTagsOptions | (optional) Configuration options |
|
|
99
|
+
| options.modifyTags | (props: ModifyTagsProps) => Array<{key: string, value: string}> | (optional) Function to customize tags based on the construct being tagged |
|
|
100
|
+
|
|
101
|
+
#### ModifyTagsProps:
|
|
102
|
+
|
|
103
|
+
| Property | Type | Description |
|
|
104
|
+
| ----------- | ----------------------------------- | ---------------------------------------- |
|
|
105
|
+
| node | IConstruct | The current construct being tagged |
|
|
106
|
+
| isLeafNode | boolean | Whether this construct has no children |
|
|
107
|
+
| isRootNode | boolean | Whether this is the root scope construct |
|
|
108
|
+
| currentTags | Array<{key: string, value: string}> | The tags that have already been applied |
|
|
60
109
|
|
|
61
110
|
</details>
|
|
62
111
|
|
|
@@ -235,15 +284,17 @@ const domainCert = new IxCertificate(scope, "ExampleDotComCertificate", {
|
|
|
235
284
|
<details>
|
|
236
285
|
<summary><strong>IxCloudWatchAlarm</strong> - Creates a CloudWatch alarm with IX-specific defaults.</summary>
|
|
237
286
|
|
|
238
|
-
IxCloudWatchAlarm extends AWS CDK's CloudWatch Alarm functionality with IX-specific defaults and special handling for
|
|
239
|
-
|
|
240
|
-
|
|
287
|
+
IxCloudWatchAlarm extends AWS CDK's CloudWatch Alarm functionality with IX-specific defaults and special handling for
|
|
288
|
+
CloudFront alarms (which must be created in us-east-1). If no actions are specified, the alarm will automatically use
|
|
289
|
+
the IX alarm SNS topic which sends alerts to MS Teams. Who is tagged in these alerts can be configured with the
|
|
290
|
+
`toNotify` property.
|
|
241
291
|
|
|
242
292
|
```typescript
|
|
243
293
|
import { IxCloudWatchAlarm } from "@infoxchange/make-it-so/cdk-constructs";
|
|
244
294
|
|
|
245
295
|
new IxCloudWatchAlarm(scope, "ApiErrorAlarm", {
|
|
246
296
|
alarmName: "high-error-rate",
|
|
297
|
+
alarmDescription: "Alert when API error rate is too high",
|
|
247
298
|
metric: {
|
|
248
299
|
namespace: "AWS/ApiGateway",
|
|
249
300
|
metricName: "5XXError",
|
|
@@ -257,37 +308,36 @@ new IxCloudWatchAlarm(scope, "ApiErrorAlarm", {
|
|
|
257
308
|
evaluationPeriods: 2,
|
|
258
309
|
comparisonOperator: (ComparisonOperator) =>
|
|
259
310
|
ComparisonOperator.GREATER_THAN_THRESHOLD,
|
|
260
|
-
toNotify: ["
|
|
261
|
-
alarmDescription: "Alert when API error rate is too high",
|
|
311
|
+
toNotify: ["Receiver Name", "Second Receiver"], // Receivers are defined in aws-gov under components/infra-event-notification
|
|
262
312
|
});
|
|
263
313
|
```
|
|
264
314
|
|
|
265
315
|
#### Options:
|
|
266
316
|
|
|
267
|
-
| Prop | Type | Description
|
|
268
|
-
| -------------------------- | ------------------------------------------------------------------ |
|
|
269
|
-
| metric | object | Metric configuration
|
|
270
|
-
| metric.namespace | string | The namespace of the metric (e.g., "AWS/ApiGateway")
|
|
271
|
-
| metric.metricName | string | The name of the metric
|
|
272
|
-
| metric.dimensionsMap | Record<string, string> | (optional) Dimensions for the metric
|
|
273
|
-
| metric.period | Duration \| ((Duration) => Duration) | (optional) The period over which the statistic is applied. Can be a function for easier access to CDK Duration helpers
|
|
274
|
-
| metric.statistic | string \| ((Stats) => string) | (optional) The statistic to apply (e.g., "Average", "Sum"). Can be a function for easier access to CloudWatch.Stats helpers
|
|
275
|
-
| comparisonOperator | ComparisonOperator \| ((ComparisonOperator) => ComparisonOperator) | How to compare the metric to the threshold. Can be a function for easier access to CloudWatch.ComparisonOperator helpers
|
|
276
|
-
| threshold | number | The value to compare the metric against
|
|
277
|
-
| evaluationPeriods | number | The number of periods over which data is compared to the threshold
|
|
278
|
-
| treatMissingData | TreatMissingData \| ((TreatMissingData) => TreatMissingData) | (optional) How to treat missing data points. Can be a function for easier access to CloudWatch.TreatMissingData helpers
|
|
279
|
-
| alarmName | string | (optional) Name of the alarm
|
|
280
|
-
| alarmDescription | string | (optional) Description of the alarm
|
|
281
|
-
| toNotify | string[] | (optional) List
|
|
282
|
-
| actions | object | (optional) Actions to take when alarm state changes. If not provided, defaults to IX alarm SNS topic
|
|
283
|
-
| actions.onOk | (string \| IAlarmAction)[] | (optional) Actions to take when alarm goes to OK state
|
|
284
|
-
| actions.onAlarm | (string \| IAlarmAction)[] | (optional) Actions to take when alarm goes to ALARM state
|
|
285
|
-
| actions.onInsufficientData | (string \| IAlarmAction)[] | (optional) Actions to take when alarm goes to INSUFFICIENT_DATA state
|
|
286
|
-
| [...CloudWatch.AlarmProps] | | Any other props accepted by [CloudWatch.Alarm](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_cloudwatch.Alarm.html)
|
|
317
|
+
| Prop | Type | Description |
|
|
318
|
+
| -------------------------- | ------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
319
|
+
| metric | object | Metric configuration |
|
|
320
|
+
| metric.namespace | string | The namespace of the metric (e.g., "AWS/ApiGateway") |
|
|
321
|
+
| metric.metricName | string | The name of the metric |
|
|
322
|
+
| metric.dimensionsMap | Record<string, string> | (optional) Dimensions for the metric |
|
|
323
|
+
| metric.period | Duration \| ((Duration) => Duration) | (optional) The period over which the statistic is applied. Can be a function for easier access to CDK Duration helpers |
|
|
324
|
+
| metric.statistic | string \| ((Stats) => string) | (optional) The statistic to apply (e.g., "Average", "Sum"). Can be a function for easier access to CloudWatch.Stats helpers |
|
|
325
|
+
| comparisonOperator | ComparisonOperator \| ((ComparisonOperator) => ComparisonOperator) | How to compare the metric to the threshold. Can be a function for easier access to CloudWatch.ComparisonOperator helpers |
|
|
326
|
+
| threshold | number | The value to compare the metric against |
|
|
327
|
+
| evaluationPeriods | number | The number of periods over which data is compared to the threshold |
|
|
328
|
+
| treatMissingData | TreatMissingData \| ((TreatMissingData) => TreatMissingData) | (optional) How to treat missing data points. Can be a function for easier access to CloudWatch.TreatMissingData helpers |
|
|
329
|
+
| alarmName | string | (optional) Name of the alarm |
|
|
330
|
+
| alarmDescription | string | (optional) Description of the alarm |
|
|
331
|
+
| toNotify | string[] | (optional) List receivers to be notified on alarm state changes. Receivers are defined in aws-gov under components/infra-event-notification |
|
|
332
|
+
| actions | object | (optional) Actions to take when alarm state changes. If not provided, defaults to IX alarm SNS topic |
|
|
333
|
+
| actions.onOk | (string \| IAlarmAction)[] | (optional) Actions to take when alarm goes to OK state |
|
|
334
|
+
| actions.onAlarm | (string \| IAlarmAction)[] | (optional) Actions to take when alarm goes to ALARM state |
|
|
335
|
+
| actions.onInsufficientData | (string \| IAlarmAction)[] | (optional) Actions to take when alarm goes to INSUFFICIENT_DATA state |
|
|
336
|
+
| [...CloudWatch.AlarmProps] | | Any other props accepted by [CloudWatch.Alarm](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_cloudwatch.Alarm.html) |
|
|
287
337
|
|
|
288
338
|
#### Static Properties:
|
|
289
339
|
|
|
290
|
-
IxCloudWatchAlarm provides
|
|
340
|
+
IxCloudWatchAlarm provides access to various CloudWatch constants:
|
|
291
341
|
|
|
292
342
|
- `IxCloudWatchAlarm.Stats` - CloudWatch.Stats for metric statistics
|
|
293
343
|
- `IxCloudWatchAlarm.Duration` - CDK.Duration for time periods
|
package/package.json
CHANGED