Skip to content

Commit

Permalink
adjusting the headings
Browse files Browse the repository at this point in the history
  • Loading branch information
jschwarzwalder committed Aug 4, 2018
1 parent 3054430 commit f13a425
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 35 deletions.
1 change: 1 addition & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

</p>

==============
SAM CLI (Beta)
==============

Expand Down
23 changes: 13 additions & 10 deletions advanced_usage.rst
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@

==============
Advanced Usage
==============


Compiled Languages
~~~~~~~~~~~~~~~~~~~~~~~~~
------------------

**Java**

Expand Down Expand Up @@ -68,7 +71,7 @@ You can generate a .NET Core example by using the ``sam init --runtime dotnetcor
.. _IAMCreds
IAM Credentials
~~~~~~~~~~~~~~~
---------------

SAM CLI will invoke functions with your locally configured IAM
credentials.
Expand Down Expand Up @@ -98,7 +101,7 @@ CLI <http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.ht
for more details.

Lambda Environment Variables
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
----------------------------

If your Lambda function uses environment variables, you can provide
values for them will passed to the Docker container. Here is how you
Expand Down Expand Up @@ -132,7 +135,7 @@ For example, consider the SAM template snippet:
Environment Variable file
^^^^^^^^^^^^^^^^^^^^^^^^^
-------------------------

Use ``--env-vars`` argument of ``invoke`` or ``start-api`` commands to
provide a JSON file that contains values for environment variables
Expand All @@ -157,7 +160,7 @@ defined in your function. The file should be structured as follows:
Shell environment
^^^^^^^^^^^^^^^^^
-----------------

Variables defined in your Shell’s environment will be passed to the
Docker container, if they map to a Variable in your Lambda function.
Expand All @@ -174,7 +177,7 @@ Following command will make value of ``mytable`` available to both
$ TABLE_NAME=mytable sam local start-api
Combination of Shell and Environment Variable file
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
--------------------------------------------------

For greater control, you can use a combination shell variables and
external environment variable file. If a variable is defined in both
Expand All @@ -187,7 +190,7 @@ lower.
3. Hard-coded values from the template

Identifying local execution from Lambda function code
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-----------------------------------------------------

When your Lambda function is invoked using SAM CLI, it sets an
environment variable ``AWS_SAM_LOCAL=true`` in the Docker container.
Expand All @@ -197,7 +200,7 @@ example: Disable emitting metrics to CloudWatch (or) Enable verbose
logging etc.

Static Assets
~~~~~~~~~~~~~
-------------

Often, it’s useful to serve up static assets (e.g CSS/HTML/Javascript
etc) when developing a Serverless application. On AWS, this would
Expand All @@ -210,7 +213,7 @@ can also disable this behaviour completely by setting
``--static-dir ""``.

Local Logging
~~~~~~~~~~~~~
-------------

Both ``invoke`` and ``start-api`` command allow you to pipe logs from
the function’s invocation into a file. This will be useful if you are
Expand All @@ -224,7 +227,7 @@ Example:
$ sam local invoke --log-file ./output.log
Remote Docker
~~~~~~~~~~~~~
-------------

Sam CLI loads function code by mounting filesystem to a Docker Volume.
As a result, The project directory must be pre-mounted on the remote
Expand Down
20 changes: 11 additions & 9 deletions installation.rst
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
==============
Installation
============
==============

Prerequisites
~~~~~~~~~~~~~
-------------

- Docker
- Python2.7 or Python3.6
Expand All @@ -26,7 +27,7 @@ the CLI (e.g. `docker ps`). You do not need to install/fetch/pull any
containers – SAM CLI will do it automatically as required.

Using PIP
~~~~~~~~~
---------

Step 1. Verify Python Version is 2.7 or 3.6.

Expand Down Expand Up @@ -70,8 +71,8 @@ In Unix/Mac systems the command ``python -m site --user-base`` typically print `
$ USER_BASE_PATH=$(python -m site --user-base)
# Update your preferred shell configuration
## Standard bash --> ~/.bash_profile
## ZSH --> ~/.zshrc
-- Standard bash --> ~/.bash_profile
-- ZSH --> ~/.zshrc
$ export PATH=$PATH:$USER_BASE_PATH/bin
Restart or Open up a new terminal and verify that the installation worked:
Expand Down Expand Up @@ -99,7 +100,7 @@ Copy the File Path.

Seach Windows for ``Edit the system environment variables``.

Select **Enviromental Variables**.
Select **Environmental Variables**.

Under **System variables**, select **Path**.

Expand Down Expand Up @@ -133,7 +134,7 @@ Advanced installations
----------------------

Build From Source
~~~~~~~~~~~~~~~~~
^^^^^^^^^^^^^^^^^

First, install Python(2.7 or 3.6) on your machine, then run the following:

Expand All @@ -149,7 +150,8 @@ First, install Python(2.7 or 3.6) on your machine, then run the following:
$ pip install --user -e .
Install with PyEnv
~~~~~~~~~~~~~~~~~~
^^^^^^^^^^^^^^^^^^

.. code:: bash
# Install PyEnv (https://github.com/pyenv/pyenv#installation)
Expand All @@ -175,7 +177,7 @@ Install with PyEnv
$ sam –version
Troubleshooting
~~~~~~~~~~~~~~~
---------------

Mac Issues
^^^^^^^^^^
Expand Down
33 changes: 17 additions & 16 deletions usage.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
=====
Usage
=====

Expand All @@ -24,14 +25,14 @@ Alternatively, you can find other sample SAM Templates by visiting `SAM <https:/
Lambda <#package-and-deploy-to-lambda>`__

Invoke functions locally
~~~~~~~~~~~~~~~~~~~~~~~~
------------------------

.. figure:: media/sam-invoke.gif
:alt: SAM CLI Invoke Sample

SAM CLI Invoke Sample

You can invoke your function locally by passing its **SAM logical ID**
You can invoke your function locally by passing its --SAM logical ID--
and an event file. Alternatively, ``sam local invoke`` accepts stdin as
an event too.

Expand All @@ -57,7 +58,7 @@ an event too.
Run automated tests for your Lambda functions locally
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-----------------------------------------------------
You can use the ``sam local invoke`` command to manually test your code
by running Lambda function locally. With SAM CLI, you can easily
author automated integration tests by
Expand All @@ -72,7 +73,7 @@ against a deployed SAM stack in your CI/CD pipeline.

Here is how this works:

**1. Start the Local Lambda Endpoint**
**1. Start the Local Lambda Endpoint**

Start the local Lambda endpoint by running the following command in the directory that contains your AWS
SAM template:
Expand All @@ -87,7 +88,7 @@ against this local Lambda endpoint. When you send an invoke to this
endpoint using the AWS CLI or SDK, it will locally execute the Lambda
function specified in the request and return a response.

**2. Run integration test against local Lambda endpoint**
**2. Run integration test against local Lambda endpoint**

In your integration test, you can use AWS SDK to invoke your Lambda function
with test data, wait for response, and assert that the response what you
Expand Down Expand Up @@ -136,7 +137,7 @@ is deployed. To do so, set the ``running_locally`` flag to ``False`` .
This will setup AWS SDK to connect to AWS Lambda service on the cloud.

Connecting to docker network
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
----------------------------

Both ``sam local invoke`` and ``sam local start-api`` support connecting
the create lambda docker containers to an existing docker network.
Expand All @@ -156,7 +157,7 @@ wish to connect to.
Generate sample event source payloads
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-------------------------------------

To make local development and testing of Lambda functions easier, you
can generate mock/sample event payloads for the following services:
Expand Down Expand Up @@ -184,7 +185,7 @@ event payload - Here’s an example using S3:
For more options, see ``sam local generate-event --help``.

Run API Gateway locally
~~~~~~~~~~~~~~~~~~~~~~~
-----------------------

``sam local start-api`` spawns a local API Gateway to test HTTP
request/response functionality. Features hot-reloading to allow you to
Expand Down Expand Up @@ -254,7 +255,7 @@ message to help you diagnose the problem:
ERROR: Function ExampleFunction returned an invalid response (must include one of: body, headers or statusCode in the response object)

Debugging Applications
~~~~~~~~~~~~~~~~~~~~~~
----------------------

Both ``sam local invoke`` and ``sam local start-api`` support local
debugging of your functions.
Expand Down Expand Up @@ -305,14 +306,14 @@ the following launch configuration:
]
}
Note: Node.js versions **below** 7 (e.g. Node.js 4.3 and Node.js 6.10)
Note: Node.js versions --below-- 7 (e.g. Node.js 4.3 and Node.js 6.10)
use the ``legacy`` protocol, while Node.js versions including and above
7 (e.g. Node.js 8.10) use the ``inspector`` protocol. Be sure to specify
the corresponding protocol in the ``protocol`` entry of your launch
configuration.

Debugging Python functions
^^^^^^^^^^^^^^^^^^^^^^^^^^
--------------------------

Unlike Node.JS and Java, Python requires you to enable remote debugging
in your Lambda function code. If you enable debugging with
Expand All @@ -335,7 +336,7 @@ port to your host machine.
updates.

Debugging Golang functions
^^^^^^^^^^^^^^^^^^^^^^^^^^
--------------------------

Golang function debugging is slightly different when compared to Node.JS,
Java, and Python. We require `delve <https://github.com/derekparker/delve>`__
Expand Down Expand Up @@ -385,7 +386,7 @@ attach to a debug session.
Passing Additional Runtime Debug Arguments
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
------------------------------------------

To pass additional runtime arguments when debugging your function, use
the environment variable ``DEBUGGER_ARGS``. This will pass a string
Expand Down Expand Up @@ -413,7 +414,7 @@ find the bug. Note: This command works for all AWS Lambda functions; not
just the ones you deploy using SAM.

Fetch, tail, and filter Lambda function logs
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--------------------------------------------
To simplify troubleshooting, SAM CLI has a command called ``sam logs``.
``sam logs`` lets you fetch logs generated by your Lambda
function from the command line. In addition to printing the logs on the
Expand Down Expand Up @@ -492,7 +493,7 @@ and understand the JSON.
:alt: SAM CLI Logs JSON Pretty Print

Validate SAM templates
~~~~~~~~~~~~~~~~~~~~~~
----------------------

Validate your templates with ``$ sam validate``. Currently this command
will validate that the template provided is valid JSON / YAML. As with
Expand All @@ -511,7 +512,7 @@ option.
Note: The validate command requires AWS credentials to be configured. See `IAM Credentials <#iam-credentials>`__.

Package and Deploy to Lambda
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
----------------------------

Once you have developed and tested your Serverless application locally,
you can deploy to Lambda using ``sam package`` and ``sam deploy``
Expand Down

0 comments on commit f13a425

Please sign in to comment.