You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/cloud-security.mdx
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,6 +24,8 @@ To use the AWS API, Bref Cloud needs **AWS credentials** that give access to the
24
24
25
25
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).
26
26
27
+
Note that all of this happens automatically and is easy to set up in the Bref Cloud web interface.
@@ -10,16 +10,21 @@ Bref can also work with any other deployment tool: Terraform, CloudFormation, SA
10
10
11
11
To deploy to AWS an application configured with `serverless.yml`, run:
12
12
13
-
```bash
14
-
serverless deploy
15
-
```
13
+
<Tabsitems={['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>
16
25
17
26
A `.serverless/` directory will be created. You can add it to `.gitignore`.
18
27
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
-
23
28
## Deploying for production
24
29
25
30
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
44
49
45
50
Once your project is ready, you can deploy via the following command:
46
51
47
-
```bash
48
-
serverless deploy
49
-
```
52
+
<Tabsitems={['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
+
<Tabsitems={['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.
50
90
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
58
92
59
-
The default stage is `dev`. The example above deploys a `prod` stage.
93
+
### Bref Cloud
60
94
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.
62
96
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.
64
98
65
-
##Automating deployments
99
+
### Serverless CLI
66
100
67
101
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:
68
102
@@ -96,40 +130,58 @@ provider:
96
130
97
131
<Callout>
98
132
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.
101
133
</Callout>
102
134
103
135
## Deletion
104
136
105
-
To delete the whole application you can run:
137
+
You can delete a deployed environment using the `remove` command.
106
138
107
-
```bash
108
-
serverless remove
109
-
```
139
+
<Tabsitems={['Serverless CLI', 'Bref Cloud']}>
140
+
<Tab>
141
+
```bash
142
+
serverless remove
110
143
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.
112
165
113
166
## How it works
114
167
115
168
### CloudFormation stacks
116
169
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:
118
171
119
-
- lambda functions
172
+
- Lambda functions
173
+
- HTTP endpoints
120
174
- S3 buckets
121
175
- databases
122
176
- etc.
123
177
124
178
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.
125
179
126
-
All of this is great except CloudFormation configuration is complex. This is where Serverless Framework helps.
127
-
128
180
### Zero-downtime deployments
129
181
130
182
CloudFormation deploys using the [blue/green deployment strategy](https://docs.aws.amazon.com/whitepapers/latest/overview-deployment-options/bluegreen-deployments.html).
131
183
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.
133
185
134
186
#### Limits to blue/green deployment
135
187
@@ -149,4 +201,4 @@ You can [learn more about that configuration format here](environment/serverless
149
201
150
202
## Learn more
151
203
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).
0 commit comments