Basic Usage =========== Using a configuration file (recommended) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 1) The most basic configuration file needed to launch a function is:: cat >> basic-cow.yaml << EOF functions: aws: - lambda: name: scar-cowsay container: image: grycap/cowsay EOF Where you define the name of the function and under it the image that will run inside the function. 2) Once you have created the file then you can create the function with:: scar init -f basic-cow.yaml 3) To execute the function the command is:: scar run -f basic-cow.yaml 4) Checking the function logs is as easy as:: scar log -f basic-cow.yaml 5) Finally to delete the function:: scar rm -f basic-cow.yaml A role must be specified with the flag -r. It must be the ARN code of the role. To find it, search IAM, the Identity and Access Management of AWS. Press the Role tab. Search and select the role name. That will have an structure similar to this arn:aws:iam::{code}:role/{name_of_the_role} 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 2) 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. 3) 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. 4) Remove the Lambda function You can remove the Lambda function together with the logs generated in CloudWatch by:: scar rm -n scar-cowsay