背景:
1、短信网关审核麻烦,采购流程长
2、实时告警需求大
参考链接:https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/sns.html
AWS新建用户,并授权sns:Publish,sns:Subscribe,最好再加限定来源IP,沿用旧Access keys可能存在异常,可以新建Access keys
代码:
vim Zabbix-SMS.sh
#!/usr/bin/python
-- coding: utf-8 --
import boto3
import sys
Create an SNS client
client = boto3.client(
"sns",
aws_access_key_id=‘XXXXXXXx‘,
aws_secret_access_key=‘XXXXXXX‘,
region_name=‘XXXX‘
)
topic_arn = ‘arn:aws:sns:XXXXXXX‘
client.subscribe(
TopicArn=topic_arn,
Protocol=‘sms‘ ,
Endpoint=sys.argv[1]
)
Publish a message.
client.publish(Message=sys.argv[2], TopicArn=topic_arn)
原文地址:https://blog.51cto.com/johnzheng/2416759
时间: 2024-10-29 02:57:23