Error using chef provisioner [Terraform] while bootstrapping a node

I’ve been trying to bootstrap a node with terraform EC2 instance, but I keep getting the following error.

aws_instance.XXX (chef): curl: (7) Failed to connect to www.chef
aws_instance.XXX (chef): .io port 443: Connection timed out
aws_instance.XXX (chef): curl: (7) Failed to connect to www.ch
aws_instance.XXX (chef): ef.io port 443: Connection timed out
Error applying plan:

3 error(s) occurred:

If this was a one-time thing, it could’ve been a short outage (I’m not aware that we have had one recently, though). If this happens consistently, something is dropping the outbound packets from your nodes. In that case, you need to check your network configuration.

Does the subnet you specified have a route to the world? If memory serves me correctly I believe that terraforms default behavior in aws vpc is to remove all default routes. I will see if I can dig up some supporting documentation.

This is something about the was vocal networking thing where the teraform
launched ec2 instance does not have internet world route. (Verify your
outbound rules which is attached with instance and also make sure it on if
there any bastion between.
Have you checked to install chef-client on instance even after teraform
failed?