Amplify-cli: What is the difference between `amplify init` with existing environment, and `amplify env checkout [env-name]`?

Created on 9 Oct 2019  路  3Comments  路  Source: aws-amplify/amplify-cli

And also, what is the difference between these operations:

amplify env checkout [env-name]

amplify env pull [env-name]

amplify env pull [env-name] --restore

The documentation mentions these should follow git workflows, but it's still nebulous to me what exactly these operations are doing, especially within a multi-stage amplify environment.

documentation platform question

Most helpful comment

@jkeys-ecg-nmsu

Please find response in-line

amplify env checkout [env-name]

This command helps you move from one environment to another similar to git checkout.
It carries over the contents of the amplify/backend directory i.e no changes are made to it but the amplify/#current-cloud-backend is overwritten by the contents of the cloud for the environment you're checking into i.e the env-name in the command.

amplify env pull [env-name]

This command helps you pulling in the state of the cloud - by pulling in the amplify/#current-cloud-backend directory for your current environment. You don't need the env-name parameter out here. This is helpful when you have multiple team members working on the same backend. You would ideally always pull before you push to the cloud.

amplify env pull [env-name] --restore

This command helps you pulling in the state of the cloud - by pulling in the amplify/#current-cloud-backend directory for your current environment, but it also replaces all the contents in your amplify/backend directory with that of amplify/#current-cloud-backend and all your local changes would be lost if you haven't pushed it.
This could be analogous to git reset master.

All 3 comments

@yuth @kaustavghosh06 I assume it has something to do with why aws-exports.js is in .gitignore by default and conversely why it must be removed to work with Amplify Console frontend-only deployments.

We're working toward a truly automated CI/CD workflow (sans manual approval), and understanding these commands is important for writing the scripts / buildspecs that will test and deploy our CF stacks that are managed by Amplify.

@jkeys-ecg-nmsu

Please find response in-line

amplify env checkout [env-name]

This command helps you move from one environment to another similar to git checkout.
It carries over the contents of the amplify/backend directory i.e no changes are made to it but the amplify/#current-cloud-backend is overwritten by the contents of the cloud for the environment you're checking into i.e the env-name in the command.

amplify env pull [env-name]

This command helps you pulling in the state of the cloud - by pulling in the amplify/#current-cloud-backend directory for your current environment. You don't need the env-name parameter out here. This is helpful when you have multiple team members working on the same backend. You would ideally always pull before you push to the cloud.

amplify env pull [env-name] --restore

This command helps you pulling in the state of the cloud - by pulling in the amplify/#current-cloud-backend directory for your current environment, but it also replaces all the contents in your amplify/backend directory with that of amplify/#current-cloud-backend and all your local changes would be lost if you haven't pushed it.
This could be analogous to git reset master.

Thank you! I think that's enough to write the CI/CD pipeline.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rehos picture rehos  路  3Comments

davo301 picture davo301  路  3Comments

kangks picture kangks  路  3Comments

adriatikgashi picture adriatikgashi  路  3Comments

ffxsam picture ffxsam  路  3Comments