Skip to content

Commit adf8abb

Browse files
authored
Merge pull request #2187 from brefphp/aws-projects
Documentation: AWS projects and missing install steps in the Laravel guides
2 parents 3beaae6 + 798b9f6 commit adf8abb

6 files changed

Lines changed: 62 additions & 13 deletions

File tree

‎docs/cloud-getting-started.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Bref Cloud is a service that makes it easy to deploy and monitor serverless PHP
99

1010
To get started, [create a free Bref Cloud account](https://bref.cloud/register).
1111

12-
You will be guided through the process of creating an AWS account (if needed) and connecting it to Bref Cloud.
12+
You will be guided through the process of creating an AWS account (if needed) and connecting it to Bref Cloud. If you create a new AWS account, use the [AWS sign-up form](https://signin.aws.amazon.com/signup?request_type=register) (*Sign up for AWS (advanced)*). Do not use *Sign up for AWS (new)*: it creates an [AWS project](./setup.mdx#aws-projects), a restricted AWS account that is not suited for production applications, and that Bref Cloud cannot connect to.
1313

1414
## Installing the CLI
1515

‎docs/laravel/file-storage.mdx‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,19 @@ When running on Lambda, you will need to use the **`s3` adapter** to store files
99

1010
The easiest way to set up S3 storage is using [Serverless Lift](https://github.com/getlift/lift):
1111

12-
First install the Lift plugin:
12+
First install the Flysystem S3 adapter, which Laravel's `s3` disk requires (without it, any file operation fails with `Class "League\Flysystem\AwsS3V3\PortableVisibilityConverter" not found`):
1313

1414
```bash
15-
serverless plugin install -n serverless-lift
15+
composer require league/flysystem-aws-s3-v3
1616
```
1717

18-
Then use [the `storage` construct](https://github.com/getlift/lift/blob/master/docs/storage.md) in `serverless.yml`:
18+
Then install the Lift plugin:
19+
20+
```bash
21+
npm install --save-dev serverless-lift
22+
```
23+
24+
Enable it in the `plugins` section of `serverless.yml` (in the file generated for Laravel, uncomment the `- serverless-lift` line), then use [the `storage` construct](https://github.com/getlift/lift/blob/master/docs/storage.md) in `serverless.yml`:
1925

2026
```yaml filename="serverless.yml"
2127
provider:

‎docs/laravel/queues.mdx‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ To make things simpler, we will use the [Serverless Lift](https://github.com/get
1414
First install the Lift plugin:
1515

1616
```bash
17-
serverless plugin install -n serverless-lift
17+
npm install --save-dev serverless-lift
1818
```
1919

20-
Then use [the Queue construct](https://github.com/getlift/lift/blob/master/docs/queue.md) in `serverless.yml`:
20+
Enable it in the `plugins` section of `serverless.yml` (in the file generated for Laravel, uncomment the `- serverless-lift` line), then use [the Queue construct](https://github.com/getlift/lift/blob/master/docs/queue.md) in `serverless.yml`:
2121

2222
```yml filename="serverless.yml"
2323
provider:
@@ -60,6 +60,8 @@ When integrated with AWS Lambda, SQS has a built-in retry mechanism and storage
6060

6161
Instead, "Bref for Laravel" makes all the features of Laravel Queues work out of the box, just like on any server. Read more in [the Laravel Queues documentation](https://laravel.com/docs/queues).
6262

63+
Failed jobs are stored in the `failed_jobs` database table, like on any server. If your application has no database, set `QUEUE_FAILED_DRIVER: 'null'` in `provider.environment`: failed jobs are still logged, but not stored. Otherwise, storing the failed job fails as well, for example with `Database file at path [/var/task/database/database.sqlite] does not exist`.
64+
6365
> [!TIP]
6466
>
6567
> The "Bref-Laravel bridge" v1 used to do the opposite. We changed that behavior in Bref v2 in order to make the experience smoother for Laravel users.

‎docs/setup/index.mdx‎

Lines changed: 45 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,15 @@ To use Bref Cloud, you will need a [Bref Cloud](/cloud) account, an AWS account,
3535

3636
Bref Cloud deploys your applications to your AWS account.
3737

38-
To create an AWS account, **go to [aws.amazon.com](https://aws.amazon.com/) and click *Sign up***. Bref Cloud will guide you through the process of creating an AWS account and connecting it to Bref Cloud.
38+
To create an AWS account, **use the [AWS sign-up form](https://signin.aws.amazon.com/signup?request_type=register)** (*Sign up for AWS (advanced)*, the form that asks for a root user email address and an AWS account name). Bref Cloud will guide you through the process of creating an AWS account and connecting it to Bref Cloud.
39+
40+
> [!WARNING]
41+
>
42+
> Do not use *Sign up for AWS (new)*, where you log in with Google, GitHub, Apple or Amazon. It creates an "AWS project": a restricted AWS account that is not suited for production applications, and that Bref Cloud cannot connect to. [Learn why](#aws-projects).
3943
4044
If you want to learn more about how Bref Cloud connects securely to your AWS account, read the ["Security" documentation](./cloud-security.mdx).
4145

42-
AWS has a generous free tier that will usually allow you to deploy your first serverless applications for free.
46+
AWS has a generous free tier that will usually allow you to deploy your first serverless applications for free. If you choose the *Free plan* when signing up, AWS closes the account after 6 months (or once the free credits are used) unless you upgrade it to the *Paid plan*: upgrade before running production applications.
4347

4448
### Bref CLI
4549

@@ -77,9 +81,13 @@ To use Bref with the Serverless CLI, you will need an AWS account, the `serverle
7781

7882
### AWS account
7983

80-
Bref deploys your applications to your AWS account. To create one, **go to [aws.amazon.com](https://aws.amazon.com/) and click *Sign up***.
84+
Bref deploys your applications to your AWS account. To create one, **use the [AWS sign-up form](https://signin.aws.amazon.com/signup?request_type=register)** (*Sign up for AWS (advanced)*, the form that asks for a root user email address and an AWS account name).
8185

82-
AWS has a generous free tier that will usually allow you to deploy your first serverless applications for free.
86+
> [!WARNING]
87+
>
88+
> Do not use *Sign up for AWS (new)*, where you log in with Google, GitHub, Apple or Amazon. It creates an "AWS project": a restricted AWS account that is not suited for production applications. [Learn why](#aws-projects).
89+
90+
AWS has a generous free tier that will usually allow you to deploy your first serverless applications for free. If you choose the *Free plan* when signing up, AWS closes the account after 6 months (or once the free credits are used) unless you upgrade it to the *Paid plan*: upgrade before running production applications.
8391

8492
### Serverless CLI
8593

@@ -100,6 +108,8 @@ To use Bref with the Serverless CLI, you will need an AWS account, the `serverle
100108
> [!NOTE]
101109
>
102110
> If you have already set up AWS credentials on your machine (for example if you use the `aws` CLI), you can skip this step.
111+
>
112+
> If those credentials are stored in a named profile (for example created with `aws login --profile my-project`), select it with the `AWS_PROFILE` environment variable (`export AWS_PROFILE=my-project`) or with the `--aws-profile` option of the `serverless` CLI. Otherwise, `serverless deploy` fails with `AWS provider credentials not found`.
103113
104114
- [Create AWS access keys](./setup/aws-keys.mdx)
105115

@@ -132,3 +142,34 @@ That's it, you're ready to use Bref with the Serverless CLI!
132142
>
133143
> Bref is compatible with PHP 8.2 or greater.
134144
> If you are using PHP 8.0 or 8.1, Bref v2 (previous major version) will be installed instead.
145+
146+
## AWS projects
147+
148+
**Do not use AWS projects: create AWS accounts with *Sign up for AWS (advanced)*.**
149+
150+
AWS offers two ways to sign up:
151+
152+
- *Sign up for AWS (advanced)*: the [sign-up form](https://signin.aws.amazon.com/signup?request_type=register) that asks for a root user email address and an AWS account name. It creates a standard AWS account that you fully control.
153+
- *Sign up for AWS (new)*: you log in with Google, GitHub, Apple or Amazon, and AWS creates a "project". A project is an AWS account in an AWS Organization that AWS manages on your behalf, with restrictions that you cannot change.
154+
155+
Projects make the first steps on AWS easier, but they do not fit how companies run applications in production. Companies run production in an AWS Organization that they control, with separate AWS accounts for production, staging and development, their own security policies, and permissions for each team (see [AWS best practices](https://docs.aws.amazon.com/whitepapers/latest/organizing-your-aws-environment/organizing-your-aws-environment.html)). In a project:
156+
157+
- AWS manages the security policies of the organization (resource control policies and service control policies): you cannot define your own.
158+
- Every team member gets administrator access: permissions cannot be restricted per person or per team.
159+
- Services that access your AWS account through a cross-account IAM role do not work: monitoring, security or deployment services, including [Bref Cloud](/cloud). AWS denies access to projects from AWS accounts outside of their organization.
160+
- CI/CD pipelines cannot use OIDC federation to deploy without long-lived access keys (for example from GitHub Actions): AWS denies the creation of identity providers.
161+
- Applications can only run in one AWS region, chosen by AWS based on your country, and only a subset of AWS services is available.
162+
- With a spend limit, AWS blocks the creation of resources when the project gets close to the limit, then stops the application once the limit is reached (Lambda invocations are blocked).
163+
164+
AWS gives the same advice: do not use *Sign up for AWS (new)* if you need your own policies, fine-grained permissions, the full set of AWS services, or if you have regulated workloads (see [Compare sign-up options](https://docs.aws.amazon.com/accounts/latest/reference/sign-up-for-aws.html)).
165+
166+
Leaving these restrictions later requires "activating advanced features" in AWS Settings, which cannot be undone, and then removing the policies set by AWS yourself. Starting with a standard AWS account avoids that migration.
167+
168+
### Deploying to an existing AWS project
169+
170+
Bref Cloud cannot connect to AWS projects: AWS shows "Region United States (N. Virginia) unavailable" when creating the connection, or Bref Cloud reports that it is not authorized to assume its role.
171+
172+
With the Serverless CLI, deployments work with the following changes:
173+
174+
- Set `region` in `serverless.yml` to the region of your project, shown in [AWS Settings](https://settings.aws.com) (in the "Additional info" of the project). The examples in this documentation use `us-east-1`: deploying to a region other than the project's fails with an error ending with `with an explicit deny in a service control policy`.
175+
- AWS credentials are provided by `aws login`, in a named profile (for example `aws login --profile my-project`). Select that profile when deploying: `export AWS_PROFILE=my-project`. These sessions expire after 12 hours: run `aws login --profile my-project` again to renew them.

‎docs/symfony/messenger.mdx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,10 @@ However, instead of creating the SQS queue and the worker manually, you can use
6464
First install the Lift plugin:
6565

6666
```bash
67-
serverless plugin install -n serverless-lift
67+
npm install --save-dev serverless-lift
6868
```
6969

70-
Then use [the Queue construct](https://github.com/getlift/lift/blob/master/docs/queue.md) in `serverless.yml` to create a queue and a worker:
70+
Add `serverless-lift` to the `plugins` section of `serverless.yml`, after `./vendor/bref/bref`. Then use [the Queue construct](https://github.com/getlift/lift/blob/master/docs/queue.md) in `serverless.yml` to create a queue and a worker:
7171

7272
```yml filename="serverless.yml"
7373
provider:

‎docs/use-cases/websites.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ While it is possible to set up CloudFront manually, the easiest approach is to u
3636
First install the plugin:
3737

3838
```bash
39-
serverless plugin install -n serverless-lift
39+
npm install --save-dev serverless-lift
4040
```
4141

4242
<Tabs items={['Laravel', 'Symfony', 'PHP']}>

0 commit comments

Comments
 (0)