mirror of
https://github.com/serverless/serverless.git
synced 2026-01-18 14:58:43 +00:00
Add JSON/YAML examples
This commit is contained in:
parent
129a2a152d
commit
3471bf3b74
@ -117,7 +117,7 @@ The corresponding resources which are defined inside the `cloudformation-resourc
|
||||
into the `Resources` section.
|
||||
|
||||
## Adding custom IAM role statements
|
||||
If you want to give permission to your functions to access certain resources on your AWS account, you can add custom IAM role statements to your service by adding the statements in the `iamRoleStatements` array in the `provider` object. As those statements will be merged into the CloudFormation template you can use Join, Ref or any other CloudFormation method or feature. Here's an example:
|
||||
If you want to give permission to your functions to access certain resources on your AWS account, you can add custom IAM role statements to your service by adding the statements in the `iamRoleStatements` array in the `provider` object. As those statements will be merged into the CloudFormation template you can use Join, Ref or any other CloudFormation method or feature. You're also able to either use YAML for defining the statement (including the methods) or use embedded JSON if you prefer it. Here's an example that uses all of the above:
|
||||
|
||||
```yml
|
||||
# serverless.yml
|
||||
@ -130,6 +130,14 @@ provider:
|
||||
Action:
|
||||
- "s3:ListBucket"
|
||||
Resource: { "Fn::Join" : ["", ["arn:aws:s3:::", { "Ref" : "ServerlessDeploymentBucket"} ] ] }
|
||||
- Effect: "Allow"
|
||||
Action:
|
||||
- "s3:PutObject"
|
||||
Resource:
|
||||
Fn::Join:
|
||||
- ""
|
||||
- - "arn:aws:s3:::"
|
||||
- "Ref" : "ServerlessDeploymentBucket"
|
||||
```
|
||||
|
||||
On deployment, all these statements will be added to the IAM role that is assumed by your lambda functions.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user