简体   繁体   English

当 object 加载失败时,如何生成 AWS SNS 警报以触发 MS Teams 通知?

[英]How can I generate AWS SNS alert to trigger MS Teams notification when an object fails to load?

I am trying to generate an SNS alert for MS Teams, and anytime I try to execute the function in Lambda I get the following error... [ERROR] InvalidParameterException: An error occurred (InvalidParameter) when calling the Publish operation: Invalid parameter: Subject Traceback我正在尝试为 MS Teams 生成 SNS 警报,并且每当我尝试在 Lambda 中执行 function 时,我都会收到以下错误... [ERROR] InvalidParameterException:调用发布操作时发生错误(InvalidParameter):参数无效:主题追溯

Does anyone have any idea where I went wrong or what I can change to generate an MS Teams alert successfully?有谁知道我哪里出错了或者我可以更改什么以成功生成 MS Teams 警报?

def sns_alert(object):
'''Sends SNS Teams alert failed to load object'''
try:
    message = f'{object} failed to load'
    subject = f'{object} failed to load'
    sc = boto3.client(service_name='sns')
    response = sc.publish(
    TopicArn = 'arn:MSTEAMS-SNS-TOPIC', 
    Message = json.dumps({'default': json.dumps(message)}),
    Subject = json.dumps({'default': json.dumps(subject)}),
    MessageStructure = 'json'
    
)
    return response
except Exception as e:
    raise e

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM