FUNCTION_ERROR_INIT_FAILURE error while deploying AWS Lamba

Today I got an error

Provisioned Concurrency configuration failed to be applied. Reason: FUNCTION_ERROR_INIT_FAILURE

in CloudFormation while deploying stack with Lambda

And that’s all. No more details about the root cause.

My SAM file configures lambda with Provisioned Concurrency.

MyTestLambda:
  Type: 'AWS::Serverless::Function'
  Properties:
    FunctionName: MyHandler
    Handler: corpoprogrammer.MyHandler::handleRequest
    ProvisionedConcurrencyConfig:
      ProvisionedConcurrentExecutions: 1

After switching off Provisioned Concurrency my stack was successfully deployed but first lambda invocation finished with exception. Exception was thrown in lambda constructor because Java code was checking if required environmental variables were supplied in lambda configuration and throwing exception if not. So that’s why lambda initialization failed when Provisioned Concurrency was configured. Cloud formation Status reason

Provisioned Concurrency configuration failed to be applied. Reason: FUNCTION_ERROR_INIT_FAILURE

could be a bit more descriptive and root cause with stacktrace could be provided. Lambda with Provisioned Concurrency  was successfully deployed after fixing environmental variables configuration.

1 thought on “FUNCTION_ERROR_INIT_FAILURE error while deploying AWS Lamba”

  1. After working on it for 3 hours, finally a good explanation.
    My problem was that the lambda crashed during the first run as well.
    With provisioning, it try to run the lambda at the start, hence if it fail the cloudformation run fail as well.

    Reply

Leave a Comment