gpt4 book ai didi

amazon-web-services - 将参数输入到 Cloudwatch 事件规则 Cloudformation 中的输入参数

转载 作者:行者123 更新时间:2023-12-04 03:55:55 25 4
gpt4 key购买 nike

我正在创建一个 Cloudwatch 事件规则,如果 Step Function 进入故障或超时状态,该规则应该触发 lambda。云监视事件规则会将参数传递给 lambda,该 lambda 将发送自定义 SNS 电子邮件。我正在尝试将输入参数的值从我在 Cloudformation 模板中设置的参数传递到 Cloudwatch 事件规则中。我无法让 Cloudformation 提取参数值并将其放入 Cloudwatch 事件规则输入参数中。 CF 获取我在 JSON 中提供的文字值并将其放入 Cloudwatch 事件规则中。我正在使用带有 JSON 参数文件的 YAML 模板。发布下面的代码。

FailureEvent:
Type: AWS::Events::Rule
DependsOn:
- StateMachine
Properties:
Description: !Ref FailureRuleDescription
Name: !Ref FailureRuleName
EventPattern:
detail-type:
- "Step Functions Execution Status Change"
detail:
status:
- "FAILED"
- "TIMED_OUT"
stateMachineArn: [!Ref StateMachine]
Targets:
- Arn:
'Fn::Join': ["", ['arn:aws:lambda:', !Ref 'AWS::Region', ':', !Ref 'AWS::AccountId', ':function:', !Ref FailureLambda]]
Id: !Ref FailureLambda
Input: '{"failed_service": "!Ref StateMachineName","sns_arn": {"Fn::Join":[":",["arn: aws: sns",{"Ref": "AWS: : Region"},{"Ref": "AWS::AccountId"},{"Ref": "SNSTopic"}]]}}'

最佳答案

您可以使用Sub :

Input: !Sub '{"failed_service": "${StateMachineName}","sns_arn": "arn:aws:sns:${AWS::Region}:${AWS::AccountId}:${SNSTopic}"}'

关于amazon-web-services - 将参数输入到 Cloudwatch 事件规则 Cloudformation 中的输入参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63908146/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com