Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I deploy a new version of an existing Amplify app using the AWS/Amplify CLI without user interaction?

I am a newbie in using AWS Amplify and I just published my own frontend WebApp with it developed with React. I just zipped my build folder and dropped the resulting zip file in the AWS Console. It is working fine.

enter image description here

However, the job is done manually and I want to automate that. I have CI&CD servers other than the ones in AWS which are working fine for my other services. So what I need is a script to automate what I just did as a I want to reuse my existing CI&CD servers. Having such a script will be really useful as I can reproduce the steps locally or in a docker container.

I know that there is a solution for that: the amplify CLI. However, commands such as amplify init, amplify configure and amplify pull require a lot rights and a lot of user interaction even the AWS profile (with the secret key and access key) has already been configured.

It would be great to do something like this:

amplify deploy build.zip <APP-ARN>

or (in case of a folder)

amplify deploy /build <APP-ARN>

Essentially, I just want to automate what I did manually: uploading the (zipped) build folder to deploy my AWS Amplify app. Thus, this means no user interaction.

How to do this?

like image 240
Daan Avatar asked Jun 08 '21 09:06

Daan


1 Answers

Your solution is git, aws amplify has the ability to watch a git repo and detect changes. If there is a change to the branch that you have set it to watch, it will automatically build a new version.

You can set it up to build only frontend or both backend (amplify) and frontend.

  1. Create a git repo. You can use for example github or aws codecommit

  2. Configure your project to publish to that git repo

  3. In AWS Amplify console start a new app or change your existing one, to watch the git repo

  4. Publish changes to the git repo and watch in the amplify console that it automatically builds a new version of your app

like image 62
Engam Avatar answered Sep 27 '22 19:09

Engam