The ETA is valid for twelve months. If your passport has to be renewed before travel, you will need to apply for your ETA with your new passport. If your present passport doesn't need renewing, I would apply a few months before you travel, in case there are any problems with issuing the ETA.
This link will explain the procedures for applying for an ETA. Information and procedure to apply for an ETA
Note - you need to apply using an app which is easily downloaded from your phone's app store.