I am trying to programmatically create a key pair with the AWS JS sdk. I am working within a docker container on an EC2 server. My aws credentials are correct as well as the region. After creating the client, I send keypair request with await client.send(command)
with the client being the Ec2Client created the credentials, and the command being created by the CreateKeyPairCommand
- after which i receive the following error Error [TimeoutError]: Socket timed out without establishing a connection within 1100 ms at Timeout._onTimeout (/usr/src/app/node_modules/@aws-sdk/node-http-handler/dist-cjs/set-connection-timeout.js:12:38) at listOnTimeout (node:internal/timers:564:17) at process.processTimers (node:internal/timers:507:7) { '$metadata': { attempts: 5, totalRetryDelay: 1029 } }
My hunch is that it is an issue with the ports and the way the sdk communicates with aws. Upon further research, I've come to see that aws communicates over ports 443 for HTTPS and 80 for HTTP, which are both exposed for my docker application both in the containers as well as the associated security group. I can ssh into the client and connect with the container, and run requests from postman through the container otherwise. It is only when the aws sdk tries to send a request that this networking error presents itself. If you have any ideas, let me know!