aws-amplify / amplify-hosting

AWS Amplify Hosting provides a Git-based workflow for deploying and hosting fullstack serverless web applications.
https://aws.amazon.com/amplify/hosting/
Apache License 2.0
457 stars 115 forks source link

[Question] Automate environment push and remove #719

Open marlonmarcello opened 4 years ago

marlonmarcello commented 4 years ago

Which Category is your question related to? Environments and teams workflow.

Amplify CLI Version 4.21.0

What AWS Services are you utilizing? Auth, Api, Storage, Hosting, Function, AppSync

Question Suppose I have the following workflow. A github repo with a master, develop and feature branches.
Developers can only merge to the develop and master branches through pull requests.
According to the docs to provision the backend from one environment to another one must:

  1. git clone
  2. amplify init
  3. git checkout feature
  4. amplify env checkout feature
  5. amplify pull
  6. git checkout develop
  7. amplify env checkout develop
  8. git merge feature
  9. amplify push

My question is, is there a way to automate this from a pull request? So a developer works on a feature on his own sandbox, he then creates a pull request and after the pull request is accepted and merged all of the steps above are automated. Maybe not all but those pertinent to merging a feature to develop.
Or will an admin have to perform all those steps above after a pull request is accepted?
Also, any way to remove an amplify environment automatically after a pull request has been merged and the branch deleted?

Just a note, I've set up Pull Request Previews and Continuous Deployment on AppSync.

ammarkarachi commented 4 years ago

@marlonmarcello We support a headless version some of the samples scripts and documentation. Is this something you were looking for?

marlonmarcello commented 4 years ago

These are interesting. Do you know of a way to implement these with the Amplify Console?

ammarkarachi commented 4 years ago

The Amplify Console does have a build script to perform CI/CD. Transferring to the console team as they should be able to help you out regarding this.

ihao8 commented 4 years ago

Hi @marlonmarcello , Here are some useful links about the way to use Amplify Console and Pr-Previews feature. If you have any questions, please let us know.

https://docs.aws.amazon.com/amplify/latest/userguide/getting-started.html https://docs.aws.amazon.com/amplify/latest/userguide/pr-previews.html

marlonmarcello commented 4 years ago

Hey @Joycehao19 , read though that and that's what I have at the moment.

I was looking for a way to automate the merge of amplify environments with pull requests.

Whenever an amplify environment is related to a branch, like the way it's recommended by the docs here: https://docs.amplify.aws/cli/teams/sandbox, and you want to merge said branch through a pull request, after doing the code review with the team a developer would have to manually merge the amplify environment after the pull request has been accepted.

I was looking for a way to automate that. Merge the amplify environment WITH the git branch. Basically, automating that second step described on the docs.

eduardohki commented 4 years ago

Like @marlonmarcello, I find the same issue for my projects.

I'm using the Pattern-based feature branch deployments, and the sandbox-backend environments are always kept.

There's no mention of this behaviour in the documentation, and the only solution I can see for now is for myself to create a custom Lambda function to cleanup the stale environments...

nkumar15 commented 3 years ago

Just curious to know if there is any update. Is am also in Sam situation.

For checkout of environment amplify pull can be used in headless mode.

But environment removal is still interactive. Is there any way we can remove environment in headless mode?

PatrykMilewski commented 3 years ago

It's very annoying that we can't have headless env checkout and removal. Currently I'm using this approach:

echo y | amplify env remove "${stage}"