Basic Usage

Using CLI configuration (old school)

  1. Create a Lambda function to execute a container (out of a Docker image that is stored in Docker Hub).

In these examples the grycap/cowsay Docker image in Docker Hub will be employed:

scar init -n scar-cowsay -i grycap/cowsay

Notice that the memory and time limits for the Lambda function can be specified in the command-line. Upon first execution, the file $HOME/.scar/scar.cfg is created with default values for the memory and timeout, among other features. The command-line values always take precedence over the values in the configuration file. The default values are 512 MB for the memory and 300 seconds for the timeout.

Further information about the command-line arguments is available in the CLI help:

scar --help
  1. Execute the Lambda function:

    scar run -n scar-cowsay
    
The first invocation to the Lambda function will pull the Docker image from DockerHub so it will take considerably longer than the subsequent invocations, which will most certainly reuse the existing cached Docker image.
  1. Access the logs

The logs are stored in CloudWatch with a default retention policy of 30 days (as default). The following command retrieves all the logs related to the Lambda function:

scar log -n scar-cowsay

If you only want the logs related to a log-stream-name you can use:

scar log -n scar-cowsay -ls 'log-stream-name'

And finally if you know the request id generated by your invocation, you can specify it to get the logs related:

scar log -n scar-cowsay -ri request-id

You can also specify the log stream name to retrieve the values related with the request id, usually this will be faster if the function has generated a lot of log output:

scar log -n scar-cowsay -ls 'log-stream-name' -ri request-id

All values are shown in the output when executing scar log. Do not forget to use the single quotes, as indicated in the example, to avoid unwanted shell expansions.

  1. Remove the Lambda function

You can remove the Lambda function together with the logs generated in CloudWatch by:

scar rm -n scar-cowsay