Yes. There are two points to consider.
You can’t purchase a product from another online retailer and ship them directly to your customers. However, when you have an order from Amazon, you can request your supplier to send you the product for Amazon to pick up from your location.
Ensure that your business information is on all packaging sold to your customers, not a third party.
Once you honor these two rules dropshipping with Amazon is 100% legal.