atlantis: Error `unsafe repository` using EFS via terraform-aws-atlantis pre-v3.17.0
Community Note
- Please vote on this issue by adding a π reaction to the original issue to help the community and maintainers prioritize this request. Searching for pre-existing feature requests helps us consolidate datapoints for identical requirements into a single place, thank you!
- Please do not leave β+1β or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.
- If you are interested in working on this issue or have submitted a pull request, please leave a comment.
Overview of the Issue
I havenβt seen this issue noted in here, but I am reporting this in case anybody else has experienced this.
After recently restarting our Atlantis task, each atlantis plan results in a failure to download every single module. One such failure message looks like this:
β·
β Error: Failed to download module
β
β Could not download module "cloudtrail" (cloudtrail.tf:12) source code from
β "git::https://github.com/trussworks/terraform-aws-cloudtrail?ref=v4.3.0":
β error downloading
β 'https://github.com/trussworks/terraform-aws-cloudtrail?ref=v4.3.0':
β /usr/bin/git exited with 128: fatal: unsafe repository
β ('/******/.terraform/modules/cloudtrail'
β is owned by someone else)
β To add an exception for this directory, call:
β
β git config --global --add safe.directory
β /******/.terraform/modules/cloudtrail
β .
β΅
We understand this is related to the recent Git security vulnerability. Weβve tried adding the suggested git config --global --add safe.directory <repo> or to via * as documented here but have not had success.
Reproduction Steps
This problem began after we restarted our atlantis task in ECS. The git version running on the previous task was from a git version before the security patch.
Logs
Environment details
Atlantis version:
- terraform-aws-modules/atlantis/aws v3.14.0
- runatlantis/atlantis:v0.18.1 - https://github.com/transcom/circleci-docker/blob/master/milmove-atlantis/Dockerfile If not running the latest Atlantis version have you tried to reproduce this issue on the latest version: No
Additional Context
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 46
- Comments: 18 (5 by maintainers)
I was able to workaround this issue setting the user too. The EFS storage wasnβt much of a need to me, and I couldnβt easily mount it externally, so I ended up adding the following lines on my terraform resource (using terraform-aws-atlantis):
For those running https://github.com/terraform-aws-modules/terraform-aws-atlantis the fix for me was to set the
user = "100:1000"which is theatlantisuser in the official image. You will also need to mount the EFS directory externally andsudo chown -R 100:1000 <your_efs_mount>. By default, the EFS mount isroot:root.Not sure if applicable but the issue is still present on latest version @nitrocode
thanks @andyshinn & @biancarosa it was related to https://github.com/terraform-aws-modules/terraform-aws-atlantis/pull/287 from the initial setup
terraform-aws-atlantisif you was not create useratlantisasuid = 100&gid = 1000byuser = "100:1000"EFS will mount with root user1000:1000we could use as belowor
Sorry, I donβt remember the exact steps. What I did was something like:
sudo chown -R 100:1000against the mountnote that switching to the Atlantis non root user may impact the above workaround