触发Lambda函数以响应Secrets Manager上的CreateSecret事件。

huangapple go评论57阅读模式
英文:

Trigger lambda function on CreateSecret event on secrets manager

问题

我有一个 Lambda 函数,我只想在 Secrets Manager 创建或更新时触发它。我正在尝试创建一个 EventBridge 规则,以在 Secrets Manager 上的任何操作上触发 Lambda。但是 EventBridge 规则也没有触发。我没有明确创建任何 CloudTrail 跟踪,但我可以在 CloudTrail 的事件历史记录中看到 Secrets Manager 操作的日志。

我尝试使用以下事件模式创建规则:

{
    "source": ["aws.secretsmanager"],
    "detail-type": ["AWS API Call via CloudTrail"],
    "detail": {
        "eventSource": ["secretsmanager.amazonaws.com"],
        "eventName": ["CreateSecret", "PutSecretValue", "UpdateSecret"]
    }
}
英文:

I have one lambda function which I want to trigger only when secrets managers is created or updated. I am trying to create a eventbridge rule to trigger lambda on any operations on secrets manager. But eventbridge rule is also not triggering. I don't have any cloudtrail trail created explicitly but I can see the logs of secrets manager operations in the event history of cloudtrail

I tried creating a rule using below event pattern

{
"source": ["aws.secretsmanager"],
"detail-type": ["AWS API Call via CloudTrail"],
"detail": {
    "eventSource": ["secretsmanager.amazonaws.com"],
    "eventName": ["CreateSecret", "PutSecretValue", "UpdateSecret"],
 }
}

答案1

得分: 1

在使用您的模式重新创建规则时,我意识到JSON格式是无效的。尝试使用以下格式,这对我有效:

{
  "source": ["aws.secretsmanager"],
  "detail-type": ["AWS API Call via CloudTrail"],
  "detail": {
    "eventSource": ["secretsmanager.amazonaws.com"],
    "eventName": ["CreateSecret", "PutSecretValue", "UpdateSecret"]
  }
}
英文:

While recreating a rule using your pattern I realized that the JSON is invalid. Try this one, it works for me:

{
  "source": ["aws.secretsmanager"],
  "detail-type": ["AWS API Call via CloudTrail"],
  "detail": {
    "eventSource": ["secretsmanager.amazonaws.com"],
    "eventName": ["CreateSecret", "PutSecretValue", "UpdateSecret"]
  }
}

huangapple
  • 本文由 发表于 2023年8月4日 02:15:35
  • 转载请务必保留本文链接:https://go.coder-hub.com/76830676.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定