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: docs/functions/customization.md
+4-2Lines changed: 4 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -114,7 +114,7 @@ Note that your layers must be in the same AWS region as your Lambdas!
114
114
115
115
## Environment Variables
116
116
117
-
Some functions or layers may require configuration via Lambda environment variables. The Lambda runtime makes environment variables available to the code.
117
+
Some functions or layers may require configuration via Lambda environment variables. The Lambda runtime will inject the environment variables so that they available to your handler code.
118
118
119
119
In this example below, we're providing a path to a font directory as an environment variable.
120
120
```php
@@ -145,7 +145,7 @@ By default, Sidecar doesn't touch your Lambda's environment at all. Only when yo
145
145
146
146
Another important thing to note is that Sidecar sets your environment variables as a part of the _activation_ process, not the _deploy_ process. This means that the environment variables will be pulled from the machine that calls `sidecar:activate`.
147
147
148
-
For example, if you are sharing secrets with your Lambda, then the values passed to your Lambda will be equal to the ones on the machine that called `sidecar:activate`, not the one that called `sidecar:deploy`:
148
+
For example, if you are sharing secrets with your Lambda, then the values passed to your Lambda will be equal to the ones on the machine that called `sidecar:activate`, not the one that called `sidecar:deploy`
149
149
150
150
```php
151
151
class ExampleFunction extends LambdaFunction
@@ -171,6 +171,8 @@ class ExampleFunction extends LambdaFunction
171
171
}
172
172
```
173
173
174
+
This is obviously important when you are calling `deploy` and `activate` from different machines as a part of your Laravel application's deployment process. To read more about deployment strategies, check out the [deploying](deploying) section.
175
+
174
176
## Name
175
177
176
178
Your function has a `name` method that determines how Sidecar names your Lambda functions. By default it is based on the name and path of your PHP class. You are free to change this if you want, but you're unlikely to need to.
To read more about environments, head to the [Environments section](../environments) of the docs.
96
96
97
+
## Setting Environment Variables
98
+
99
+
This is covered in the [Environment Variables](customization#environment-variables) section of the Customization docs, but we'll cover strategies around env vars and deployment here.
100
+
101
+
Some of your functions will require environment variables, either from your Laravel application or something completely distinct. In some cases, you may need to set a static variable so that some library will work [(LibreOffice example)](https://github.com/hammerstonedev/sidecar/issues/24):
Setting static variables like that is quite straightforward.
127
+
128
+
If, however, you want to share some secrets or environment variables _from your Laravel_ application, it will be important that you are sharing them from the correct environment.
129
+
130
+
Imagine the scenario where you want to share your AWS keys with your Lambda function:
You pull your key and secret using the Laravel `config` function, which in turn likely delegates to the `env()` function.
157
+
158
+
Sidecar sets the environment variables _upon activation_. If you are deploying from CI and then activating from e.g. Vapor, you'll want to make sure you have those variables in the Vapor environment.
159
+
160
+
Environment variables are set before activation, and before any pre-warming takes place.
161
+
162
+
And remember! If Sidecar manages the environment variables for a function, it will clobber any changes you make in the AWS UI, so you cannot use both methods simultaneously.
163
+
97
164
## Reusing Package Files
98
165
99
166
If you're deploying your Sidecar functions every time you deploy your app, you will likely be deploying functions that have not changed at all.
0 commit comments