gpt4 book ai didi

amazon-web-services - 如何使用 CloudFormation 创建每隔几分钟调用一次网关 API 的规则?

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

我正在尝试在 CloudFormation 中创建一条 CloudWatch 规则,每隔几分钟触发一次我们的网关 API,但我无法找到有关如何填充模板某些部分的文档。

例如,这就是我们的 CF 模板中的内容:

SomeAPI:
Type: AWS::Serverless::Function
Properties:
Handler: api
Runtime: go1.x
CodeUri: ../../deploy/bla.zip
Timeout: 600
VpcConfig:
SecurityGroupIds:
- !ImportValue VPCSecurityGroup
SubnetIds:
- !ImportValue PrivateSubnetA
- !ImportValue PrivateSubnetB

Events:
TestApiPing:
Type: Api
Properties:
Path: /test-api/ping
Method: GET

我想让 CF 创建一个调用 ping API 的规则,但在填写目标部分时遇到困难:

TestRule:
Type: AWS::Events::Rule
Properties:
Name: "test-ping-rule"
ScheduleExpression: "cron(0/15 * ? * * *)"
Targets:
-
Arn:
Fn::GetAtt:
- "PingFunction"
- <what to put here?>
Id: "TargetFunctionV1"

感谢您的帮助!

最佳答案

今天经过多次尝试和错误,我找到了解决方案。在无服务器函数定义的事件部分下,您可以执行以下操作:

Events:
PublicApi:
Type: Schedule
Properties:
Schedule: cron(0/5 * ? * * *)
Input: '{ "httpMethod": "GET", "path": "/public_api/ping" }'

关于amazon-web-services - 如何使用 CloudFormation 创建每隔几分钟调用一次网关 API 的规则?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57152129/

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