-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add some examples for alarms and sns
- Loading branch information
Chris Guest
committed
Aug 5, 2022
1 parent
42191cc
commit c30da28
Showing
2 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# Cloudwatch | ||
|
||
Demonstrate some example commands for managing Cloudwatch. | ||
|
||
NOTE: | ||
|
||
* Cloudwatch Alarms are regional | ||
|
||
## Alarms | ||
|
||
```sh | ||
export AWS_PAGER= | ||
|
||
# list alarm names | ||
aws --profile ${AWS_PROFILE} --region ${AWS_REGION} cloudwatch describe-alarms | jq '.MetricAlarms[].AlarmName' | ||
|
||
# show an alarm | ||
aws --profile ${AWS_PROFILE} --region ${AWS_REGION} cloudwatch describe-alarms | jq 'select(.MetricAlarms[].AlarmName == "alarm-name-to-look-for")' | ||
|
||
# output alarms with action | ||
aws --profile ${AWS_PROFILE} --region ${AWS_REGION} cloudwatch describe-alarms | jq -c '.MetricAlarms[] | {name: .AlarmName, action:.AlarmActions[0]}' | jq -s -c 'sort_by(.action)' | jq -c '.[]' | ||
|
||
# patching in profile and region | ||
aws --profile ${AWS_PROFILE} --region ${AWS_REGION} cloudwatch describe-alarms | jq --arg profile ${AWS_PROFILE} --arg region "${AWS_REGION}" -c '.MetricAlarms[] | {profile: $profile, region: $region, name: .AlarmName, action:.AlarmActions[0]}' | jq -s -c 'sort_by(.action)' | jq -c '.[]' | ||
|
||
# loop over multiple profiles and regions (writes out ./alarms.json) | ||
while IFS=, read -r AWS_PROFILE AWS_REGION | ||
do | ||
aws --profile ${AWS_PROFILE} --region ${AWS_REGION} cloudwatch describe-alarms | jq --arg profile ${AWS_PROFILE} --arg region "${AWS_REGION}" -c '.MetricAlarms[] | {profile: $profile, region: $region, name: .AlarmName, action:.AlarmActions[0]}' | jq -s -c 'sort_by(.action)' | jq -c '.[]' | ||
done << EOF > ./alarms.json | ||
profile1,us-east-1 | ||
profile1,eu-west-1 | ||
profile2,us-east-1 | ||
profile1,eu-west-1 | ||
profile3,us-east-1 | ||
profile3,eu-west-1 | ||
EOF | ||
|
||
# sort and filter alarms | ||
jq -s '[.[].action] | sort | unique' ./alarms.json | jq -r '.[]' | grep sns | ||
``` | ||
|
||
## Resources | ||
|
||
* cloudwatch cli [here](https://docs.aws.amazon.com/cli/latest/reference/cloudwatch/index.html) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Simple Notification Service SNS | ||
|
||
Demonstrate some example commands for managing SNS. | ||
|
||
```sh | ||
# list topics | ||
aws --profile ${AWS_PROFILE} --region ${AWS_REGION} sns list-topics | ||
|
||
# describe a topic | ||
aws --profile ${AWS_PROFILE} --region ${AWS_REGION} sns list-subscriptions-by-topic --topic-arn "arn:aws:sns:us-east-1:accountid:topicname" | ||
``` | ||
|
||
## Resources | ||
|
||
* SNS cli [here](https://docs.aws.amazon.com/cli/latest/reference/sns/index.html) |