Zappa icon indicating copy to clipboard operation
Zappa copied to clipboard

Upcoming changes in Lambda. Does it affect Zappa?

Open soymonitus opened this issue 5 years ago • 9 comments

https://aws.amazon.com/es/blogs/compute/coming-soon-updated-lambda-states-lifecycle-for-vpc-networking/

I have seen this regarding function creation. Does it affect Zappa?

soymonitus avatar Jan 21 '20 16:01 soymonitus

I believe it does. I've found that for Lambdas using an ALB, a waiter needs to be put in here: https://github.com/Miserlou/Zappa/blob/master/zappa/core.py#L1415

        # Wait for lambda to become active, otherwise registering target will fail
        # https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/lambda.html#waiters
        kwargs = dict(
          FunctionName="{}:{}".format(lambda_arn, ALB_LAMBDA_ALIAS)
        )
        waiter = self.lambda_client.get_waiter('function_active')
        waiter.wait(**kwargs)

Otherwise you get an error message like the following: botocore.exceptions.ClientError: An error occurred (InternalFailure) when calling the RegisterTargets operation (reached max retries: 4): Unknown

uuqq avatar Feb 10 '20 06:02 uuqq

@uuqq thanks - would I need just a lambda with an ALB to replicate the problem? If not, can you share a sample config?

jneves avatar Feb 14 '20 00:02 jneves

I had an existing ALB which I use (I use code from this PR https://github.com/Miserlou/Zappa/pull/1833) but I'm guessing it will be the same as using a new ALB. The problem is at the creation of the target group section.

uuqq avatar Feb 14 '20 00:02 uuqq

Ran into the issue described by @uuqq , when creating a new ALB. Currently looking for a workaround, will update here if I find one.

cyrillay avatar Jan 18 '21 10:01 cyrillay

Did the workaround with the "wait" not work?

uuqq avatar Jan 18 '21 11:01 uuqq

It didn't... The wait gave me another issue that I didn't dig further :

Traceback (most recent call last):
  File ".../zappa/cli.py", line 2778, in handle
    sys.exit(cli.handle())
  File ".../zappa/cli.py", line 512, in handle
    self.dispatch_command(self.command, stage)
  File ".../zappa/cli.py", line 549, in dispatch_command
    self.deploy(self.vargs['zip'])
  File ".../zappa/cli.py", line 801, in deploy
    self.zappa.deploy_lambda_alb(**kwargs)
  File ".../zappa/core.py", line 1413, in deploy_lambda_alb
    waiter.wait(**kwargs)
  File ".../botocore/waiter.py", line 53, in wait
    Waiter.wait(self, **kwargs)
  File ".../botocore/waiter.py", line 313, in wait
    response = self._operation_method(**kwargs)
  File ".../botocore/waiter.py", line 84, in __call__
    return self._client_method(**kwargs)
  File ".../botocore/client.py", line 357, in _api_call
    return self._make_api_call(operation_name, kwargs)
  File ".../botocore/client.py", line 649, in _make_api_call
    api_params, operation_model, context=request_context)
  File ".../botocore/client.py", line 697, in _convert_to_request_dict
    api_params, operation_model)
  File ".../botocore/validate.py", line 297, in serialize_to_request
    raise ParamValidationError(report=report.generate_report())
botocore.exceptions.ParamValidationError: Parameter validation failed:
Unknown parameter in input: "Action", must be one of: FunctionName, Qualifier
Unknown parameter in input: "Principal", must be one of: FunctionName, Qualifier
Unknown parameter in input: "SourceArn", must be one of: FunctionName, Qualifier
Unknown parameter in input: "StatementId", must be one of: FunctionName, Qualifier

I also tried with a import time; time.sleep(120) but I had the same issue as before : botocore.exceptions.ClientError: An error occurred (InternalFailure) when calling the RegisterTargets operation (reached max retries: 4): Unknown

cyrillay avatar Jan 18 '21 13:01 cyrillay

Anyone ran into this same issue ?

I'm running into another similar one... When launching zappa update with an existing load balancer, it doesn't work unless I manually deregister the target from the ALB and register the lambda again. Not sure what cause this. Would appreciate any insight !

cyrillay avatar Jan 22 '21 15:01 cyrillay

Any update on this ? @uuqq : do you have any guidance on how we could solve this on zappa ? Or workarounds to try ?

cyrillay avatar Feb 09 '21 09:02 cyrillay

I haven't done more development using Zappa for a while now so unfortunately I can't help much further here. I've also moved on from the project that was using Zappa so I can't test it out either :(

The way I troubleshooted it was basically by reading through the AWS Lambda changes. I think the wait function is the way to go and you'll have to dig into the new error that comes up.

uuqq avatar Feb 09 '21 13:02 uuqq