I've the application deployed on an EC2 instance with an IAM role attached. The instance running inside of private subnet. I'm getting the networking error while trying to listing the buckets from S3 service.
Error: connect ETIMEDOUT 10.100.20.30:443
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1144:16) {
errno: -110,
code: 'NetworkingError',
syscall: 'connect',
address: '10.100.20.30',
port: 443,
region: 'us-east-1',
hostname: 'mybucket.s3.us-east-1.amazonaws.com',
retryable: true,
time: 2020-07-28T05:44:13.678Z
} Error: connect ETIMEDOUT 10.100.20.30:443
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1144:16)
It appears that your situation is:
There are two ways to achieve this:
Option 1: Internet Access
Amazon S3 resides on the Internet. Since the EC2 instance is in a private subnet, it will need to use a NAT Gateway to access the Internet and Amazon S3.
The NAT Gateway should be launched in a public subnet and the Route Table for the private subnet(s) should be updated to send traffic destined for
0.0.0.0/0to the NAT Gateway.Option 2: VPC Endpoint
Alternatively, you can add a VPC Endpoint for S3, which provides a 'short-cut' to communicate with Amazon S3 without going via the Internet.