1

I have an EC2 instance running Docker with GitLab Runner that will create containers for jobs.

These containers are usually built from the gitlab-terraform registry image.

I'm using Terraform containers to create EC2 infrastructure via the GitLab Runner (GitLab CI/CD). When planning, each time I get an error saying that Terraform cannot reach my credentials, despite me attaching a role to the EC2 instance.

Has anyone faced this issue before? If yes, how did you fix that

Fares
  • 893
  • 1
  • 11
  • 24
  • Are you just running Terraform in a Docker container directly on an EC2 instance without ECS or Kubernetes? If so you should still have access to the instance metadata endpoint that vends credentials which you can test by execing into the container and attempting to curl it. You should also check that the instance profile has the correct permissions attached by running the AWS CLI locally on the instance not in a container. – ydaetskcoR Aug 11 '20 at 11:24

1 Answers1

0

Are you running the Gitlab CI with a specific Runner for the repository? If so, the EC2 for the specific runner must have IAM role for the tasks the terraform scripts are performing. There's a difference process if you're using shared Runner

NLee
  • 1
  • 1