Skip to content

Commit

Permalink
Merge pull request #1827 from brefphp/document-stage-parameters
Browse files Browse the repository at this point in the history
Document how to use stage parameters in `serverless.yml`
  • Loading branch information
mnapoli committed Jun 18, 2024
2 parents 820f7bd + b6d3476 commit be276f2
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions docs/environment/serverless-yml.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,32 @@ provider:

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.

## Stage parameters

Stage parameters are a great way to define values that change depending on the stage (dev, prod, staging…).

```yaml
params:
# Default parameters that apply to all stages
default:
# Here we use the special `sls:stage` variable
# to define a domain that changes depending on the stage
domain: ${sls:stage}.preview.myapp.com
# Parameters that apply to the prod stage
prod:
domain: myapp.com
# Parameters that apply to the dev stage
dev:
domain: preview.myapp.com

# Parameters can be used via the ${param:XXX} variables:
provider:
environment:
APP_DOMAIN: ${param:domain}
```

Read the full [Serverless documentation about stage parameters](https://github.com/serverless/serverless/blob/v3/docs/guides/dashboard/parameters.md#stage-parameters).

## Resources

```yaml
Expand Down

0 comments on commit be276f2

Please sign in to comment.