1- ============================================
1+ ==============================
22Deploy to AWS Lambda with Bref
3- ============================================
3+ ==============================
44
55.. default-domain:: mongodb
66
@@ -15,28 +15,28 @@ Deploy to AWS Lambda with Bref
1515Overview
1616--------
1717
18- `Bref <https://bref.sh>` allows to deploy serverless PHP applications on AWS Lambda.
18+ `Bref <https://bref.sh>`_ allows to deploy serverless PHP applications on AWS Lambda.
1919In this tutorial, you will deploy a simple PHP application with the MongoDB PHP extension,
2020and connect to an Atlas cluster using AWS IAM authentication.
2121
2222Prerequisites
2323--------------
2424
2525Before you begin, you must install Bref on your machine. You can follow the
26- `official documentation to setup bref <https://bref.sh/docs/setup>`_.
26+ `official documentation to setup Bref <https://bref.sh/docs/setup>`_.
2727
2828Install the MongoDB extension
2929-----------------------------
3030
3131By default, the bref layer is compiled with PHP and a few extensions. Additional extensions
3232are provided in additional layers.
3333
34- Start by creating a new directory for your project and install the required mongodb
35- and bref dependencies. This project will be a bare minimum PHP web application that
36- connects to a MongoDB cluster. No framework is used, but you can adapt the code to
37- your needs.
34+ Start by creating a new directory for your project and install the required MongoDB
35+ and Bref dependencies. This project will be a bare minimum PHP web application that
36+ connects to a MongoDB cluster.
3837
3938.. code-block:: bash
39+
4040 mkdir bref-mongodb-app && cd bref-mongodb-app
4141 composer init
4242 composer require bref/bref bref/extra-php-extensions
@@ -47,10 +47,12 @@ The file ``index.php`` has been created. To validate the deployment, you can sta
4747by deploying this default application.
4848
4949.. code-block:: bash
50+
5051 serverless deploy
5152
53+
5254Bref provides a Lambda layer with PHP and some very common extensions.
53- Additional extensions are provided by the package `bref/extra-php-extension <https://github.com/brefphp/extra-php-extensions>`.
55+ Additional extensions are provided by the package `bref/extra-php-extension <https://github.com/brefphp/extra-php-extensions>`_ .
5456
5557.. code-block:: yaml
5658
@@ -67,16 +69,17 @@ Additional extensions are provided by the package `bref/extra-php-extension <htt
6769
6870
6971Let's try to use the MongoDB driver with this simple web page that list planets
70- from the `sample dataset <https://www.mongodb.com/docs/atlas/sample-data/>`.
72+ from the `sample dataset <https://www.mongodb.com/docs/atlas/sample-data/>`_ .
7173Replace the contents of ``index.php`` with the following:
7274
73- .. literalinclude:: /examples/lambda- aws/index.php
75+ .. literalinclude:: /examples/aws-lambda /index.php
7476 :language: php
7577
7678
7779Deploy the application
7880
7981.. code-block:: bash
82+
8083 serverless deploy
8184
8285
@@ -89,7 +92,7 @@ Atlas supports passwordless authentication with AWS credentials. In any Lambda f
8992AWS sets environment variables that contains the access token and secret token with
9093the role assigned to deployed function.
9194
92- Set up `unified AWS Access <https://www.mongodb.com/docs/atlas/security/set-up-unified-aws-access/>`
95+ Set up `unified AWS Access <https://www.mongodb.com/docs/atlas/security/set-up-unified-aws-access/>`_
9396
94971. Open the Lambda function in the AWS console
95982. In "Configuration > Permission", copy the "Role name"
@@ -113,7 +116,7 @@ Update the ``serverless.yml`` file to pass the environment variable ``MONGODB_UR
113116
114117
115118The value can be found in "Atlas > Deployment > Database > Connect". Select "3. AWS IAM".
116- You can remove the ``<AWS access key>:<AWS secret key>`` part from the URI, the credentials
119+ Remove the ``<AWS access key>:<AWS secret key>`` part from the URI, the credentials
117120will be read from environment variables.
118121
119122.. code-block:: bash
0 commit comments