Skip to content

Commit 605b1db

Browse files
committed
Tweak docs
1 parent b564c6d commit 605b1db

File tree

2 files changed

+42
-44
lines changed

2 files changed

+42
-44
lines changed

docs/environment/aws-credentials.mdx

Lines changed: 40 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ import { Callout, Tabs } from 'nextra/components';
88
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.
99

1010
<Callout type="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**.
1214
</Callout>
1315

1416
## How it works
@@ -40,6 +42,8 @@ $result = $s3->putObject([
4042
// Note that this also works with https://async-aws.com
4143
```
4244

45+
Note that **Laravel and Symfony automatically pick up these permissions** too.
46+
4347
These credentials have access controlled by an IAM role defined in `serverless.yml`.
4448

4549
<Callout type="info">
@@ -121,31 +125,45 @@ Here are the IAM actions you'll typically need for common AWS services:
121125

122126
### DynamoDB
123127
```yaml
124-
- Effect: Allow
125-
Action:
126-
- dynamodb:GetItem
127-
- dynamodb:PutItem
128-
- dynamodb:UpdateItem
129-
- dynamodb:DeleteItem
130-
- dynamodb:Query
131-
- dynamodb:Scan
132-
Resource: arn:aws:dynamodb:${aws:region}:${aws:accountId}:table/my-table
128+
- Effect: Allow
129+
Action:
130+
- dynamodb:GetItem
131+
- dynamodb:PutItem
132+
- dynamodb:UpdateItem
133+
- dynamodb:DeleteItem
134+
- dynamodb:Query
135+
- dynamodb:Scan
136+
Resource: arn:aws:dynamodb:${aws:region}:${aws:accountId}:table/my-table
133137
```
134138

135139
### Secrets Manager
136140
```yaml
137-
- Effect: Allow
138-
Action:
139-
- secretsmanager:GetSecretValue
140-
Resource: arn:aws:secretsmanager:${aws:region}:${aws:accountId}:secret:my-secret-*
141+
- Effect: Allow
142+
Action: secretsmanager:GetSecretValue
143+
Resource: arn:aws:secretsmanager:${aws:region}:${aws:accountId}:secret:my-secret-*
141144
```
142145

143146
### SNS (notifications)
144147
```yaml
145-
- Effect: Allow
146-
Action:
147-
- sns:Publish
148-
Resource: arn:aws:sns:${aws:region}:${aws:accountId}:my-topic
148+
- Effect: Allow
149+
Action: sns:Publish
150+
Resource: arn:aws:sns:${aws:region}:${aws:accountId}:my-topic
151+
```
152+
153+
### EventBridge
154+
```yaml
155+
- Effect: Allow
156+
Action: events:PutEvents
157+
Resource: arn:aws:events:${aws:region}:${aws:accountId}:event-bus/my-event-bus
158+
```
159+
160+
### SSM Parameter Store
161+
```yaml
162+
- Effect: Allow
163+
Action:
164+
- ssm:GetParameter
165+
- ssm:GetParameters
166+
Resource: arn:aws:ssm:${aws:region}:${aws:accountId}:parameter/my-app/*
149167
```
150168

151169
## Troubleshooting
@@ -163,6 +181,10 @@ If you get "Access Denied" errors when trying to use AWS services:
163181

164182
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.
165183

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+
166188
## Learn more
167189

168190
- [`serverless.yml` IAM guide](https://github.com/oss-serverless/serverless/blob/main/docs/guides/iam.md)

docs/environment/serverless-yml.mdx

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -148,33 +148,9 @@ Note that it is possible to mix PHP functions with functions written in other la
148148

149149
### Permissions
150150

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.
152152

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
166-
- Effect: Allow
167-
Action:
168-
- dynamodb:Query
169-
- dynamodb:Scan
170-
- dynamodb:GetItem
171-
- dynamodb:PutItem
172-
- dynamodb:UpdateItem
173-
- dynamodb:DeleteItem
174-
Resource: 'arn:aws:dynamodb:us-east-1:111110002222:table/example'
175-
```
176-
177-
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).
178154

179155
## Stage parameters
180156

0 commit comments

Comments
 (0)