Amplify: Migrate the (very) easy way

Fastest way to migrate amplify to a more owned infrastructure

Ricardo Ribas
3 min readMay 8, 2023

This article is part of a series of articles that talk about AWS Amplify, but also how to migrate it to a more flexible and extensible infrastructure.

When me and Amplify first meet, we didn’t know much about each other. It was mandatory to dig through the documentation if I wanted to have success of any kind.

However, there comes a time that things change and we had to move things apart. There comes a time that the product you are working on changes requirements, or the team scales and Amplify is no longer a valid solution for you.

A few years ago, when I had to tackle an Amplify migration for the very first time, I didn’t have the expertise about AWS Cloudformation that I have nowadays, but also I didn’t certain features available. It happens that after a few months, aws came up with a sky rocket idea: export the whole infrastructure into a folder in a single command. This git commit started it all 🙏. From the official documentation:

Export Amplify CLI-generated backends as a Cloud Development Kit (CDK) stack and incorporate into existing CDK deployment pipelines. This capability allows frontend developers to build their app backend quickly and, each time it is ready to ship, hand it over to DevOps teams to deploy to production.

That’s right! An export feature was ready to be used. Not sure if was lack of luck or just ignorance (why not both?), but if I had the opportunity to go back in time, I would give it a go, manage better the expectations with the managers and prepare a further migration in a smoother way. Live and learn, live and learn…

You can check the whole command docs here. Bear in mind that the time I am writing this, the notifications feature is not included in the export feature. In any of the cases, almost 100% of the infrastructure is just around the corner and you can hand it to the devops team or the backend people. Easy peasy lemon squeezy. 🍋

# let the magic happens
$ amplify export --out <your-cdk-project-location>

$ pushd <your-cdk-project-location>
$ ls -la

drwx------ 10 johndoe unknown 320 May 5 19:38 .
drwxr-xr-x 3 johndoe unknown 96 May 5 19:38 ..
-rw-r--r-- 1 johndoe unknown 11845 May 5 19:38 amplify-export-manifest.json
drwxr-xr-x 3 johndoe unknown 96 May 5 19:38 analytics
drwxr-xr-x 4 johndoe unknown 128 May 5 19:38 api
drwxr-xr-x 4 johndoe unknown 128 May 5 19:38 auth
-rw-r--r-- 1 johndoe unknown 1172 May 5 19:38 category-stack-mapping.json
-rw-r--r-- 1 johndoe unknown 132 May 5 19:38 export-tags.json
drwxr-xr-x 8 johndoe unknown 256 May 5 19:38 function
-rw-r--r-- 1 johndoe unknown 20208 May 5 19:38 root-stack-template.json

$ popd

If you are familiar with cloudformation, you will notice that most of the files generated are descriptors of the stacks of the infrastructure overall. They will give you all the details about the (1) parameters you can pass for each feature, (2) outputs and (3) resources that compose a feature.

Conclusion

Exporting an infrastructure in such a easy way, makes it look like backend a very easy job to do 😂. I am afraid not. Amplify is just a very nice piece of engineering made by very nice engineers to ease the hassle of starting up a whole cloud infrastructure from scratch. Even if you don’t use the exported resources and want to create something from scratch, at least you have a good source of inspiration.

Thanks a lot for reading and feel free to clap your hands and hit the follow button 🤓

--

--

Ricardo Ribas

Software Engineer passionate about rock climbing, yoga, gaming and travelling