amazon-web-services - 创建 cloudformation 堆栈后触发预定的 lambda 函数

标签 amazon-web-services aws-lambda aws-cloudformation

这会安排我的 cloudformation lambda 每天运行一次,但我希望它在创建时触发一次。

Transform: AWS::Serverless-2016-10-31
...
EventListFunction:
  Type: 'AWS::Serverless::Function'
  Properties:
    ...
    Events:
      Schedule1:
        Type: Schedule
        Properties:
          Schedule: rate(1 day)

最佳答案

以下是一些选项:

  1. 手动create an SNS Topic 。添加AWS::SNS::Subscription将 lambda 函数添​​加到堆栈中 Endpoint SNS 主题为 TopicArn 。在堆栈创建/更新时,配置要发送到此 SNS 主题的堆栈事件通知。

  2. 添加Custom Resource引用新创建的函数,它将在创建时调用该函数。为了完成自定义资源创建并且不会导致堆栈回滚,您需要调整 Lambda 函数以支持 CloudFormation 请求/响应格式(请参阅 Custom Resource Reference )。另请注意,在堆栈删除时也会再次调用该函数,这也需要处理。

  3. 将 Lambda 函数添​​加到堆栈输出,然后编写一个简单的脚本来执行堆栈更新并在完成后调用 Lambda 函数。

关于amazon-web-services - 创建 cloudformation 堆栈后触发预定的 lambda 函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41268333/

相关文章:

node.js - 如果服务器重新启动,我是否需要在 EC2 上手动重新启动我的应用程序?

amazon-web-services - AWS ElasticBeanstalk + cloudflare

amazon-web-services - 拒绝Cognito用户池中的注册请求

amazon-web-services - 向 Slack 发送 SNS 通知

amazon-web-services - s3 cloudformation 总是给出回滚并且不创建 s3 存储桶

django - 如何将现有的 Web 应用程序从 Heroku 迁移到 AWS

ios - 连接到 AWS IoT MQTT 主题的客户端数量

c# - 当 CORS OPTIONS 请求成功完成时,API 网关间歇性返回 "No ' Access-Control-Allow-Origin' header is present...”

amazon-web-services - Cloudformation 模板中的嵌套映射

templates - 使用 jackson YAMLMapper 进行反序列化和重新序列化时,YAML 中的感叹号(YAML 标记)会导致奇怪的行为