I have an EC2 instance that has an S3_Admin_Access role attached to it. I also have a IAM user with full admin access, and I configured the aws cli on the EC2 instance with the user's credentials. However, when I try to execute aws s3 ls from the EC2 instance terminal, the HTTPS connection times out. Trying the same from my laptop's terminal, the call succeeds. The aws cli is configured with the same credentials as the EC2 instance.
I added inbound rules over SSH/HTTP/HTTPS to the EC2 instance, and I removed the outbound rule that allows all traffic. Interestingly enough, if I add the "allow all" outbound rule back, the aws cli call works, the HTTPS connection does not time out, and I get a list of all buckets. I also added outbound rules only for SSH/HTTPS, and this, again, works. However, removing the outbound rules breaks the call again.
I thought that inbound rules are stateful, as in, if i have an inbound rule over a protocol/port, I do not need an explicit outbound rule over the same port. However, that does not seem to be working. What else might be the problem? Note that I can ssh into the EC2 instance without the outbound rule being present.