Skip to content
betterstack-alchemyUnofficial

Incidents.AmazonSnsIntegration

Kind ResourceType id BetterStack.Incidents.AmazonSnsIntegrationSource src/Incidents/AmazonSnsIntegration.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/AmazonSnsIntegration.test.ts).

An Amazon SNS integration opens incidents from the notifications your Amazon SNS topic sends. Better Stack gives you a url (a secret, Redacted): in AWS, subscribe it to your topic with the HTTPS protocol and leave raw message delivery off (otherwise every notification is refused with 400). Better Stack confirms the subscription itself; subscriptionState turns from awaiting to active and topicArn shows the topic once AWS has confirmed it.

Rules you set decide which notifications open (startedRuleType + startedRules), acknowledge or resolve an incident, and fields pick the cause, title and alert id out of the message (json, xml, body) or out of the SNS envelope (sns_envelope, e.g. its Subject). By default the title is the envelope’s Subject and the cause the whole message.

Every prop updates in place except teamId, which replaces the integration (and gives it a new url). name defaults to a generated unique name. Removing escalationPolicyId, teamWait, titleField, the acknowledged/resolved alert id fields or an other*Fields list clears it; removing causeField, startedAlertIdField, the rule lists or metadata keeps what the integration has.

The API adds createdAt/updatedAt to every rule and returns every member of a field (unset ones null, plus its role in specialType); the attributes drop those, so they read like the props and an update sends only what changed.

Opening incidents from CloudWatch alarms published to SNS

Section titled “Opening incidents from CloudWatch alarms published to SNS”

NewStateValue ALARM opens, OK resolves

const alarmName: AlertField = { fieldTarget: "json", targetField: "AlarmName", matchType: "match_everything" };
const sns = yield* BetterStack.Incidents.AmazonSnsIntegration("alarms", {
startedRuleType: "any",
startedRules: [{ ruleTarget: "json", targetField: "NewStateValue", matchType: "equals", content: "ALARM" }],
resolvedRuleType: "any",
resolvedRules: [{ ruleTarget: "json", targetField: "NewStateValue", matchType: "equals", content: "OK" }],
startedAlertIdField: alarmName,
resolvedAlertIdField: alarmName,
causeField: { fieldTarget: "json", targetField: "NewStateReason", matchType: "match_everything" },
});

The aws sns subscribe arguments for the deployed URL

const subscribe = (topicArn: string, endpoint: string) => [
"sns", "subscribe", "--topic-arn", topicArn, "--protocol", "https", "--notification-endpoint", endpoint,
];
const args = subscribe("arn:aws:sns:us-east-1:123456789012:alarms", Redacted.value(endpointUrl));

acknowledgedAlertIdField CreateIncidentsAmazonSnsIntegrationRequestAcknowledgedAlertIdField | null

How to extract the alert ID from a notification that acknowledges an incident, with the same keys as cause_field. Required when acknowledged_rule_type isn't unused.

acknowledgedRules CreateIncidentsAmazonSnsIntegrationRequestAcknowledgedRulesItem[]

The conditions acknowledged_rule_type checks, with the same keys as started_rules. At least one is required when the type is any or all.

acknowledgedRuleType "any" | "all" | "unused" | string

When notifications acknowledge an incident. Any value other than unused needs started_alert_id_field, acknowledged_alert_id_field and at least one rule.

call boolean

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

causeField CreateIncidentsAmazonSnsIntegrationRequestCauseField | null

How to extract the incident cause from the notification that starts an incident. Defaults to the whole message.

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. Returned as a string.

metadata CreateIncidentsAmazonSnsIntegrationRequestMetadataMap

Custom metadata. Each key holds a list of values. A value is a string, written as {type: "String", value}, or a catalog reference, written as {type, item_id, name, email}. User references are returned as u123 and team references as t123. Get a user's ID via List team members, and a team's ID via List teams. A key accepts a single value or a list. Values under one key must all be the same type and can't repeat. An update replaces all of the integration's metadata with the object, {} removes it all, and leaving metadata out keeps it.

name string

The name shown in the dashboard. Defaults to a unique name generated from the stack, stage and logical id.

otherAcknowledgedFields CreateIncidentsAmazonSnsIntegrationRequestOtherAcknowledgedFieldsItem[] | null

Custom fields extracted from a notification that acknowledges an incident.

otherResolvedFields CreateIncidentsAmazonSnsIntegrationRequestOtherResolvedFieldsItem[] | null

Custom fields extracted from a notification that resolves an incident.

otherStartedFields CreateIncidentsAmazonSnsIntegrationRequestOtherStartedFieldsItem[] | null

Custom fields extracted from the notification that starts an incident, saved as incident metadata.

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 0 | 60 | 180 | 300 | 900 | 1800 | 3600 | 7200 | number

How long to wait, in seconds, after a matching resolving notification before the incident resolves. Applies only while resolved_rule_type isn't unused.

resolvedAlertIdField CreateIncidentsAmazonSnsIntegrationRequestResolvedAlertIdField | null

How to extract the alert ID from a notification that resolves an incident, with the same keys as cause_field. Required when resolved_rule_type isn't unused.

resolvedRules CreateIncidentsAmazonSnsIntegrationRequestResolvedRulesItem[]

The conditions resolved_rule_type checks, with the same keys as started_rules. At least one is required when the type is any or all.

resolvedRuleType "any" | "all" | "unused" | string

When notifications resolve an incident. Any value other than unused needs started_alert_id_field, resolved_alert_id_field and at least one rule. Resolving is checked first, then acknowledging, then opening, and a notification that matches no open incident can still open one.

sms boolean

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

startedAlertIdField CreateIncidentsAmazonSnsIntegrationRequestStartedAlertIdField | null

How to extract the alert ID from the notification that starts an incident, with the same keys as cause_field. Later notifications acknowledge or resolve the open incident with the same alert ID. Required when acknowledged_rule_type or resolved_rule_type isn't unused.

startedRules CreateIncidentsAmazonSnsIntegrationRequestStartedRulesItem[]

The conditions started_rule_type checks. At least one rule is required when the type is any or all.

startedRuleType "any" | "all" | "unused" | string

When notifications open an incident. Every value other than unused needs at least one rule. When started_alert_id_field finds an alert ID that matches an open incident, the notification goes to that incident instead of opening a new one.

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.

titleField CreateIncidentsAmazonSnsIntegrationRequestTitleField | null

How to extract a custom incident title from the notification that starts an incident, with the same keys as cause_field. By default, the title is the whole SNS Subject, with field_target set to sns_envelope, target_field to Subject and match_type to match_everything. null extracts no title.

id string always set

The incidents_amazon_sns_integration's id.

acknowledgedAlertIdField IncidentsAmazonSnsIntegrationAcknowledgedAlertIdField | null

How to extract the alert ID from a notification that acknowledges an incident, with the same keys as cause_field. Required when acknowledged_rule_type isn't unused.

acknowledgedRules IncidentsAmazonSnsIntegrationAcknowledgedRulesItem[]

The conditions acknowledged_rule_type checks, with the same keys as started_rules. At least one is required when the type is any or all.

acknowledgedRuleType "any" | "all" | "unused"

When notifications acknowledge an incident. Any value other than unused needs started_alert_id_field, acknowledged_alert_id_field and at least one rule.

call boolean

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

causeField IncidentsAmazonSnsIntegrationCauseField | null

How to extract the incident cause from the notification that starts an incident. Defaults to the whole message.

createdAt string

When the integration was created.

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. Returned as a string.

metadata IncidentsAmazonSnsIntegrationMetadataMap

Custom metadata. Each key holds a list of values. A value is a string, written as {type: "String", value}, or a catalog reference, written as {type, item_id, name, email}. User references are returned as u123 and team references as t123. Get a user's ID via List team members, and a team's ID via List teams. A key accepts a single value or a list. Values under one key must all be the same type and can't repeat.

name string | null

The name of the Amazon SNS integration shown in the dashboard.

otherAcknowledgedFields IncidentsAmazonSnsIntegrationOtherAcknowledgedFieldsItem[] | null

Custom fields extracted from a notification that acknowledges an incident.

otherResolvedFields IncidentsAmazonSnsIntegrationOtherResolvedFieldsItem[] | null

Custom fields extracted from a notification that resolves an incident.

otherStartedFields IncidentsAmazonSnsIntegrationOtherStartedFieldsItem[] | null

Custom fields extracted from the notification that starts an incident, saved as incident metadata.

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 0 | 60 | 180 | 300 | 900 | 1800 | 3600 | 7200

How long to wait, in seconds, after a matching resolving notification before the incident resolves. Applies only while resolved_rule_type isn't unused.

resolvedAlertIdField IncidentsAmazonSnsIntegrationResolvedAlertIdField | null

How to extract the alert ID from a notification that resolves an incident, with the same keys as cause_field. Required when resolved_rule_type isn't unused.

resolvedRules IncidentsAmazonSnsIntegrationResolvedRulesItem[]

The conditions resolved_rule_type checks, with the same keys as started_rules. At least one is required when the type is any or all.

resolvedRuleType "any" | "all" | "unused"

When notifications resolve an incident. Any value other than unused needs started_alert_id_field, resolved_alert_id_field and at least one rule. Resolving is checked first, then acknowledging, then opening, and a notification that matches no open incident can still open one.

sampleBody string | null

The body of the sample SNS message saved in the dashboard to preview extraction.

sampleHeaders string | null

The headers of the sample notification saved in the dashboard to preview extraction.

sampleQueryString string | null

The query string of the sample notification saved in the dashboard to preview extraction.

sms boolean

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

startedAlertIdField IncidentsAmazonSnsIntegrationStartedAlertIdField | null

How to extract the alert ID from the notification that starts an incident, with the same keys as cause_field. Later notifications acknowledge or resolve the open incident with the same alert ID. Required when acknowledged_rule_type or resolved_rule_type isn't unused.

startedRules IncidentsAmazonSnsIntegrationStartedRulesItem[]

The conditions started_rule_type checks. At least one rule is required when the type is any or all.

startedRuleType "any" | "all" | "unused"

When notifications open an incident. Every value other than unused needs at least one rule. When started_alert_id_field finds an alert ID that matches an open incident, the notification goes to that incident instead of opening a new one.

subscriptionState "active" | "awaiting"

Whether AWS has confirmed the SNS subscription.

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.

titleField IncidentsAmazonSnsIntegrationTitleField | null

How to extract a custom incident title from the notification that starts an incident, with the same keys as cause_field. By default, the title is the whole SNS Subject, with field_target set to sns_envelope, target_field to Subject and match_type to match_everything. null extracts no title.

topicArn string | null

The ARN of the subscribed Amazon SNS topic, or null until AWS confirms the subscription.

updatedAt string

When the integration was last updated.

url string | Redacted<string>

The endpoint to subscribe your Amazon SNS topic to. Leave Enable raw message delivery off on the subscription, or every notification is rejected with 400.

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

teamId string

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