You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+41-1Lines changed: 41 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,6 +8,7 @@ Serverless Framework handles everything from creating namespaces to function/cod
8
8
-[Requirements](#requirements)
9
9
-[Create a Project](#create-a-project)
10
10
-[Configure your functions](#configure-your-functions)
11
+
-[Security and secret management](#security-and-secret-management)
11
12
-[Functions Handler](#functions-handler)
12
13
-[Using ES Modules](#using-es-modules)
13
14
-[Node](#node)
@@ -57,15 +58,18 @@ Your functions are defined in the `serverless.yml` file created:
57
58
service: scaleway-python3
58
59
configValidationMode: off
59
60
61
+
useDotenv: true
62
+
60
63
provider:
61
64
name: scaleway
62
65
runtime: python310
63
66
# Global Environment variables - used in every functions
64
67
env:
65
68
test: test
69
+
# Storing credentials in this file is strongly not recommanded for security concerns, please refer to README.md about best practices
66
70
scwToken: <scw-token>
67
71
scwProject: <scw-project-id>
68
-
# region in which the deployment will happen, (default fr-par)
72
+
# region in which the deployment will happen (default: fr-par)
69
73
scwRegion: <scw-region>
70
74
71
75
plugins:
@@ -92,6 +96,8 @@ of the same runtime (here `python3`)
92
96
93
97
The different parameters are:
94
98
* `service`: your namespace name
99
+
* `useDotenv`: Load environment variables from .env files (default: false), read [Security and secret management](#security-and-secret-management)
100
+
* `configValidationMode`: Configuration validation: 'error' (fatal error), 'warn' (logged to the output) or 'off' (default: warn)
95
101
* `provider.runtime`: the runtime of your functions (check the supported runtimes above)
96
102
* `provider.env`: environment variables attached to your namespace are injected to all your namespace functions
97
103
* `provider.secret`: secret environment variables attached to your namespace are injected to all your namespace functions, see [this example project](./examples/secrets)
@@ -110,6 +116,40 @@ The different parameters are:
110
116
* `runtime`: (Optional) runtime of the function, if you need to deploy multiple functions with different runtimes in your Serverless Project. If absent, `provider.runtime` will be used to deploy the function, see [this example project](./examples/multiple).
111
117
* `events` (Optional): List of events to trigger your functions (e.g, trigger a function based on a schedule with `CRONJobs`). See `events` section below
112
118
119
+
### Security and secret management
120
+
121
+
You configuration file may contains sensitive data, your project ID and your Token must not be shared and must not be commited in VCS.
122
+
123
+
To keep your informations safe and be able to share or commit your `serverles.yml` file you should remove your credentials from the file. Then
124
+
you can :
125
+
- use global environment variables
126
+
- use `.env` file and keep it secret
127
+
128
+
To use `.env` file you can modify your `serverless.yml` file as following :
129
+
130
+
```yml
131
+
# This will alow the plugin to read your .env file
132
+
useDotenv: true
133
+
134
+
provider:
135
+
name: scaleway
136
+
runtime: node16
137
+
138
+
scwToken: ${env:SCW_SECRET_KEY}
139
+
scwProject: ${env:SCW_DEFAULT_PROJECT_ID}
140
+
scwRegion: ${env:SCW_REGION}
141
+
```
142
+
143
+
And then create a `.env` file next to your `serverless.yml` file, containing following values :
144
+
145
+
```bash
146
+
SCW_SECRET_KEY=XXX
147
+
SCW_DEFAULT_PROJECT_ID=XXX
148
+
SCW_REGION=fr-par
149
+
```
150
+
151
+
You can use this pattern to hide your secrets (for example a connexion string to a database or a S3 bucket).
152
+
113
153
## Functions Handler
114
154
115
155
Based on the chosen runtime, the `handler` variable on function might vary.
[link to CLI documentation](https://github.com/scaleway/scaleway-cli/blob/master/docs/commands/function.md)
98
+
99
+
- **serverless.yml** (discouraged) manifest. Inside your manifest, you may inquire your credentials with the following structure under the `provider` key:
100
+
```yml
101
+
provider:
102
+
scwToken: <scw-token>
103
+
scwProject: <scw-project-id>
104
+
```
105
+
84
106
The priority order is the following (from top: + priority to bottom: - priority):
0 commit comments