aws / aws-cli

Universal Command Line Interface for Amazon Web Services
Other
15.58k stars 4.13k forks source link

Lambda update-function-code not working #5367

Closed Leoputera2407 closed 4 years ago

Leoputera2407 commented 4 years ago

Confirm by changing [ ] to [x] below to ensure that it's a bug:

Describe the bug I was trying to push new code for my lambda function using aws-cli on AWS Linux 2 EC2 instance. Ran this code aws lambda update-function-code --function-name --zip-file fileb://function.zip But, it returns no output and lambda code wasn't updated.

SDK version number aws-cli/1.18.13 Python/2.7.18 Linux/4.14.181-108.257.amzn1.x86_64 botocore/1.15.13

Platform/OS/Hardware/Device AWS Linux 2 (EC2) on a MacOs Catalina Version 10.15.5

Expected behavior Expected the command to output a report on which lambda function was updated and that the lambda function was updated.

Logs/output

2020-07-09 23:48:34,953 - MainThread - awscli.clidriver - DEBUG - CLI version: aws-cli/1.18.13 Python/2.7.18 Linux/4.14.181-108.257.amzn1.x86_64 botocore/1.15.13 2020-07-09 23:48:34,953 - MainThread - awscli.clidriver - DEBUG - Arguments entered to CLI: ['lambda', 'update-function-code', '--function-name', '', '--zip-file', 'fileb://function.zip', '--debug'] 2020-07-09 23:48:34,953 - MainThread - botocore.hooks - DEBUG - Event session-initialized: calling handler <function add_scalar_parsers at 0x7fd04cdf9f50> 2020-07-09 23:48:34,953 - MainThread - botocore.hooks - DEBUG - Event session-initialized: calling handler <function register_uri_param_handler at 0x7fd04dc53350> 2020-07-09 23:48:34,954 - MainThread - botocore.hooks - DEBUG - Event session-initialized: calling handler <function inject_assume_role_provider_cache at 0x7fd04dc776d0> 2020-07-09 23:48:34,955 - MainThread - botocore.hooks - DEBUG - Event session-initialized: calling handler <function attach_history_handler at 0x7fd04d1964d0> 2020-07-09 23:48:34,958 - MainThread - botocore.loaders - DEBUG - Loading JSON file: /usr/lib/python2.7/dist-packages/botocore/data/lambda/2015-03-31/service-2.json 2020-07-09 23:48:34,978 - MainThread - botocore.hooks - DEBUG - Event building-command-table.lambda: calling handler <function add_waiters at 0x7fd04ce1cd50> 2020-07-09 23:48:34,985 - MainThread - botocore.loaders - DEBUG - Loading JSON file: /usr/lib/python2.7/dist-packages/botocore/data/lambda/2015-03-31/waiters-2.json 2020-07-09 23:48:34,987 - MainThread - awscli.clidriver - DEBUG - OrderedDict([(u'function-name', <awscli.arguments.CLIArgument object at 0x7fd04ca65c90>), (u'zip-file', <awscli.arguments.CLIArgument object at 0x7fd04ca65b50>), (u's3-bucket', <awscli.arguments.CLIArgument object at 0x7fd04ca65e10>), (u's3-key', <awscli.arguments.CLIArgument object at 0x7fd04ca65e50>), (u's3-object-version', <awscli.arguments.CLIArgument object at 0x7fd04ca65ed0>), (u'publish', <awscli.arguments.BooleanArgument object at 0x7fd04ca65e90>), (u'no-publish', <awscli.arguments.BooleanArgument object at 0x7fd04ca65f10>), (u'dry-run', <awscli.arguments.BooleanArgument object at 0x7fd04ca65f50>), (u'no-dry-run', <awscli.arguments.BooleanArgument object at 0x7fd04ca65f90>), (u'revision-id', <awscli.arguments.CLIArgument object at 0x7fd04ca65fd0>)]) 2020-07-09 23:48:34,988 - MainThread - botocore.hooks - DEBUG - Event building-argument-table.lambda.update-function-code: calling handler <function add_streaming_output_arg at 0x7fd04ce147d0> 2020-07-09 23:48:34,988 - MainThread - botocore.hooks - DEBUG - Event building-argument-table.lambda.update-function-code: calling handler <function _modify_zipfile_docstring at 0x7fd04dc77f50> 2020-07-09 23:48:34,988 - MainThread - botocore.hooks - DEBUG - Event building-argument-table.lambda.update-function-code: calling handler <function add_cli_input_json at 0x7fd04dc7cbd0> 2020-07-09 23:48:34,988 - MainThread - botocore.hooks - DEBUG - Event building-argument-table.lambda.update-function-code: calling handler <function unify_paging_params at 0x7fd051cffc50> 2020-07-09 23:48:34,994 - MainThread - botocore.loaders - DEBUG - Loading JSON file: /usr/lib/python2.7/dist-packages/botocore/data/lambda/2015-03-31/paginators-1.json 2020-07-09 23:48:34,995 - MainThread - botocore.hooks - DEBUG - Event building-argument-table.lambda.update-function-code: calling handler <function add_generate_skeleton at 0x7fd051ce1050> 2020-07-09 23:48:34,995 - MainThread - botocore.hooks - DEBUG - Event before-building-argument-table-parser.lambda.update-function-code: calling handler <bound method CliInputJSONArgument.override_required_args of <awscli.customizations.cliinputjson.CliInputJSONArgument object at 0x7fd04ca65a10>> 2020-07-09 23:48:34,995 - MainThread - botocore.hooks - DEBUG - Event before-building-argument-table-parser.lambda.update-function-code: calling handler <bound method GenerateCliSkeletonArgument.override_required_args of <awscli.customizations.generatecliskeleton.GenerateCliSkeletonArgument object at 0x7fd04ca6d390>> 2020-07-09 23:48:34,997 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.lambda.update-function-code.function-name: calling handler <awscli.paramfile.URIArgumentHandler object at 0x7fd04ccc5bd0> 2020-07-09 23:48:34,997 - MainThread - botocore.hooks - DEBUG - Event process-cli-arg.lambda.update-function-code: calling handler <function validate_is_zip_file at 0x7fd04dc77ed0> 2020-07-09 23:48:34,997 - MainThread - botocore.hooks - DEBUG - Event process-cli-arg.lambda.update-function-code: calling handler <awscli.argprocess.ParamShorthandParser object at 0x7fd04dc4dbd0> 2020-07-09 23:48:34,998 - MainThread - awscli.arguments - DEBUG - Unpacked value of u'arn:aws:lambda:us-west-2:311569361338:function:hanif_test_lex' for parameter "function_name": u'arn:aws:lambda:us-west-2:311569361338:function:hanif_test_lex' 2020-07-09 23:48:34,998 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.lambda.update-function-code.zip-file: calling handler <awscli.paramfile.URIArgumentHandler object at 0x7fd04ccc5bd0> 2020-07-09 23:48:35,139 - MainThread - botocore.hooks - DEBUG - Event process-cli-arg.lambda.update-function-code: calling handler <function validate_is_zip_file at 0x7fd04dc77ed0> 2020-07-09 23:48:35,184 - MainThread - botocore.hooks - DEBUG - Event process-cli-arg.lambda.update-function-code: calling handler <awscli.argprocess.ParamShorthandParser object at 0x7fd04dc4dbd0> Traceback (most recent call last): File "/usr/lib64/python2.7/logging/init.py", line 868, in emit msg = self.format(record) File "/usr/lib64/python2.7/logging/init.py", line 741, in format return fmt.format(record) File "/usr/lib64/python2.7/logging/init.py", line 465, in format record.message = record.getMessage() File "/usr/lib64/python2.7/logging/init.py", line 329, in getMessage msg = msg % self.args MemoryError Logged from file arguments.py, line 455 2020-07-09 23:48:42,061 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.lambda.update-function-code.s3-bucket: calling handler <awscli.paramfile.URIArgumentHandler object at 0x7fd04ccc5bd0> 2020-07-09 23:48:42,065 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.lambda.update-function-code.s3-key: calling handler <awscli.paramfile.URIArgumentHandler object at 0x7fd04ccc5bd0> 2020-07-09 23:48:42,065 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.lambda.update-function-code.s3-object-version: calling handler <awscli.paramfile.URIArgumentHandler object at 0x7fd04ccc5bd0> 2020-07-09 23:48:42,065 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.lambda.update-function-code.publish: calling handler <awscli.paramfile.URIArgumentHandler object at 0x7fd04ccc5bd0> 2020-07-09 23:48:42,066 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.lambda.update-function-code.dry-run: calling handler <awscli.paramfile.URIArgumentHandler object at 0x7fd04ccc5bd0> 2020-07-09 23:48:42,066 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.lambda.update-function-code.revision-id: calling handler <awscli.paramfile.URIArgumentHandler object at 0x7fd04ccc5bd0> 2020-07-09 23:48:42,066 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.lambda.update-function-code.cli-input-json: calling handler <awscli.paramfile.URIArgumentHandler object at 0x7fd04ccc5bd0> 2020-07-09 23:48:42,067 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.lambda.update-function-code.generate-cli-skeleton: calling handler <awscli.paramfile.URIArgumentHandler object at 0x7fd04ccc5bd0> 2020-07-09 23:48:42,067 - MainThread - botocore.hooks - DEBUG - Event calling-command.lambda.update-function-code: calling handler <bound method CliInputJSONArgument.add_to_call_parameters of <awscli.customizations.cliinputjson.CliInputJSONArgument object at 0x7fd04ca65a10>> 2020-07-09 23:48:42,067 - MainThread - botocore.hooks - DEBUG - Event calling-command.lambda.update-function-code: calling handler <bound method GenerateCliSkeletonArgument.generate_json_skeleton of <awscli.customizations.generatecliskeleton.GenerateCliSkeletonArgument object at 0x7fd04ca6d390>> 2020-07-09 23:48:42,067 - MainThread - botocore.credentials - DEBUG - Looking for credentials via: env 2020-07-09 23:48:42,067 - MainThread - botocore.credentials - DEBUG - Looking for credentials via: assume-role 2020-07-09 23:48:42,068 - MainThread - botocore.credentials - DEBUG - Looking for credentials via: assume-role-with-web-identity 2020-07-09 23:48:42,068 - MainThread - botocore.credentials - DEBUG - Looking for credentials via: shared-credentials-file 2020-07-09 23:48:42,070 - MainThread - botocore.credentials - INFO - Found credentials in shared credentials file: ~/.aws/credentials 2020-07-09 23:48:42,078 - MainThread - botocore.loaders - DEBUG - Loading JSON file: /usr/lib/python2.7/dist-packages/botocore/data/endpoints.json 2020-07-09 23:48:42,139 - MainThread - botocore.hooks - DEBUG - Event choose-service-name: calling handler <function handle_service_name_alias at 0x7fd04f6f5650> 2020-07-09 23:48:42,141 - MainThread - botocore.hooks - DEBUG - Event creating-client-class.lambda: calling handler <function add_generate_presigned_url at 0x7fd04f783ad0> 2020-07-09 23:48:42,147 - MainThread - botocore.endpoint - DEBUG - Setting lambda timeout as (60, 60) 2020-07-09 23:49:08,280 - MainThread - botocore.credentials - DEBUG - Looking for credentials via: assume-role 2020-07-09 23:49:08,280 - MainThread - botocore.credentials - DEBUG - Looking for credentials via: assume-role-with-web-identity 2020-07-09 23:49:08,280 - MainThread - botocore.credentials - DEBUG - Looking for credentials via: shared-credentials-file 2020-07-09 23:49:08,282 - MainThread - botocore.credentials - INFO - Found credentials in shared credentials file: ~/.aws/credentials 2020-07-09 23:49:08,291 - MainThread - botocore.loaders - DEBUG - Loading JSON file: /usr/lib/python2.7/dist-packages/botocore/data/endpoints.json 2020-07-09 23:49:08,350 - MainThread - botocore.hooks - DEBUG - Event choose-service-name: calling handler <function handle_service_name_alias at 0x7f17075d0650> 2020-07-09 23:49:08,353 - MainThread - botocore.hooks - DEBUG - Event creating-client-class.lambda: calling handler <function add_generate_presigned_url at 0x7f170765ead0> 2020-07-09 23:49:08,381 - MainThread - botocore.endpoint - DEBUG - Setting lambda timeout as (60, 60) 2020-07-09 23:49:08,454 - MainThread - botocore.loaders - DEBUG - Loading JSON file: /usr/lib/python2.7/dist-packages/botocore/data/_retry.json 2020-07-09 23:49:08,456 - MainThread - botocore.client - DEBUG - Registering retry handlers for service: lambda 2020-07-09 23:49:08,457 - MainThread - botocore.hooks - DEBUG - Event before-parameter-build.lambda.UpdateFunctionCode: calling handler <function generate_idempotent_uuid at 0x7f17075d3550> 2020-07-09 23:49:09,370 - MainThread - awscli.clidriver - DEBUG - Exception caught in main() Traceback (most recent call last): File "/usr/lib/python2.7/dist-packages/awscli/clidriver.py", line 217, in main return command_table[parsed_args.command](remaining, parsed_args) File "/usr/lib/python2.7/dist-packages/awscli/clidriver.py", line 358, in call return command_table[parsed_args.operation](remaining, parsed_globals) File "/usr/lib/python2.7/dist-packages/awscli/clidriver.py", line 530, in call call_parameters, parsed_globals) File "/usr/lib/python2.7/dist-packages/awscli/clidriver.py", line 650, in invoke client, operation_name, parameters, parsed_globals) File "/usr/lib/python2.7/dist-packages/awscli/clidriver.py", line 662, in _make_client_call **parameters) File "/usr/lib/python2.7/dist-packages/botocore/client.py", line 316, in _api_call return self._make_api_call(operation_name, kwargs) File "/usr/lib/python2.7/dist-packages/botocore/client.py", line 599, in _make_api_call api_params, operation_model, context=request_context) File "/usr/lib/python2.7/dist-packages/botocore/client.py", line 647, in _convert_to_request_dict api_params, operation_model) File "/usr/lib/python2.7/dist-packages/botocore/validate.py", line 299, in serialize_to_request operation_model) File "/usr/lib/python2.7/dist-packages/botocore/serialize.py", line 457, in serialize_to_request serialized, shape, shape_members) File "/usr/lib/python2.7/dist-packages/botocore/serialize.py", line 507, in _serialize_payload partitioned['body_kwargs'], shape) File "/usr/lib/python2.7/dist-packages/botocore/serialize.py", line 586, in _serialize_body_params return json.dumps(serialized_body).encode(self.DEFAULT_ENCODING) MemoryError 2020-07-09 23:49:09,375 - MainThread - awscli.clidriver - DEBUG - Exiting with rc 255

Additional context Add any other context about the problem here.

KaibaLopez commented 4 years ago

Hi @Leoputera2407 , On the logs it mentions a memory error, can you tell me the size of your function's .zip is?

Leoputera2407 commented 4 years ago

HI @KaibaLopez, It's about 20Mb. I noticed that it's a recurring a problem. It happens randomly once in a while, where without the --debug flag, there weren't any output to the cli.

KaibaLopez commented 4 years ago

@Leoputera2407 , sorry what do you mean by "happens randomly once in a while"? do you mean that sometimes the call works and sometimes it fails? Or it fails every time but sometimes you don't get an output without --debug?

Leoputera2407 commented 4 years ago

Sometimes the 'aws lambda update-function-code` works and sometimes it fails. But, when it failed and I used the --debug command, that's the error message I got.

yadavsahil197 commented 4 years ago

@Leoputera2407 I was facing the same issue, debug output showing out of memory error. The problem was fixed after upgrading to the latest cli. aws-cli/1.18.99 Python/3.6.10 Linux/4.14.138-89.102.amzn1.x86_64 botocore/1.17.22

KaibaLopez commented 4 years ago

@Leoputera2407 , Can you try updating to the latest release and see if that works for you too?

github-actions[bot] commented 4 years ago

Greetings! It looks like this issue hasn’t been active in longer than a week. We encourage you to check if this is still an issue in the latest release. Because it has been longer than a week since the last update on this, and in the absence of more information, we will be closing this issue soon. If you find that this is still a problem, please feel free to provide a comment or add an upvote to prevent automatic closure, or if the issue is already closed, please feel free to open a new one.

kangear commented 2 years ago

work on the ec2

sudo yum remove awscli
pip3 install awscli --upgrade --user