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
When your PHP application runs on AWS Lambda, it automatically has access to AWS credentials. This means you don't need to manage AWS access keys or credentials in your code - Lambda handles this for you.
9
9
10
10
<Callouttype="warning">
11
-
**Common mistake**: Don't put AWS access keys in your Lambda functions or environment variables. Lambda provides credentials automatically.
11
+
Don't deploy AWS access keys in your Lambda functions or environment variables. Lambda provides credentials automatically.
12
+
13
+
This is a common mistake **when migrating an existing application to AWS Lambda**.
12
14
</Callout>
13
15
14
16
## How it works
@@ -40,6 +42,8 @@ $result = $s3->putObject([
40
42
// Note that this also works with https://async-aws.com
41
43
```
42
44
45
+
Note that **Laravel and Symfony automatically pick up these permissions** too.
46
+
43
47
These credentials have access controlled by an IAM role defined in `serverless.yml`.
44
48
45
49
<Callouttype="info">
@@ -121,31 +125,45 @@ Here are the IAM actions you'll typically need for common AWS services:
@@ -163,6 +181,10 @@ If you get "Access Denied" errors when trying to use AWS services:
163
181
164
182
When testing locally remember that you will need to provide AWS credentials since you're not running on Lambda. You can set them up via long-lived AWS access keys or IAM roles with SSO.
165
183
184
+
## Permissions per function
185
+
186
+
If you want to define permissions **per function**, instead of globally (ie: in the provider), you can install the plugin [`serverless-iam-roles-per-function`](https://github.com/functionalone/serverless-iam-roles-per-function) and then use the `iamRoleStatements` at the function definition block.
187
+
166
188
## Learn more
167
189
168
190
- [`serverless.yml` IAM guide](https://github.com/oss-serverless/serverless/blob/main/docs/guides/iam.md)
Copy file name to clipboardExpand all lines: docs/environment/serverless-yml.mdx
+2-26Lines changed: 2 additions & 26 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -148,33 +148,9 @@ Note that it is possible to mix PHP functions with functions written in other la
148
148
149
149
### Permissions
150
150
151
-
If your lambda needs to access other AWS services (S3, SQS, SNS…), you will need to add the proper permissions via the [`iam.role.statements` section](https://serverless.com/framework/docs/providers/aws/guide/functions#permissions):
151
+
If your lambda needs to access other AWS services (S3, SQS, SNS…), you will need to add the proper permissions via the `iam.role.statements` section.
152
152
153
-
```yaml
154
-
provider:
155
-
name: aws
156
-
timeout: 10
157
-
runtime: provided.al2
158
-
iam:
159
-
role:
160
-
statements:
161
-
# Allow to put a file in the `my-bucket` S3 bucket
162
-
- Effect: Allow
163
-
Action: s3:PutObject
164
-
Resource: 'arn:aws:s3:::my-bucket/*'
165
-
# Allow to query and update the `example` DynamoDB table
If you only want to define some permissions **per function**, instead of globally (ie: in the provider), you should install and enable the Serverless plugin [`serverless-iam-roles-per-function`](https://github.com/functionalone/serverless-iam-roles-per-function) and then use the `iamRoleStatements` at the function definition block.
153
+
Read more about [AWS credentials in the documentation](./aws-credentials.mdx).
0 commit comments