aws lambda invoke --log-type parameter unimplemented
Confirm by changing [ ] to [x] below to ensure that it's a bug:
- [x] I've gone though the User Guide and the API reference
- [x] I've searched for previous similar issues and didn't find any solution
Describe the bug
The docs for the aws lambda invoke command describe a log-type parameter that would allow tailing of the lambda function logs. When I actually try to use this however I get a NotImplemented error:
$ aws lambda invoke --function-name "SAMFunction" --endpoint-url "http://127.0.0.1:3001" --no-verify-ssl invoke_output.log --log-type Tail
An error occurred (NotImplemented) when calling the Invoke operation: log-type: Tail is not supported. None is only supported.
Please either implement this very useful feature (as far as I can see you currently have to kill the lambda server in order to make it flush the logs to the output file) or correct the docs.
SDK version number
aws-cli/2.2.2
Platform/OS/Hardware/Device What are you running the cli on?
MacOS Big Sur on a 2019 Macbook Pro
To Reproduce (observed behavior) Steps to reproduce the behavior
run the aws lambda invoke command with --log-type Tail
Expected behavior A clear and concise description of what you expected to happen.
The lambda function to be invoked and logs to be streamed to the command line output
Logs/output
Get full traceback and error logs by adding --debug to the command.
aws lambda invoke --function-name "SAMFunction" --endpoint-url "http://127.0.0.1:3001" --no-verify-ssl invoke_output.log --log-type Tail --debug
2021-06-02 12:02:06,841 - MainThread - awscli.clidriver - DEBUG - CLI version: aws-cli/2.2.2 Python/3.8.8 Darwin/20.4.0 exe/x86_64
2021-06-02 12:02:06,841 - MainThread - awscli.clidriver - DEBUG - Arguments entered to CLI: ['lambda', 'invoke', '--function-name', 'SAMFunction', '--endpoint-url', 'http://127.0.0.1:3001', '--no-verify-ssl', 'invoke_output.log', '--log-type', 'Tail', '--debug']
2021-06-02 12:02:06,885 - MainThread - botocore.hooks - DEBUG - Event building-command-table.main: calling handler <function add_s3 at 0x7fe81beee1f0>
2021-06-02 12:02:06,885 - MainThread - botocore.hooks - DEBUG - Event building-command-table.main: calling handler <function add_ddb at 0x7fe81bd748b0>
2021-06-02 12:02:06,885 - MainThread - botocore.hooks - DEBUG - Event building-command-table.main: calling handler <bound method BasicCommand.add_command of <class 'awscli.customizations.configure.configure.ConfigureCommand'>>
2021-06-02 12:02:06,885 - MainThread - botocore.hooks - DEBUG - Event building-command-table.main: calling handler <function change_name at 0x7fe81bd1c040>
2021-06-02 12:02:06,885 - MainThread - botocore.hooks - DEBUG - Event building-command-table.main: calling handler <function change_name at 0x7fe81bd22040>
2021-06-02 12:02:06,885 - MainThread - botocore.hooks - DEBUG - Event building-command-table.main: calling handler <function alias_opsworks_cm at 0x7fe81c040c10>
2021-06-02 12:02:06,886 - MainThread - botocore.hooks - DEBUG - Event building-command-table.main: calling handler <function add_history_commands at 0x7fe81bdbf670>
2021-06-02 12:02:06,886 - MainThread - botocore.hooks - DEBUG - Event building-command-table.main: calling handler <bound method BasicCommand.add_command of <class 'awscli.customizations.devcommands.CLIDevCommand'>>
2021-06-02 12:02:06,886 - MainThread - botocore.hooks - DEBUG - Event building-command-table.main: calling handler <function add_waiters at 0x7fe81c039e50>
2021-06-02 12:02:06,886 - MainThread - botocore.loaders - DEBUG - Loading JSON file: /usr/local/aws-cli/awscli/data/cli.json
2021-06-02 12:02:06,889 - MainThread - botocore.hooks - DEBUG - Event top-level-args-parsed: calling handler <function resolve_types at 0x7fe81be6e160>
2021-06-02 12:02:06,889 - MainThread - botocore.hooks - DEBUG - Event top-level-args-parsed: calling handler <function no_sign_request at 0x7fe81be6eca0>
2021-06-02 12:02:06,889 - MainThread - botocore.hooks - DEBUG - Event top-level-args-parsed: calling handler <function resolve_verify_ssl at 0x7fe81be6ec10>
2021-06-02 12:02:06,889 - MainThread - botocore.hooks - DEBUG - Event top-level-args-parsed: calling handler <function resolve_cli_read_timeout at 0x7fe81be6edc0>
2021-06-02 12:02:06,889 - MainThread - botocore.hooks - DEBUG - Event top-level-args-parsed: calling handler <function resolve_cli_connect_timeout at 0x7fe81be6ed30>
2021-06-02 12:02:06,889 - MainThread - botocore.hooks - DEBUG - Event top-level-args-parsed: calling handler <built-in method update of dict object at 0x7fe81c0dba40>
2021-06-02 12:02:06,890 - MainThread - awscli.clidriver - DEBUG - CLI version: aws-cli/2.2.2 Python/3.8.8 Darwin/20.4.0 exe/x86_64 prompt/off
2021-06-02 12:02:06,890 - MainThread - awscli.clidriver - DEBUG - Arguments entered to CLI: ['lambda', 'invoke', '--function-name', 'SAMFunction', '--endpoint-url', 'http://127.0.0.1:3001', '--no-verify-ssl', 'invoke_output.log', '--log-type', 'Tail', '--debug']
2021-06-02 12:02:06,890 - MainThread - botocore.hooks - DEBUG - Event session-initialized: calling handler <function add_timestamp_parser at 0x7fe81beee820>
2021-06-02 12:02:06,890 - MainThread - botocore.hooks - DEBUG - Event session-initialized: calling handler <function register_uri_param_handler at 0x7fe81baca670>
2021-06-02 12:02:06,890 - MainThread - botocore.hooks - DEBUG - Event session-initialized: calling handler <function add_binary_formatter at 0x7fe81c0a3310>
2021-06-02 12:02:06,890 - MainThread - botocore.hooks - DEBUG - Event session-initialized: calling handler <function no_pager_handler at 0x7fe81bac4a60>
2021-06-02 12:02:06,890 - MainThread - botocore.hooks - DEBUG - Event session-initialized: calling handler <function inject_assume_role_provider_cache at 0x7fe81bb29040>
2021-06-02 12:02:06,892 - MainThread - botocore.utils - DEBUG - IMDS ENDPOINT: http://169.254.169.254/
2021-06-02 12:02:06,899 - MainThread - botocore.hooks - DEBUG - Event session-initialized: calling handler <function attach_history_handler at 0x7fe81bdbf550>
2021-06-02 12:02:06,900 - MainThread - botocore.hooks - DEBUG - Event session-initialized: calling handler <function inject_json_file_cache at 0x7fe81bd6f790>
2021-06-02 12:02:06,953 - MainThread - botocore.loaders - DEBUG - Loading JSON file: /usr/local/aws-cli/botocore/data/lambda/2015-03-31/service-2.json
2021-06-02 12:02:06,962 - MainThread - botocore.hooks - DEBUG - Event building-command-table.lambda: calling handler <function _add_wizard_command at 0x7fe81c0a3280>
2021-06-02 12:02:06,962 - MainThread - botocore.hooks - DEBUG - Event building-command-table.lambda: calling handler <function add_waiters at 0x7fe81c039e50>
2021-06-02 12:02:07,015 - MainThread - botocore.loaders - DEBUG - Loading JSON file: /usr/local/aws-cli/botocore/data/lambda/2015-03-31/waiters-2.json
2021-06-02 12:02:07,016 - MainThread - awscli.clidriver - DEBUG - OrderedDict([('function-name', <awscli.arguments.CLIArgument object at 0x7fe81c4de7f0>), ('invocation-type', <awscli.arguments.CLIArgument object at 0x7fe81c4de730>), ('log-type', <awscli.arguments.CLIArgument object at 0x7fe81c4de700>), ('client-context', <awscli.arguments.CLIArgument object at 0x7fe81c4de6a0>), ('payload', <awscli.arguments.CLIArgument object at 0x7fe81c4de670>), ('qualifier', <awscli.arguments.CLIArgument object at 0x7fe81c4de640>)])
2021-06-02 12:02:07,016 - MainThread - botocore.hooks - DEBUG - Event building-argument-table.lambda.invoke: calling handler <function add_streaming_output_arg at 0x7fe81beeedc0>
2021-06-02 12:02:07,016 - MainThread - botocore.hooks - DEBUG - Event building-argument-table.lambda.invoke: calling handler <function add_cli_input_json at 0x7fe81bb298b0>
2021-06-02 12:02:07,016 - MainThread - botocore.hooks - DEBUG - Event building-argument-table.lambda.invoke: calling handler <function add_cli_input_yaml at 0x7fe81bb29b80>
2021-06-02 12:02:07,016 - MainThread - botocore.hooks - DEBUG - Event building-argument-table.lambda.invoke: calling handler <function unify_paging_params at 0x7fe81bd74ee0>
2021-06-02 12:02:07,065 - MainThread - botocore.loaders - DEBUG - Loading JSON file: /usr/local/aws-cli/botocore/data/lambda/2015-03-31/paginators-1.json
2021-06-02 12:02:07,065 - MainThread - botocore.hooks - DEBUG - Event building-argument-table.lambda.invoke: calling handler <function add_generate_skeleton at 0x7fe81be64700>
2021-06-02 12:02:07,066 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.lambda.invoke.function-name: calling handler <awscli.paramfile.URIArgumentHandler object at 0x7fe81c119220>
2021-06-02 12:02:07,066 - MainThread - botocore.hooks - DEBUG - Event process-cli-arg.lambda.invoke: calling handler <awscli.argprocess.ParamShorthandParser object at 0x7fe81baedb50>
2021-06-02 12:02:07,067 - MainThread - awscli.arguments - DEBUG - Unpacked value of 'SAMFunction' for parameter "function_name": 'SAMFunction'
2021-06-02 12:02:07,067 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.lambda.invoke.invocation-type: calling handler <awscli.paramfile.URIArgumentHandler object at 0x7fe81c119220>
2021-06-02 12:02:07,067 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.lambda.invoke.log-type: calling handler <awscli.paramfile.URIArgumentHandler object at 0x7fe81c119220>
2021-06-02 12:02:07,067 - MainThread - botocore.hooks - DEBUG - Event process-cli-arg.lambda.invoke: calling handler <awscli.argprocess.ParamShorthandParser object at 0x7fe81baedb50>
2021-06-02 12:02:07,067 - MainThread - awscli.arguments - DEBUG - Unpacked value of 'Tail' for parameter "log_type": 'Tail'
2021-06-02 12:02:07,067 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.lambda.invoke.client-context: calling handler <awscli.paramfile.URIArgumentHandler object at 0x7fe81c119220>
2021-06-02 12:02:07,067 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.lambda.invoke.payload: calling handler <awscli.paramfile.URIArgumentHandler object at 0x7fe81c119220>
2021-06-02 12:02:07,067 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.lambda.invoke.qualifier: calling handler <awscli.paramfile.URIArgumentHandler object at 0x7fe81c119220>
2021-06-02 12:02:07,067 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.lambda.invoke.outfile: calling handler <awscli.paramfile.URIArgumentHandler object at 0x7fe81c119220>
2021-06-02 12:02:07,067 - MainThread - botocore.credentials - DEBUG - Looking for credentials via: env
2021-06-02 12:02:07,067 - MainThread - botocore.credentials - DEBUG - Looking for credentials via: assume-role
2021-06-02 12:02:07,067 - MainThread - botocore.credentials - DEBUG - Looking for credentials via: assume-role-with-web-identity
2021-06-02 12:02:07,067 - MainThread - botocore.credentials - DEBUG - Looking for credentials via: sso
2021-06-02 12:02:07,068 - MainThread - botocore.credentials - DEBUG - Looking for credentials via: shared-credentials-file
2021-06-02 12:02:07,068 - MainThread - botocore.credentials - INFO - Found credentials in shared credentials file: ~/.aws/credentials
2021-06-02 12:02:07,068 - MainThread - botocore.loaders - DEBUG - Loading JSON file: /usr/local/aws-cli/botocore/data/endpoints.json
2021-06-02 12:02:07,075 - MainThread - botocore.hooks - DEBUG - Event choose-service-name: calling handler <function handle_service_name_alias at 0x7fe81b1f0700>
2021-06-02 12:02:07,076 - MainThread - botocore.hooks - DEBUG - Event creating-client-class.lambda: calling handler <function add_generate_presigned_url at 0x7fe81b19ca60>
2021-06-02 12:02:07,083 - MainThread - botocore.endpoint - DEBUG - Setting lambda timeout as (60, 60)
2021-06-02 12:02:07,083 - MainThread - botocore.hooks - DEBUG - Event provide-client-params.lambda.Invoke: calling handler <function base64_decode_input_blobs at 0x7fe81c0a3a60>
2021-06-02 12:02:07,084 - MainThread - botocore.hooks - DEBUG - Event before-parameter-build.lambda.Invoke: calling handler <function generate_idempotent_uuid at 0x7fe81b20f700>
2021-06-02 12:02:07,084 - MainThread - botocore.hooks - DEBUG - Event before-call.lambda.Invoke: calling handler <function inject_api_version_header_if_needed at 0x7fe81b213f70>
2021-06-02 12:02:07,084 - MainThread - botocore.endpoint - DEBUG - Making request for OperationModel(name=Invoke) with params: {'url_path': '/2015-03-31/functions/SAMFunction/invocations', 'query_string': {}, 'method': 'POST', 'headers': {'X-Amz-Log-Type': 'Tail', 'User-Agent': 'aws-cli/2.2.2 Python/3.8.8 Darwin/20.4.0 exe/x86_64 prompt/off command/lambda.invoke'}, 'body': b'', 'url': 'http://127.0.0.1:3001/2015-03-31/functions/SAMFunction/invocations', 'context': {'client_region': 'us-east-1', 'client_config': <botocore.config.Config object at 0x7fe81c7a73d0>, 'has_streaming_input': True, 'auth_type': None}}
2021-06-02 12:02:07,084 - MainThread - botocore.hooks - DEBUG - Event request-created.lambda.Invoke: calling handler <bound method RequestSigner.handler of <botocore.signers.RequestSigner object at 0x7fe81c7a7490>>
2021-06-02 12:02:07,084 - MainThread - botocore.hooks - DEBUG - Event choose-signer.lambda.Invoke: calling handler <function set_operation_specific_signer at 0x7fe81b20f5e0>
2021-06-02 12:02:07,084 - MainThread - botocore.auth - DEBUG - Calculating signature using v4 auth.
2021-06-02 12:02:07,084 - MainThread - botocore.auth - DEBUG - CanonicalRequest:
POST
/2015-03-31/functions/SAMFunction/invocations
host:127.0.0.1:3001
x-amz-date:20210602T110207Z
x-amz-log-type:Tail
host;x-amz-date;x-amz-log-type
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
2021-06-02 12:02:07,084 - MainThread - botocore.auth - DEBUG - StringToSign:
AWS4-HMAC-SHA256
20210602T110207Z
20210602/us-east-1/lambda/aws4_request
f5605033ee95f84630e452f0d9689518e9f7cd0c12f8452333373d6630129a1f
2021-06-02 12:02:07,085 - MainThread - botocore.auth - DEBUG - Signature:
157a6449756cec80b453e6142e3d690f6293efb33c6321124677b4b6f2387454
2021-06-02 12:02:07,085 - MainThread - botocore.endpoint - DEBUG - Sending http request: <AWSPreparedRequest stream_output=True, method=POST, url=http://127.0.0.1:3001/2015-03-31/functions/SAMFunction/invocations, headers={'X-Amz-Log-Type': b'Tail', 'User-Agent': b'aws-cli/2.2.2 Python/3.8.8 Darwin/20.4.0 exe/x86_64 prompt/off command/lambda.invoke', 'X-Amz-Date': b'20210602T110207Z', 'Authorization': b'AWS4-HMAC-SHA256 Credential=AKIAXT6RDSSW2WHPZDGT/20210602/us-east-1/lambda/aws4_request, SignedHeaders=host;x-amz-date;x-amz-log-type, Signature=157a6449756cec80b453e6142e3d690f6293efb33c6321124677b4b6f2387454', 'Content-Length': '0'}>
2021-06-02 12:02:07,085 - MainThread - urllib3.connectionpool - DEBUG - Starting new HTTP connection (1): 127.0.0.1:3001
2021-06-02 12:02:07,088 - MainThread - urllib3.connectionpool - DEBUG - http://127.0.0.1:3001 "POST /2015-03-31/functions/SAMFunction/invocations HTTP/1.1" 501 95
2021-06-02 12:02:07,088 - MainThread - botocore.parsers - DEBUG - Response headers: {'x-amzn-errortype': 'NotImplemented', 'Content-Type': 'application/json', 'Content-Length': '95', 'Server': 'Werkzeug/1.0.1 Python/3.8.10', 'Date': 'Wed, 02 Jun 2021 11:02:07 GMT'}
2021-06-02 12:02:07,088 - MainThread - botocore.parsers - DEBUG - Response body:
b'{"Type": "LocalService", "Message": "log-type: Tail is not supported. None is only supported."}'
2021-06-02 12:02:07,090 - MainThread - botocore.hooks - DEBUG - Event needs-retry.lambda.Invoke: calling handler <bound method RetryHandler.needs_retry of <botocore.retries.standard.RetryHandler object at 0x7fe81c7a7ee0>>
2021-06-02 12:02:07,090 - MainThread - botocore.retries.standard - DEBUG - Not retrying request.
2021-06-02 12:02:07,090 - MainThread - botocore.hooks - DEBUG - Event after-call.lambda.Invoke: calling handler <bound method StreamingOutputArgument.save_file of <awscli.customizations.streamingoutputarg.StreamingOutputArgument object at 0x7fe81c4dea60>>
2021-06-02 12:02:07,090 - MainThread - botocore.hooks - DEBUG - Event after-call.lambda.Invoke: calling handler <bound method RetryQuotaChecker.release_retry_quota of <botocore.retries.standard.RetryQuotaChecker object at 0x7fe81c7a7a60>>
2021-06-02 12:02:07,091 - MainThread - awscli.clidriver - DEBUG - Exception caught in main()
Traceback (most recent call last):
File "awscli/clidriver.py", line 459, in main
File "awscli/clidriver.py", line 594, in __call__
File "awscli/clidriver.py", line 770, in __call__
File "awscli/clidriver.py", line 901, in invoke
File "awscli/clidriver.py", line 913, in _make_client_call
File "botocore/client.py", line 249, in _api_call
File "botocore/client.py", line 568, in _make_api_call
botocore.exceptions.ClientError: An error occurred (NotImplemented) when calling the Invoke operation: log-type: Tail is not supported. None is only supported.
An error occurred (NotImplemented) when calling the Invoke operation: log-type: Tail is not supported. None is only supported.
Additional context Add any other context about the problem here.
Hi @lilycj,
Thanks for reaching out! I tested myself on version 2.2.5 and was not able to reproduce. I took a look at the Lambda models in botocore and noticed that Tail was added as a value for the --log-type parameter back in 2015, so it should work with the version you have. I would suggest trying an uninstall/reinstall in the off chance the CLI is using an old version of botocore. Let me know how it goes!
hi Sean, I tried updating to 2.2.6, but still had the issue, so I uninstalled and reinstalled 2.2.6, but I got the same thing. I noticed when I do aws --version it prints aws-cli/2.2.6 Python/3.8.8 Darwin/20.5.0 exe/x86_64 prompt/off. In the docs the example has the botocore version there, but mine doesn't. How can I see what botocore version it's using, or see what python installation it's using so I can install to it manually? Thanks!
Hi @lilycj,
My apologies for leading you down the re-install path— I totally missed that you're invoking a SAM local lambda. For aws CLI v2, the botocore version is isolated (same with the python interpreter). I thought initially that this may have been a conflict between an older (v1) installation and your v2 version.
Are you using the SAM CLI? This may be something we need to transfer over to their repository. I see some options in sam logs that may allow you to work around this for the time being.
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.
Hi @stobrien89, I am using the SAM cli yes, I forgot about this issue as I discovered that adding --debug to the sam local start-lambda command allows logs to be streamed to the lambda server.
Hi @lilycj,
Glad you were able to find a workaround! Please let us know if you have any additional questions.