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
@@ -48,6 +50,20 @@ Please note not all resource configuration properties are supported, however the
48
50
49
51
The most notable change between Amplify Gen 1 backends and Gen 2 backends is the use of infrastructure as code with TypeScript. Preparing your environment for migration involves converting the configuration of your live Gen 1 backend resources to their Gen 2 equivalent written using TypeScript.
50
52
53
+
<Calloutinfo>
54
+
55
+
**Testers Only**
56
+
57
+
Prerequisites:
58
+
59
+
- Node.js v18.17.1 or higher
60
+
-[Local AWS CLI profile](/gen1/[platform]/start/getting-started/installation/) with `AdministratorAccess-Amplify` and the `AmplifyBackendDeployFullAccess` policies attached.
61
+
- Existing Gen 1 backend or a [new Gen 1 app created](/gen1/[platform]/start/getting-started/) with some backend resources.
62
+
- Git
63
+
- Package manager (npm, yarn, pnpm)
64
+
65
+
</Callout>
66
+
51
67
To get started, create a new git branch and Amplify backend:
52
68
53
69
```bash title="Terminal" showLineNumbers={false}
@@ -64,12 +80,54 @@ amplify add env migrate
64
80
65
81
</Callout>
66
82
83
+
<Calloutinfo>
84
+
85
+
**Testers Only**
86
+
87
+
For testing purposes, you will need to additionally install the tagged versions of the `@aws-amplify/cli` package.
After this command completes successfully your `amplify/` directory is converted to an Amplify Gen 2 backend authored in TypeScript. In the next section we will walk through how to validate the generated code using [Amplify Gen 2's sandbox feature](/[platform]/deploy-and-host/sandbox-environments/setup/).
90
166
167
+
91
168
## Validating the preparation
92
169
93
170
The preparation command will add npm dependencies relevant to your Gen 2 backend in the root `package.json`. Before you begin with the validation, install dependencies:
94
171
172
+
95
173
```bash title="Terminal" showLineNumbers={false}
96
174
npm install
97
175
```
98
176
177
+
<Calloutinfo>
178
+
179
+
**Testers Only**
180
+
181
+
For testing purposes, you will need to additionally install the tagged versions of the `@aws-amplify/backend` and `@aws-amplify/backend-data` packages.
We will need to add the following manually to `backend.ts` file to set up the `Identity providers` on the `User pool client`. This is needed since Gen 2 only supports 1 user pool client out-of-the-box. Add the following code to `backend.ts` file after the `User pool client` is defined:
In order to provide a smoother experience with the migration tooling, we have added `throw new Error` messages to the generated code. This is to ensure that resources requiring manual changes are modified in your sandbox environment before the migration is executed.
239
+
240
+
For example, if you have a Node.js Lambda function in Gen 1, you will see the following error in your sandbox run:
241
+
242
+
```bash title="Terminal" showLineNumbers={false}
243
+
Source code forthis function can be foundin your Amplify Gen 1 Directory. See .amplify/migration/amplify/backend/function/app81ff331aPostConfirmation/src
244
+
```
245
+
246
+
you will need to copy the code from your Gen 1 backend and make any necessary changes to the code such as updating to TypeScript and updating the import statements.
247
+
248
+
**Note:** You will need to install the Lambda dependencies in the project root `package.json` file.
249
+
250
+
</Callout>
251
+
103
252
```bash title="Terminal" showLineNumbers={false}
104
253
npx ampx sandbox
105
254
```
106
255
256
+
<Callout info>
257
+
258
+
If you have not deployed a Amplify Gen 2 backend before, the process will redirect you the Amplify Console to bootstrap your AWS account and region. Ensure you are signed in with Admin credentials.
259
+
260
+
If you experience any errors, refer to the [troubleshooting section]([platform]/build-a-backend/troubleshooting/).
261
+
262
+
</Callout>
263
+
107
264
```bash title="Terminal" showLineNumbers={false}
108
265
npx ampx sandbox delete --yes
109
266
```
@@ -116,6 +273,22 @@ git push
116
273
117
274
In order to execute the migration you will need to first deploy the Amplify Gen 2 backend, scaffolded by the TypeScript code generated by the preparation command. This will create a new CloudFormation stack with live resources, which will then be used to execute the migration against to migrate resources from your Amplify Gen 1 backend stack to the new stack.
118
275
276
+
<Callout info>
277
+
278
+
**Testers Only**
279
+
280
+
Deploy a new Amplify App with your repository and selectthe`migrate` branch.
281
+
282
+
<Video src="/images/gen2/getting-started/react/deploy.mp4" description="Video - Deploy the starter app" />
283
+
284
+
</Callout>
285
+
286
+
Next, make a note of the stack name of your Gen 2 backend, you can find this in the build logs or the CloudFormation stack console:
287
+
288
+
1. Open the [CloudFormation stack console](https://console.aws.amazon.com/cloudformation/).
289
+
2. Find the stack with the Amplify AppID. The name should be in the format `amplify-<app-id>-<branch-name>-<random-id>`
290
+
3. Make a note of the stack name.
291
+
119
292
{/* picture of amplify console connecting new `migrate` branch */}
120
293
121
294
{/* how to handle CDK bootstrap */}
@@ -129,19 +302,70 @@ In order to execute the migration you will need to first deploy the Amplify Gen
Then copy the `amplify/` directory from the `.amplify/migration` directory back into your project.
344
+
345
+
138
346
## Post-migration tasks
139
347
140
348
{/* a note about s3 bucket names */}
141
349
{/* ... anything else*/}
142
350
{/*set up CI/CD */}
143
351
{/* deploy using backend-cli manually (for those not using Amplify to deploy today) */}
144
352
353
+
<Callout info>
354
+
355
+
**Testers Only**
356
+
357
+
Delete Cognito User pool custom domain from `amplify/backend.ts` as the domain already exists (This will not delete the domain from Cognito User pool):
358
+
359
+
```typescript
360
+
delete (backend.auth.stack.node.children.find(child => child.node.id === 'amplifyAuth') as any).domainPrefix;
361
+
```
362
+
363
+
Open `.amplify/migration/README.md` and follow the instructions to complete the post-migration tasks.
364
+
365
+
Then redeploy the application by committing the changes to Git.
366
+
367
+
</Callout>
368
+
145
369
## Verify continuous deployment
146
370
147
371
After performing the post-migration tasks, commit your changes and allow your deployment pipeline to deploy changes without error.
@@ -355,5 +579,3 @@ The tables below present a feature matrix for Gen 1 customers who are considerin
0 commit comments