[英]Cloudformation `StartingPositionTimestamp` for Lambda/Kinesis event source mapping
I'm looking to connect a Kinesis stream to a Lambda function via event source mapping, want to set the StartingPosition
value to AT_TIMESTAMP
-我希望通过事件源映射将 Kinesis 流连接到 Lambda 函数,希望将StartingPosition
值设置为AT_TIMESTAMP
-
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-startingposition https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-startingposition
So now I'm looking to set the actual timestamp for that starting position.所以现在我想为那个起始位置设置实际的时间戳。
If I look at the AWS CLI there seems to be a parameter for it ( --starting-position-timestamp
) -如果我查看 AWS CLI,似乎有一个参数( --starting-position-timestamp
)-
aws lambda create-event-source-mapping help
SYNOPSIS
create-event-source-mapping
--event-source-arn <value>
--function-name <value>
[--enabled | --no-enabled]
[--batch-size <value>]
[--starting-position <value>]
[--starting-position-timestamp <value>]
[--cli-input-json <value>]
[--generate-cli-skeleton <value>]
and if I look at boto3
there is a StartingPositionTimestamp
parameter -如果我看一下boto3
有一个StartingPositionTimestamp
参数 -
https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/lambda.html#Lambda.Client.create_event_source_mapping https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/lambda.html#Lambda.Client.create_event_source_mapping
response = client.create_event_source_mapping(
EventSourceArn='string',
FunctionName='string',
Enabled=True|False,
BatchSize=123,
StartingPosition='TRIM_HORIZON'|'LATEST'|'AT_TIMESTAMP',
StartingPositionTimestamp=datetime(2015, 1, 1)
)
but I can't find any such StartingPositionTimestamp
parameter in the AWS::Lambda::EventSourceMapping
docs -但我在AWS::Lambda::EventSourceMapping
文档中找不到任何这样的StartingPositionTimestamp
参数 -
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html
So how do I set Kinesis starting position timestamp via Cloudformation ?那么如何通过 Cloudformation 设置 Kinesis 起始位置时间戳?
Great question, and I'm stuck with this myself.很好的问题,我自己也被困住了。 Not just "How do I specify the timestamp in the CloudFormation template?"不仅仅是“如何在 CloudFormation 模板中指定时间戳?” , but obviously "How do I update the timestamp that the EventSourceMapping uses?" ,但显然“我如何更新 EventSourceMapping 使用的时间戳?”
This isn't really a static property so doesn't lend itself to CloudFormation.这并不是真正的静态属性,因此不适用于 CloudFormation。
I'm guessing here, but maybe you should update the timestamp as part of your process.我在这里猜测,但也许您应该在过程中更新时间戳。 Bootstrap your app by setting timestamp as epoch, and then after reading your stream set it to the timestamp of the last processed element.通过将时间戳设置为纪元来引导您的应用程序,然后在读取流后将其设置为最后处理元素的时间戳。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.