How to depend on the LambdaVersion{sha256} resource?

I’ve got a custom resource that will trigger one of my serverless functions. This resource uses DependsOn to wait for the AWS::Lambda::Function to be created, but I can’t figure out how to depend on the version resource — which appears necessary to avoid a race condition. (CF is calling my function before there’s a version available, and gives up by the time it is…)

How can I access the sha256 / name of the AWS::Lambda::Version that serverless manages internally so I can depend on it correctly?

so I’ve got:

functions:
  foobar:
    handler: foobar.handler
resources:
  custom:
    Type: Custom::FoobarTrigger
    DependsOn: FoobarLambdaFunction

but I want to write:

DependsOn: FoobarLambdaVersion{sha256}

Help!

Thanks,
–Bob

Finally found this post and it worked like a charm for my use case.

1 Like