There are good answers here, just wanted to add what I found , kind of tricky too.I just wanted to download the entire log stream logs for one of the support case I was working on.
Below command works only on the latest log stream.
$ aws logs get-log-events --log-group-name 'my_log_group' \
--log-stream-name 'my_stream_name' --output text
If the log stream is not latest, we need to specify the --start-from-head flag otherwise it will not give you the logs
without --start-from-head
flag
$ aws logs get-log-events --log-group-name 'my_log_group' \
--log-stream-name 'my_stream_name' --output text
b/3812585230811583357791156477815594204/s f/38126173438735188692892143032919214/s
with --start-from-head
flag
$ aws logs get-log-events --log-group-name 'my_log_group' \
--log-stream-name 'my_stream_name' --output text
b/3812585230811583357791156477815594204/s f/3812617343873518869289214303291960224/s
EVENTS 1709568940700 INIT_START Runtime Version: python:3.12.v29
Runtime Version ARN: arn:aws:lambda:us-east-1::runtime:2fb93380dac14772d30092f171a3f757
Below is the snippet from the aws cli docs
--start-from-head | --no-start-from-head (boolean)
If the value is true, the earliest log events are returned first. If
the value is false,
the latest log events are returned first. The default value is false.
If you are using a previous nextForwardToken value as the nextToken in this operation,
you must specify true for startFromHead .