Skip to content

Access CodeArtifact from inside an EC2 instance

0

I'm experimenting with AWS Services to build my project, a backend Java using Docker for containers and Maven for dependencies, and Angular 16 for my front end, right now I have a VPC with 6 subnets, two of them are public. I have an RDS instance with public access as well and a Free Tier EC2 instance running with connection to this RDS instance, didn't test this connection yet so not sure if it works. I'm trying to build my project inside the EC2, a Docker Compose Up command with multiple Java Maven services where two of them have a dependency from my CodeArtifact repository but, not only it can't access this dependency, even though I have the settings.xml configured correctly, the command to get CodeArtifact's token ends with a time out when I try to run it inside the EC2, but works fine on my local machine. My Security Groups, the ones that this EC2 is using, have outbound permission to all protocols on "0.0.0.0/0" and "::/0" and my CodeArtifact policies are allowing everything to my root user and my dev user, which I'm using right now Am I doing something wrong? I saw here that it is possible but maybe not anymore? The public subnets have the same ACL configuration, tried to add another rule to allow outbound and inbound traffic but didn't work! Print from one of the Public Subnet ACL

I'm also adding the inbound and outbound rules here to make sure I'm not forgetting some configuration Inbound and outbound rules

Edit 1: Tried the solution proposed with the IAM Roles but no dice! Created a new instance and tried both with and without the IAM Role, following the tutorial on the YouTube video shared and even after attaching the IAM Role, I'm getting timed out! A photo of my PuTTy console, executed command before the IAM Role (first command) and after IAM Role (second command)

2 Answers
1

Hi,

This happens very probably because the Execution role of your EC2 instance where you access the other AWS services doesn't have the proper permissions to access those AWS services.

To understand EC2 execution role, please, have a look at:

Best,

Didier

EXPERT

answered 2 years ago

EXPERT

reviewed 2 years ago

  • Thank you! I tried to follow the steps on the YouTube video, really well made btw, but my issue persists! I even tried to create a new EC2 instance and do exactly what the person does on the video but, no deal! I managed to capture a screenshot with both, the command "aws iam list-users" before and after I attached the IAM role to the EC2, still getting a "Connect timeout on endpoint", gonna share the screenshot on the question

0
Accepted Answer

Well I fixed it by launching another instance but this time assigning an IPv4 for it. I really don't know if this is the problem but, it's the only thing that I did different (I was using only IPv6 since it's free). Thank you guys for your help!!

answered 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.