Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS Amplify Console deploy to different accounts

Tags:

aws-amplify

I have 4 relevant AWS accounts (Services, Dev, QA, Prod). I intended Services to contain the CI/CD pipeline and deploy to the environment specific accounts. I setup a IAM user in each environment account to use for deployments. With AWS Amplify CLI I am able to set a different profile for each environment so that I can deploy to different accounts.

This works great but I wanted to use the Amplify Console as my CI/CD pipeline. It has the ability to setup different pipelines for different branches and is able to deploy the front-end to different accounts but requires a role to deploy the back-end. I can't find a way to set it up so that it can deploy the back-end to a different account but I am fairly new to it.

For now I will either use another CI/CD solution and make calls to the Amplify CLI or setup the Amplify pipeline in each environment account.

Is there a way to setup the Amplify Console so that I can deploy the application back-end to a different account?

like image 470
bygrace Avatar asked Jan 10 '19 18:01

bygrace


1 Answers

Update on 19/11/2019:

Using something like

 - echo -e "[default]\nregion={our-region}" > ~/.aws/config
 - amplifyPush --simple

on backend phase of amplify.yml seems possible to manipulate the aws profile used by Amplify CLI and eventually deploy to different AWS accounts. At least by this way, I was able to deploy 2 different environments in different regions using a single instance of Amplify Console & AWS CodeCommit using the following instructions:

# Set a different region Amplify CLI 
- if [ "${AWS_BRANCH}" != "master" ]; then echo -e "[default]\nregion=${DEV_REGION}" > ~/.aws/config; fi
- '# Execute Amplify CLI with the helper script'
- amplifyPush --simple

Credits to this post


This doesn't seem possible and there is an open pull request looking for support.

However, you can set up Amplify console in each AWS account and trigger independent deploys based on the branch:

  • dev branch -> dev AWS account;
  • master branch -> Production account;

and so on.

You can keep Amplify console set up in the same way by "Save the build settings in your repository - Download the amplify.yml file and add it to the root of your repository (or root of the app folder for monorepos).".

Last, replication won't be required in case you (or someone else) uses AWS CodeCommit as a version control system but a Cross-Account Access configuration would be required.

like image 85
r.pedrosa Avatar answered Nov 12 '22 16:11

r.pedrosa