用于 Lambda/Kinesis 事件源映射的 Cloudformation `StartingPositionTimestamp`

Jus*_*tin 5 amazon-web-services aws-cloudformation amazon-kinesis aws-lambda

我希望通过事件源映射将 Kinesis 流连接到 Lambda 函数,希望将StartingPosition值设置为AT_TIMESTAMP-

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-startingposition

所以现在我想为那个起始位置设置实际的时间戳。

如果我查看 AWS CLI,它似乎有一个参数 ( --starting-position-timestamp) -

aws lambda create-event-source-mapping help
Run Code Online (Sandbox Code Playgroud)
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>]
Run Code Online (Sandbox Code Playgroud)

如果我看boto3有一个StartingPositionTimestamp参数 -

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)
)
Run Code Online (Sandbox Code Playgroud)

但我StartingPositionTimestampAWS::Lambda::EventSourceMapping文档中找不到任何这样的参数-

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html

那么如何通过 Cloudformation 设置 Kinesis 起始位置时间戳?

Kir*_*rst -2

很好的问题,我自己也被这个问题困扰了。不仅仅是“如何在 CloudFormation 模板中指定时间戳?” ,但显然“如何更新 EventSourceMapping 使用的时间戳?”

这并不是真正的静态属性,因此不适合 CloudFormation。

我在这里猜测,但也许您应该在流程中更新时间戳。通过将时间戳设置为纪元来引导您的应用程序,然后在读取流后将其设置为最后处理的元素的时间戳。