@@ -23,7 +23,7 @@ To deploy to AWS Lambda by using Bref, you must have the following components se
23
23
- AWS account with access keys
24
24
- Serverless Framework
25
25
26
- To learn how to set these up, follow the `Setup tutorial<https://bref.sh/docs/setup>`__
26
+ To learn how to set these up, follow the `Setup tutorial <https://bref.sh/docs/setup>`__
27
27
in the Bref official documentation.
28
28
29
29
Install the MongoDB extension
@@ -49,9 +49,14 @@ Then initialize the serverless configuration using the ``bref`` command.
49
49
$ vendor/bin/bref init
50
50
51
51
52
- This series of commands creates a file named ``index.php``. To validate your
53
- setup, try deploying this default application. This outputs a
54
- URL that renders a webpage with the Bref logo:
52
+ After this series of commands, you should have this files:
53
+
54
+ - ``composer.json`` for PHP dependencies installed in the ``vendor`` directory
55
+ - ``index.php`` a sample webpage
56
+ - ``serverless.yml`` for the configuration of the deployment
57
+
58
+ To validate your setup, try deploying this default application. This outputs
59
+ a URL that renders a webpage with the Bref logo:
55
60
56
61
.. code-block:: none
57
62
@@ -78,8 +83,9 @@ will look like this:
78
83
- ${bref-extra:mongodb-php-83}
79
84
80
85
86
+
81
87
Let's use the MongoDB driver with a web page that list planets from the Atlas
82
- `sample dataset <https://www.mongodb.com/docs/atlas/ sample-data/>`__ .
88
+ :atlas: `sample dataset </ sample-data/>`.
83
89
Replace the contents of ``index.php`` with the following:
84
90
85
91
.. literalinclude:: /examples/aws-lambda/index.php
@@ -108,15 +114,14 @@ the role assigned to deployed function.
108
114
2. In :guilabel:`Configuration > Permission`, copy the "Role name"
109
115
3. Add this role to your Atlas cluster with the built-in Role: "Read and write any database"
110
116
111
- To learn how to set up unified AWS access, see `Set Up Unified AWS Access
112
- <https://www.mongodb.com/docs/atlas/security/set-up-unified-aws-access/>`__ in the
113
- MongoDB Atlas documentation.
117
+ To learn how to set up unified AWS access, see :atlas:`Set Up Unified AWS Access
118
+ </security/set-up-unified-aws-access/>` in the MongoDB Atlas documentation.
114
119
115
120
Now that the permissions have been configured, the Lambda function is allowed to access
116
121
your Atlas cluster. You can configure your application with the Atlas endpoint.
117
122
118
123
Access to Atlas clusters is also restricted by IP address. Since the range of IP that comes
119
- from AWS is very wide, you can `allow access from everywhere <https://www.mongodb.com/docs/atlas /security/ip-access-list/>`__.
124
+ from AWS is very wide, you can :atlas: `allow access from everywhere </security/ip-access-list/>`__.
120
125
121
126
.. note::
122
127
@@ -136,8 +141,8 @@ Update the ``serverless.yml`` file to pass the environment variable ``MONGODB_UR
136
141
environment:
137
142
MONGODB_URI: "mongodb+srv://cluster0.example.mongodb.net/?authSource=%24external&authMechanism=MONGODB-AWS&retryWrites=true&w=majority"
138
143
139
- Finally, deploy with the new configuration. After deployment completes, you can access the function URL
140
- and see the list of planets from your Atlas cluster.
144
+ Finally, deploy with the new configuration. After deployment completes, you can
145
+ access the function URL and see the list of planets from your Atlas cluster.
141
146
142
147
.. code-block:: none
143
148
0 commit comments