First thing I want to suggest you that don't write your whole code in a file. Split your project and try to use the module concept in Terraform. Then it will be easier to troubleshoot any issue. Now regarding your error, it says it can't find a matching route for nat gateway with destination 0.0.0.0/0, however, in AWS console, the route was created. Any plan after this attempts to add it again and fails as a duplicate entry until the route is manually removed or imported into the TF state.