Amplify-console: build settings (amplify.yml): difference between backend and frontend sections

Created on 27 Mar 2020  路  3Comments  路  Source: aws-amplify/amplify-console

Trying to learn more detail than is currently given at the page https://docs.aws.amazon.com/amplify/latest/userguide/build-settings.html about the amplify.yml build settings.

There are sections backend and frontend. Do these have any actual meaning or differences?

It seems that even the shell environment flows between them - for example I had a cd command in backend and one in frontend but the frontend one failed as the build was still in the directory from the backend cd command.

question

Most helpful comment

@helloPiers The three phases are borrowed from CodeBuild terminology, and primarily meant to organize _your_ commands into sections; you could stick them all in a single phase and it'd work all the same. The only thing the runner guarantees is the run-order (preBuild > build > postBuild).

The "we" is a bit confusing in that section, since it refers to what _your_ commands did in the build phase (presumably generate your assets and stick 'em in the output dir).

Closing for now, since this reply mostly just confirmed your correct understanding of what was happening. Feel free to reopen if you've any more questions.

All 3 comments

Hi @helloPiers, thanks for your question.
The 'backend'/'frontend' sections are used to appropriately group the logs during a build.
The commands that are in each section happen in the same container/shell environment, and the state does not reset between steps.
Let us know if you have any follow-up questions.

Thanks for the response - understand now that this split allows the Console UI to separate the log output into Backend and Frontend sections.

A quick follow-up - in the docs it says

postBuild - The post-build script runs after the build has finished and we have copied all the necessary artifacts to the output directory

I'm not quite sure who "we" is, and what "output directory" means here, but, I put a command in postBuild to overwrite a file in my /dist/ folder, and the overwritten file was what was published. In other words postBuild seems to run _before_ the artifacts are collected.

Do preBuild, build, and postBuild actually do anything different or just provide a conceptual way to organise the file?

@helloPiers The three phases are borrowed from CodeBuild terminology, and primarily meant to organize _your_ commands into sections; you could stick them all in a single phase and it'd work all the same. The only thing the runner guarantees is the run-order (preBuild > build > postBuild).

The "we" is a bit confusing in that section, since it refers to what _your_ commands did in the build phase (presumably generate your assets and stick 'em in the output dir).

Closing for now, since this reply mostly just confirmed your correct understanding of what was happening. Feel free to reopen if you've any more questions.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dongjason1 picture dongjason1  路  3Comments

asyschikov picture asyschikov  路  5Comments

BardiaN picture BardiaN  路  4Comments

gherrera-gesintel picture gherrera-gesintel  路  4Comments

lucaluke88 picture lucaluke88  路  4Comments