简体   繁体   中英

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 -

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 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 -

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 -

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

So how do I set Kinesis starting position timestamp via Cloudformation ?

Great question, and I'm stuck with this myself. Not just "How do I specify the timestamp in the CloudFormation template?" , but obviously "How do I update the timestamp that the EventSourceMapping uses?"

This isn't really a static property so doesn't lend itself to 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM