Skip to content

Commit d902f2d

Browse files
committed
Merge branch 'master' into v3
# Conflicts: # docs/runtimes.mdx # docs/setup.mdx # layers.json
2 parents 5196c64 + 9f4d8a7 commit d902f2d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1372
-555
lines changed

.github/workflows/website.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,16 @@ env:
1111
jobs:
1212

1313
deploy:
14-
runs-on: ubuntu-22.04
14+
runs-on: ubuntu-latest
15+
concurrency: deploy-prod # Avoid deploying concurrently
1516
permissions:
1617
contents: read
1718
defaults:
1819
run:
1920
working-directory: ./website
21+
environment:
22+
name: prod
23+
url: https://bref.sh
2024
steps:
2125
- uses: actions/checkout@v4
2226
with:

bref

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ switch ($argv[1] ?? '') {
3232
error('Since Bref 2.0, the "bref local" command has been moved. Read https://bref.sh/docs/local-development/event-driven-functions\n');
3333
case 'dashboard':
3434
cliWarning();
35-
echo "The Bref Dashboard is now available as a desktop application.\n\n";
36-
echo "Check out https://dashboard.bref.sh/\n";
35+
echo "Check out Bref Cloud: https://bref.sh/cloud\n";
3736
exit(1);
3837
case '':
3938
help();

docs/cloud-deploy.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,10 @@ jobs:
9696
runs-on: ubuntu-latest
9797
timeout-minutes: 15
9898
concurrency: deploy-prod # Avoid deploying concurrently
99+
environment:
100+
name: prod
101+
# Optionally set a URL for the environment
102+
# url: https://example.com
99103
steps:
100104
- uses: actions/checkout@v4
101105

docs/cloud-security.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ To use the AWS API, Bref Cloud needs **AWS credentials** that give access to the
2424

2525
Bref Cloud does not use long-lived AWS credentials (aka AWS access keys). Instead, it follows standard AWS best practices and uses IAM roles with [temporary credentials](https://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html#bp-workloads-use-roles).
2626

27+
Note that all of this happens automatically and is easy to set up in the Bref Cloud web interface.
28+
2729
## How it works
2830

2931
```mermaid

docs/cloud/logs.png

421 KB
Loading

docs/default/cli-commands.mdx

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { Tab, Tabs } from 'nextra/components';
2+
13
# CLI commands
24

35
We can run CLI commands and scripts on AWS Lambda by deploying a "console" function with `serverless.yml`.
@@ -13,15 +15,33 @@ The function uses the [Console runtime](../runtimes/console.mdx).
1315
1416
To execute the script on Lambda, run the command below:
1517
16-
```bash
17-
serverless bref:cli
18-
```
18+
<Tabs items={['Serverless CLI', 'Bref Cloud']}>
19+
<Tab>
20+
```bash
21+
serverless bref:cli
22+
```
23+
</Tab>
24+
<Tab>
25+
```bash
26+
bref command
27+
```
28+
</Tab>
29+
</Tabs>
1930

2031
We can also pass arguments to the script:
2132

22-
```bash
23-
serverless bref:cli --args="extra command line arguments and options"
24-
```
33+
<Tabs items={['Serverless CLI', 'Bref Cloud']}>
34+
<Tab>
35+
```bash
36+
serverless bref:cli --args="extra command line arguments and options"
37+
```
38+
</Tab>
39+
<Tab>
40+
```bash
41+
bref command "extra command line arguments and options"
42+
```
43+
</Tab>
44+
</Tabs>
2545

2646
Our script will be invoked inside AWS Lambda and the result will be printed to the console.
2747

docs/default/getting-started.mdx

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Cards, Card } from 'nextra/components';
1+
import { Cards, Card, Tabs, Tab } from 'nextra/components';
22
// Path relative to the copy in the `website/` folder
33
import { LaravelIcon } from '../../../components/icons/LaravelIcon';
44
import { SymfonyIcon } from '../../../components/icons/SymfonyIcon';
@@ -70,9 +70,18 @@ plugins:
7070
7171
To deploy, run:
7272
73-
```bash
74-
serverless deploy
75-
```
73+
<Tabs items={['Serverless CLI', 'Bref Cloud']}>
74+
<Tab>
75+
```bash
76+
serverless deploy
77+
```
78+
</Tab>
79+
<Tab>
80+
```bash
81+
bref deploy
82+
```
83+
</Tab>
84+
</Tabs>
7685

7786
Once the command finishes, it should print a URL like this one:
7887

docs/deploy.mdx

Lines changed: 87 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Callout } from 'nextra/components';
1+
import { Callout, Tab, Tabs } from 'nextra/components';
22

33
# Deployment
44

@@ -10,16 +10,21 @@ Bref can also work with any other deployment tool: Terraform, CloudFormation, SA
1010

1111
To deploy to AWS an application configured with `serverless.yml`, run:
1212

13-
```bash
14-
serverless deploy
15-
```
13+
<Tabs items={['Serverless CLI', 'Bref Cloud']}>
14+
<Tab>
15+
```bash
16+
serverless deploy
17+
```
18+
</Tab>
19+
<Tab>
20+
```bash
21+
bref deploy
22+
```
23+
</Tab>
24+
</Tabs>
1625

1726
A `.serverless/` directory will be created. You can add it to `.gitignore`.
1827

19-
<Callout>
20-
Want to get an overview of your deployed application? Check out the [Bref Dashboard](https://dashboard.bref.sh/?ref=bref).
21-
</Callout>
22-
2328
## Deploying for production
2429

2530
In the previous step, we deployed the project installed on your machine. This is probably a *development version*.
@@ -44,25 +49,54 @@ Now is also the best time to configure your project for production, as well as b
4449

4550
Once your project is ready, you can deploy via the following command:
4651

47-
```bash
48-
serverless deploy
49-
```
52+
<Tabs items={['Serverless CLI', 'Bref Cloud']}>
53+
<Tab>
54+
```bash
55+
serverless deploy
56+
```
57+
</Tab>
58+
<Tab>
59+
```bash
60+
bref deploy
61+
```
62+
</Tab>
63+
</Tabs>
64+
65+
## Environments
66+
67+
We can deploy the same application multiple times in completely separated environments (also called "stages" by the Serverless CLI).
68+
69+
<Tabs items={['Serverless CLI', 'Bref Cloud']}>
70+
<Tab>
71+
```bash
72+
serverless deploy --stage=prod
73+
```
74+
</Tab>
75+
<Tab>
76+
```bash
77+
bref deploy --env=prod
78+
79+
# or
80+
bref deploy -e prod
81+
```
82+
</Tab>
83+
</Tabs>
84+
85+
The default environment is `dev`. The example above deploys a `prod` environment.
86+
87+
Each environment is a separate CloudFormation stack, with completely separate AWS resources (Lambda functions, logs, permissions, etc.). All AWS resources are prefixed with the `service` and environment name (for example `myapp-dev-api`), which avoids any collision between environments.
88+
89+
It is possible to deploy different environments in different AWS accounts (to lock down permissions), and to deploy one environment per git branch, pull request, or even developer in the team.
5090

51-
## Stages
52-
53-
Serverless Framework has a concept of "stages", another name for "environments". We can deploy the same application multiple times in completely separated environments:
54-
55-
```bash
56-
serverless deploy --stage=prod
57-
```
91+
## Automating deployments
5892

59-
The default stage is `dev`. The example above deploys a `prod` stage.
93+
### Bref Cloud
6094

61-
Each stage is a separate CloudFormation stack, with completely separate AWS resources (Lambda functions, logs, permissions, etc.). All AWS resources are prefixed with the `service` and stage name (for example `myapp-dev-api`), which avoids any collision between stages.
95+
If you are using [Bref Cloud](https://bref.sh/cloud), you can easily set up automatic deployments from CI/CD tools.
6296

63-
It is possible to deploy different stages in different AWS accounts (to lock down permissions), and to deploy one stage per git branch, pull request, or even developer in the team.
97+
Read the [documentation on deploying with Bref Cloud](./cloud-deploy.mdx) for more information.
6498

65-
## Automating deployments
99+
### Serverless CLI
66100

67101
If you are using GitHub Actions, Gitlab CI, CircleCI, or any tool of the sort you will want to automate the deployment to something like this:
68102

@@ -96,40 +130,58 @@ provider:
96130

97131
<Callout>
98132
If you are a first time user, using the `us-east-1` region (the default region) is recommended for the first projects. It simplifies commands and avoids a lot of mistakes when discovering AWS.
99-
100-
I mean really… I can't count how many times a command failed or an AWS page looked empty because I was in the wrong region.
101133
</Callout>
102134

103135
## Deletion
104136

105-
To delete the whole application you can run:
137+
You can delete a deployed environment using the `remove` command.
106138

107-
```bash
108-
serverless remove
109-
```
139+
<Tabs items={['Serverless CLI', 'Bref Cloud']}>
140+
<Tab>
141+
```bash
142+
serverless remove
110143

111-
Note that this command, like `serverless deploy`, is for a specific stage. If you want to delete all stages you will have to run the command once per stage.
144+
# or remove a specific environment
145+
serverless remove --stage=prod
146+
```
147+
148+
Note that because of the way Serverless Framework works, you will need to delete the contents of AWS S3 buckets manually before running this command.
149+
</Tab>
150+
<Tab>
151+
```bash
152+
bref remove
153+
154+
# or remove a specific environment
155+
bref remove --env=prod
156+
```
157+
158+
Bref Cloud will automatically delete the contents of AWS S3 buckets.
159+
</Tab>
160+
</Tabs>
161+
162+
**Deleting an environment destroys the AWS resources that were created for that environment.**
163+
164+
If you want to delete all environments of an application, you can do so in the [Bref Cloud dashboard](https://bref.cloud). If you don't use Bref Cloud, you will need to delete each environment one by one.
112165

113166
## How it works
114167

115168
### CloudFormation stacks
116169

117-
The `serverless deploy` command will deploy everything via a **[CloudFormation](https://aws.amazon.com/cloudformation/) stack**. A "stack" is nothing more than a bunch of things that compose an application:
170+
Under the hood, Bref will deploy everything to AWS as a **[CloudFormation](https://aws.amazon.com/cloudformation/) stack**. A "stack" is nothing more than a bunch of things that compose an application:
118171

119-
- lambda functions
172+
- Lambda functions
173+
- HTTP endpoints
120174
- S3 buckets
121175
- databases
122176
- etc.
123177

124178
Stacks make it easy to group those resources together: the whole stack is updated at once on deployments, and if you delete the stack all the resources inside are deleted together too. Clean and simple.
125179

126-
All of this is great except CloudFormation configuration is complex. This is where Serverless Framework helps.
127-
128180
### Zero-downtime deployments
129181

130182
CloudFormation deploys using the [blue/green deployment strategy](https://docs.aws.amazon.com/whitepapers/latest/overview-deployment-options/bluegreen-deployments.html).
131183

132-
This means that when you deploy, a new version of your code is deployed alongside the old one. Once the new version is ready, the traffic switches to the new version. If the deployment fails at any point, the traffic stays on the old version.
184+
This means that when you deploy, a new version of your code is deployed alongside the old one. Once the new version is ready, the traffic switches to the new version. If the deployment fails at any point, the traffic stays on the old version and the deployment is rolled back.
133185

134186
#### Limits to blue/green deployment
135187

@@ -149,4 +201,4 @@ You can [learn more about that configuration format here](environment/serverless
149201

150202
## Learn more
151203

152-
Read more about `serverless deploy` in [the official documentation](https://serverless.com/framework/docs/providers/aws/guide/deploying/).
204+
Read more about `serverless deploy` in [the official documentation](https://github.com/oss-serverless/serverless/blob/main/docs/guides/deploying.md).

docs/environment/_meta.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@
99
"database-public": {
1010
"display": "hidden"
1111
},
12+
"aws-credentials": "AWS credentials",
1213
"performances": "Performance"
1314
}

0 commit comments

Comments
 (0)