Using the Configuration Manager module that comes with Drupal core to "automatically" as described in Managing your site's configuration is probably a better way to achieve what you want.
Create the new content types and their fields through the user interface.
On Configuration » Development » Configuration synchronization » Export » Single item, you just need to select your various pieces of content, one by one. For example, if you select Content type from the Configuration type menu and then a content type, you'll see the configuration you would need in the .yml file in the config/install directory for your module. Just eliminate that first uuid line. If you scroll down past the configuration text area, you'll see the name of the file name you need. For the Article content type, that would be node.type.article.yml.
You'll also need the field and field storage configuration types. Pay attention to the configuration dependencies and be sure you get all the pieces of configuration you need.
Once you get everything you need into configuration files, you can delete everything you created through the UI, reinstall your module, and verify everything works as expected. Otherwise, you can make changes through the user interface and export the configuration again. You could just edit the files directly, once you understand how everything is organized, especially if you're just making small changes.