Skip to content
betterstack-alchemyUnofficial

Incidents.AwsCloudWatchIntegration

Kind ResourceType id BetterStack.Incidents.AwsCloudWatchIntegrationSource src/Incidents/AwsCloudWatchIntegration.tsLive test gated Lifecycle test runs against the offline mock; a live run exists but is gated behind BETTERSTACK_TEST_PAID_INTEGRATIONS=1 because the test account's plan refuses this integration (test/Incidents/AwsCloudWatchIntegration.test.ts).

Receives alerts from AWS CloudWatch and opens Better Stack incidents. Better Stack gives you a webhookUrl (a secret, Redacted): in AWS, subscribe it as an HTTPS endpoint to an SNS topic and make that topic the action of your CloudWatch alarms. An alarm going to ALARM opens an incident, going back to OK resolves it.

Every prop updates in place except teamId, which replaces the integration (and gives it a new webhookUrl). name defaults to a generated unique name. Removing escalationPolicyId or teamWait clears them. Without an escalation policy, call/sms/email/push/ criticalAlert decide how the current on-call person is alerted.

Alert through an escalation policy

const integration = yield* BetterStack.Incidents.AwsCloudWatchIntegration("aws-cloudwatch", {
name: "AWS CloudWatch alerts",
escalationPolicyId: policyId,
});

Pasting the webhook URL into AWS CloudWatch

Section titled “Pasting the webhook URL into AWS CloudWatch”

The URL is a secret: export it from the stack and paste it into AWS CloudWatch, or hand it to whatever provisions AWS CloudWatch.

A stack output

const integration = yield* BetterStack.Incidents.AwsCloudWatchIntegration("alerts", { escalationPolicyId: policyId });
return { webhookUrl: integration.webhookUrl };

Stop opening incidents during maintenance

yield* BetterStack.Incidents.AwsCloudWatchIntegration("aws-cloudwatch", { name: "AWS CloudWatch alerts", paused: true });

call boolean

Whether to call the on-call person. Ignored while an escalation policy is set.

criticalAlert boolean

Whether to send a critical push notification that ignores the mute switch and Do Not Disturb mode. Ignored while an escalation policy is set.

email boolean

Whether to send an e-mail to the on-call person. Ignored while an escalation policy is set.

escalationPolicyId string | null

ID of the escalation policy for alerts, or null to alert the current on-call person directly.

name string

Integration name. Defaults to a unique name generated from the stack, stage and logical id.

paused boolean

Whether the integration is paused. A paused integration opens no incidents.

push boolean

Whether to send a push notification to the on-call person. Ignored while an escalation policy is set.

recoveryPeriod number | null

Seconds a resolved alert must hold before the incident resolves. Has no effect for this integration, since an incident resolves as soon as AWS CloudWatch reports the alert as resolved.

sms boolean

Whether to send an SMS to the on-call person. Ignored while an escalation policy is set.

teamId string

Team that owns the resource, such as t123. Defaults to the credentials' team (BETTERSTACK_TEAM_ID, or the profile's team). Changing it replaces the resource.

teamWait number | null

Seconds to wait before escalating to the whole team. 0 alerts the whole team right away, and null never escalates to the team. Ignored while an escalation policy is set.

id string always set

The incidents_aws_cloudwatch_integration's id.

call boolean

Whether to call the on-call person. Ignored while an escalation policy is set.

criticalAlert boolean

Whether to send a critical push notification that ignores the mute switch and Do Not Disturb mode. Ignored while an escalation policy is set.

email boolean

Whether to send an e-mail to the on-call person. Ignored while an escalation policy is set.

escalationPolicyId string | null

ID of the escalation policy for alerts, or null to alert the current on-call person directly.

name string | null

Integration name.

paused boolean

Whether the integration is paused. A paused integration opens no incidents.

push boolean

Whether to send a push notification to the on-call person. Ignored while an escalation policy is set.

recoveryPeriod number | null

Seconds a resolved alert must hold before the incident resolves. Has no effect for this integration, since an incident resolves as soon as AWS CloudWatch reports the alert as resolved.

sms boolean

Whether to send an SMS to the on-call person. Ignored while an escalation policy is set.

teamId string

Team that owns this integration, such as t123.

teamName string

Name of the team that owns this integration.

teamWait number | null

Seconds to wait before escalating to the whole team. 0 alerts the whole team right away, and null never escalates to the team. Ignored while an escalation policy is set.

webhookUrl string | Redacted<string>

The URL to paste into AWS CloudWatch. Alerts AWS CloudWatch sends to it open incidents.

AwsCloudWatchIntegration.lookup(props) reads an object this stack does not manage. It is never created, updated or deleted.

id string required

The integration's id.

teamId string

Team that owns it, such as t123. Defaults to the credentials' team.