Aws-cdk: Lambda fails to deploy when provisoned_executions > 0

Created on 29 Jan 2020  路  6Comments  路  Source: aws/aws-cdk

This code fails to deploy with:

Provisioned Concurrency configuration failed to be applied. 
Reason: FUNCTION_ERROR_INIT_FAILURE

However, if I change provisioned_executions from 10 to 0, it deploys correctly.

    def addValidationFunction(self):

        self.validationDlq = Queue(self, 'validationDLQ')

        curTime = round(time.time())

        fnName = "IssFn{}".format(curTime)

        self.validationFunction = Function(self, fnName,
            runtime=Runtime.PYTHON_3_6,
            code=Code.asset('lambda/issuer'),
            handler='validation_function.lambda_handler',
            timeout=core.Duration.seconds(900),
            layers=[self.depLayer],
            dead_letter_queue=self.validationDlq
        )

        verName = "IssFnVer{}".format(curTime)

        self.validationVersion = self.validationFunction.add_version(name=verName, provisioned_executions=10)

        lambdaPolicy = PolicyStatement()
        lambdaPolicy.add_all_resources()
        lambdaPolicy.add_actions("secretsmanager:GetSecretValue")
        self.validationFunction.add_to_role_policy(lambdaPolicy)

        StringParameter(self, "issuerValidationFunctionArn",
             parameter_name="ISSUER_VALIDATION_FN_ARN",
             string_value=self.validationVersion.function_arn,
             simple_name=True
        )

Environment

  • CLI Version :
  • Framework Version: CDK 1.20.0
  • OS : OSX
  • Language : Python

Other


This is :bug: Bug Report

@aws-cdaws-lambda bug closing-soon

Most helpful comment

@sblackstone this issue doesn't seem specific to CDK. it's likely that you'd see the same error working with cloudformation directly.

When you pre-provision a lambda, it is bootstrapped in the same call that creates the cloudformation resource. if the bootstrapping either fails or times out, FUNCTION_ERROR_INIT_FAILURE is thrown.

So, the question is, why is this code failing to initialize in a timely manner.
Can you try some other code in this lambda, or perhaps a stripped-down version of your current code?

All 6 comments

@sblackstone the error FUNCTION_ERROR_INIT_FAILURE happens for provisioned capacity > 0, when the handler fails to initialize. I'd recommend looking at the code.
You can also initially deploy the code with provisioned_executions=0, trigger the function manually, & see if this code is throwing any errors.

@netroy The deploy works (including my code) if provisioned_executions=0.

It also works fine if I add a provisoned_concurrent_executions configuration after the stack deploys.

It only fails when provisioned_executions > 0 at cdk deploy

I can add that it hangs for a long time before that error occurs.

@netroy Also, it does the same thing whether I add the provisioned_executions to a Version or an Alias,
I've tried it both ways...

@sblackstone this issue doesn't seem specific to CDK. it's likely that you'd see the same error working with cloudformation directly.

When you pre-provision a lambda, it is bootstrapped in the same call that creates the cloudformation resource. if the bootstrapping either fails or times out, FUNCTION_ERROR_INIT_FAILURE is thrown.

So, the question is, why is this code failing to initialize in a timely manner.
Can you try some other code in this lambda, or perhaps a stripped-down version of your current code?

Agree with @netroy's assessment. Can you try this with an uber simple Lambda function and see if it still fails?

Closing this issue since there hasn't been a response in a while. Feel free to reopen.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

v-do picture v-do  路  3Comments

eladb picture eladb  路  3Comments

slipdexic picture slipdexic  路  3Comments

artyom-melnikov picture artyom-melnikov  路  3Comments

nzspambot picture nzspambot  路  3Comments