I imagine it will be a pain to do the development against a real AWS configuration
I’d argue the contrary. The real pain is trying to emulate a serverless application locally. Why try to emulate AWS when you can just operate out of AWS?
beside costs and the need to maintain a second AWS account
Costs are a factor, but for a serverless application, they should be minimal. If you can’t afford a dev version of a serverless application, than you can’t afford the prod version as well. Maintaining a second AWS account also shouldn’t be an issue if you’re set up correctly. Again, if maintaining a second AWS account (or an nth account) is too much of a pain, then a serverless application will be too much of a pain, too.
I wondered if there is any recommended practice when it comes to develop and test a serverless web application.
If your application is set up well, then you’ll have segregated the serverless portions of the app from the business logic of the app. From there, you should be able to handle the business logic locally (i.e., using unit tests, etc.) and handle serverless development in the cloud. There are different approaches for this and I don’t think any one approach is the recommended standard, but I recommend this approach.
Like, is there a way to replicate AWS in a local environment, where you could run your tests as well before you deploy?
Others have mentioned Localstack and other ways of emulating AWS services. These can work and are certainly important in some settings, but odds are if you’re asking these questions, then this approach isn’t very appropriate. You’ll be spending more time trying to get your local machine to act like AWS then actually getting your application to work in AWS.
Basically, I think you need to take a step back and recognize that you shouldn’t be trying to shoehorn a serverless app development process into something that looks more traditional. You either need to move away from serverless into something more conceptually simple or embrace serverless and try to work out of AWS directly. It’s the only feasible way of addressing classic issue of “but it worked on my machine” when the production “machine” fundamentally doesn’t resemble your machine.
And like I said, emulating AWS locally is an option and is something that is done regularly. But I’m telling you, on a personal level, that it’s more work than it seems, and if you’re a small (or one man) team, it ain’t worth it.