Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions .doc_gen/metadata/sns_metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1393,3 +1393,42 @@ sns_UsageSmsTopic:
- sns.java2.PublishTextSMS.main
services:
sns: {}

sns_Scenario_CloudWatchSnsMonitoring:
title: Monitor infrastructure with &CW; alarms and &SNS; notifications using an &AWS; SDK
title_abbrev: Monitor infrastructure with &CW; and &SNS;
synopsis: create &CW; alarms that send &SNS; notifications when infrastructure metrics breach thresholds.
category: Scenarios
languages:
Python:
versions:
- sdk_version: 3
github: python/example_code/sns
excerpts:
- description: Create an &SNS; topic and email subscription for alarm notifications.
snippet_tags:
- python.example_code.sns.CreateTopicForAlarm
- description: Create a &CW; alarm with an &SNS; action.
snippet_tags:
- python.example_code.cloudwatch.PutMetricAlarmWithSns
- description: Create a &CW; dashboard to visualize metrics.
snippet_tags:
- python.example_code.cloudwatch.PutDashboard
- description: Publish metric data to trigger the alarm.
snippet_tags:
- python.example_code.cloudwatch.PutMetricDataForAlarm
- description: Check the alarm state.
snippet_tags:
- python.example_code.cloudwatch.DescribeAlarmsState
- description: Retrieve alarm history.
snippet_tags:
- python.example_code.cloudwatch.DescribeAlarmHistory
- description: Clean up monitoring resources.
snippet_tags:
- python.example_code.cloudwatch.DeleteMonitoringResources
- description: Run the complete scenario.
snippet_tags:
- python.example_code.sns.Scenario_CloudWatchSnsMonitoring
services:
sns: {CreateTopic, Subscribe, Unsubscribe, DeleteTopic}
cloudwatch: {PutMetricAlarm, PutMetricData, DescribeAlarms, DescribeAlarmHistory, DeleteAlarms, PutDashboard, DeleteDashboards}
21 changes: 20 additions & 1 deletion python/example_code/cloudwatch/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ Code examples that show you how to accomplish a specific task by calling multipl
functions within the same service.

- [Manage metrics and alarms](cloudwatch_basics.py)
- [Monitor infrastructure with CloudWatch and Amazon SNS](../sns/scenario_cloudwatch_sns_monitoring.py)


<!--custom.examples.start-->
Expand Down Expand Up @@ -90,6 +91,24 @@ python cloudwatch_basics.py
<!--custom.scenarios.cloudwatch_Usage_MetricsAlarms.start-->
<!--custom.scenarios.cloudwatch_Usage_MetricsAlarms.end-->

#### Monitor infrastructure with CloudWatch and Amazon SNS

This example shows you how to create CloudWatch alarms that send Amazon SNS notifications when infrastructure metrics breach thresholds.


<!--custom.scenario_prereqs.sns_Scenario_CloudWatchSnsMonitoring.start-->
<!--custom.scenario_prereqs.sns_Scenario_CloudWatchSnsMonitoring.end-->

Start the example by running the following at a command prompt:

```
python ../sns/scenario_cloudwatch_sns_monitoring.py
```


<!--custom.scenarios.sns_Scenario_CloudWatchSnsMonitoring.start-->
<!--custom.scenarios.sns_Scenario_CloudWatchSnsMonitoring.end-->

### Tests

⚠ Running tests might result in charges to your AWS account.
Expand All @@ -116,4 +135,4 @@ in the `python` folder.

Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.

SPDX-License-Identifier: Apache-2.0
SPDX-License-Identifier: Apache-2.0
19 changes: 19 additions & 0 deletions python/example_code/sns/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ functions within the same service.
- [Create an Amazon Textract explorer application](../../cross_service/textract_explorer)
- [Create and publish to a FIFO topic](sns_fifo_topic.py)
- [Detect people and objects in a video](../../example_code/rekognition)
- [Monitor infrastructure with CloudWatch and Amazon SNS](scenario_cloudwatch_sns_monitoring.py)
- [Publish an SMS text message](sns_basics.py)
- [Publish messages to queues](../../cross_service/topics_and_queues/topics_and_queues_scenario.py)
- [Use API Gateway to invoke a Lambda function](../../example_code/lambda)
Expand Down Expand Up @@ -121,6 +122,24 @@ This example shows you how to detect people and objects in a video with Amazon R
<!--custom.scenarios.cross_RekognitionVideoDetection.start-->
<!--custom.scenarios.cross_RekognitionVideoDetection.end-->

#### Monitor infrastructure with CloudWatch and Amazon SNS

This example shows you how to create CloudWatch alarms that send Amazon SNS notifications when infrastructure metrics breach thresholds.


<!--custom.scenario_prereqs.sns_Scenario_CloudWatchSnsMonitoring.start-->
<!--custom.scenario_prereqs.sns_Scenario_CloudWatchSnsMonitoring.end-->

Start the example by running the following at a command prompt:

```
python scenario_cloudwatch_sns_monitoring.py
```


<!--custom.scenarios.sns_Scenario_CloudWatchSnsMonitoring.start-->
<!--custom.scenarios.sns_Scenario_CloudWatchSnsMonitoring.end-->

#### Publish an SMS text message

This example shows you how to publish SMS messages using Amazon SNS.
Expand Down
Loading
Loading