Skip to content

Commit 154348e

Browse files
committed
Add documentation for IAM and custom authorizers
1 parent 003f3e2 commit 154348e

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

README.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,52 @@ stepFunctions:
210210

211211
Configuring the cors property sets Access-Control-Allow-Origin, Access-Control-Allow-Headers, Access-Control-Allow-Methods,Access-Control-Allow-Credentials headers in the CORS preflight response.
212212

213+
#### HTTP Endpoints with AWS_IAM Authorizers
214+
215+
If you want to require that the caller submit the IAM user's access keys in order to be authenticated to invoke your Lambda Function, set the authorizer to AWS_IAM as shown in the following example:
216+
217+
```yml
218+
stepFunctions:
219+
stateMachines:
220+
hello:
221+
events:
222+
- http:
223+
path: posts/create
224+
method: POST
225+
authorizer: aws_iam
226+
definition:
227+
```
228+
229+
#### HTTP Endpoints with Custom Authorizers
230+
231+
[Custom Authorizers](https://serverless.com/framework/docs/providers/aws/events/apigateway/#http-endpoints-with-custom-authorizers) allow you to run an AWS Lambda Function before your targeted AWS Lambda Function. This is useful for Microservice Architectures or when you simply want to do some Authorization before running your business logic.
232+
233+
You can enable Custom Authorizers for your HTTP endpoint by setting the Authorizer in your http event to another function in the same service, as shown in the following example:
234+
235+
```yml
236+
stepFunctions:
237+
stateMachines:
238+
hello:
239+
- http:
240+
path: posts/create
241+
method: post
242+
authorizer: authorizerFunc
243+
definition:
244+
```
245+
246+
If the Authorizer function does not exist in your service but exists in AWS, you can provide the ARN of the Lambda function instead of the function name, as shown in the following example:
247+
248+
```yml
249+
stepFunctions:
250+
stateMachines:
251+
hello:
252+
- http:
253+
path: posts/create
254+
method: post
255+
authorizer: xxx:xxx:Lambda-Name
256+
definition:
257+
```
258+
213259
#### Customizing request body mapping templates
214260

215261
The plugin generates default body mapping templates for `application/json` and `application/x-www-form-urlencoded` content types. If you'd like to add more content types or customize the default ones, you can do so by including them in `serverless.yml`:

0 commit comments

Comments
 (0)