@@ -20,8 +20,8 @@ Deploy to AWS Lambda
20
20
Overview
21
21
--------
22
22
23
- In this guide, you can learn how to use the tool `Bref
24
- <https://bref.sh>`__ to deploy serverless PHP applications on AWS
23
+ In this guide, you can learn how to use `Bref
24
+ <https://bref.sh>`__ to deploy serverless PHP applications to AWS
25
25
Lambda. This guide demonstrates how to deploy a PHP application built by
26
26
using the {+library-short+} and connect to an Atlas cluster by using AWS
27
27
IAM authentication.
@@ -43,9 +43,9 @@ Install Dependencies
43
43
44
44
Bref uses `Lambda layers
45
45
<https://docs.aws.amazon.com/lambda/latest/dg/chapter-layers.html>`__ to
46
- provide the PHP runtime. The ``bref`` layer is compiled with PHP and a
47
- few extensions. You can install extensions, such as ``mongodb``,
48
- in other layers.
46
+ provide the PHP runtime. The ``bref`` layer integrates Bref into your
47
+ application and is compiled with PHP and a few other extensions. You can
48
+ install the other necessary extensions, such as ``mongodb``, in other layers.
49
49
50
50
The following commands create a new project directory and install the
51
51
MongoDB and Bref dependencies:
@@ -69,23 +69,13 @@ After the commands complete, your project contains the following files:
69
69
- ``index.php``: Defines a sample webpage
70
70
- ``serverless.yml``: Configures the deployment
71
71
72
- To validate your setup, try to deploy the default application. The
73
- following command deploys the application and returns a URL that renders
74
- a webpage that shows the Bref logo:
75
-
76
- .. code-block:: bash
77
-
78
- serverless deploy
79
-
80
72
Add the MongoDB Extension to Your Configuration
81
73
-----------------------------------------------
82
74
83
75
After you initialize the project, you can add the ``mongodb`` extension.
84
76
Locate the ``Serverless config`` name in the list of extensions provided
85
77
by the :github:`bref/extra-php-extension <brefphp/extra-php-extensions>`
86
- package.
87
-
88
- Add it to the ``layers`` of the function in the ``serverless.yaml``
78
+ package. Add it to the ``layers`` of the function in the ``serverless.yaml``
89
79
file, as shown in the following code:
90
80
91
81
.. code-block:: yaml
@@ -133,7 +123,8 @@ The following steps demonstrate how to set the role in your Atlas
133
123
cluster:
134
124
135
125
1. Open the Lambda function in the AWS console.
136
- #. Enter :guilabel:`Configuration > Permission`, then copy the :guilabel:`Role name`.
126
+ #. Navigate to :guilabel:`Configuration > Permission`, then copy the
127
+ :guilabel:`Role name`.
137
128
#. Add this role to your Atlas cluster in the :guilabel:`Database
138
129
Access` section. Select the :guilabel:`AWS IAM` authentication method
139
130
and set the built-in role ``Read and write any database``.
@@ -152,15 +143,17 @@ the Atlas documentation.
152
143
153
144
.. note::
154
145
155
- Using VPC Peering is recommended to isolate your Atlas
156
- cluster from the internet. This requires the Lambda function to be
157
- deployed in this AWS VPC.
146
+ Using Virtual Private Cloud (VPC) Peering is recommended to isolate
147
+ your Atlas cluster from the internet. This requires the Lambda
148
+ function to be deployed in the AWS VPC. To learn more, see
149
+ :atlas:`Set Up a Network Peering Connection </security-vpc-peering>`
150
+ in the Atlas documentation.
158
151
159
152
Next, copy your connection string and remove the ``<AWS access key>:<AWS
160
153
secret key>`` section, as your credentials are read from environment variables.
161
154
162
- Update the ``serverless.yml`` file in your project to set the
163
- environment variable ``MONGODB_URI`` to your connection string:
155
+ In your project's ``serverless.yml`` file, set the
156
+ ``MONGODB_URI`` environment variable to your connection string:
164
157
165
158
.. code-block:: yaml
166
159
0 commit comments