Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

with terragrunt-alantis-config, do i still need to commit the alantis.yaml to github ? #86

Closed
ishallbethat opened this issue Nov 26, 2020 · 8 comments · Fixed by #105
Closed

Comments

@ishallbethat
Copy link

I don't know how to make the atlantis.yaml automatically generated every time i create a pull request, and atlantis can pick up this auto generated file then do terragrunt plan or apply.

I think this would be best if atlantis.yaml can be auto generated and i don't need to keep track of this file in github repo.

@michaelfarrell76
Copy link
Member

the plan for this is atlantis is adding a feature to allow for pre-workflow custom hooks

see the issue
and the open pr

@michaelfarrell76
Copy link
Member

for now would recommend committing the atlantis.yaml until that is merged

@ishallbethat
Copy link
Author

I'm looking at "terragrunt-atlantis-config using github action to validate atlantis.yaml" . I'm not sure it's a way to achieve what i need. @michaelfarrell76

@angeloskaltsikis
Copy link
Contributor

@IamGabrielWu You can follow the method described in this medium post till the PR of having pre-workflow custom hooks is merged.

I would advise against committing as you will have each user run the current project
cc. @michaelfarrell76

@dmattia
Copy link
Member

dmattia commented Nov 26, 2020

I'm going to close this, but feel free to open if you have any other questions.

To summarize:

  • you can keep committing atlantis.yaml to github
  • @angeloskaltsikis has a very nice solution you can migrate to now to not need to commit
  • fairly soon, atlantis should support hooks that are another option for not needing to commit

@dmattia dmattia closed this as completed Nov 26, 2020
@dmattia
Copy link
Member

dmattia commented Jan 3, 2021

runatlantis/atlantis#1255 has been released in Atlantis v0.16.0, allowing us to run terragrunt-atlantis-config on the Atlantis server side of things.

I'll be updating the documentation of this repo soon with how to use the new features 😄

@dmattia dmattia reopened this Jan 3, 2021
@tsunamishaun
Copy link

tsunamishaun commented Jan 14, 2021

@angeloskaltsikis the post wasn't entirely clear on how to setup the post-clone git hook, I ended up putting the core.hooksPath in /etc/gitconfig with /home/atlantis/hooks as the path. Though I am using the new pre-workflow feature of atlantis it doesn't consistently run for subsequent workspaces, making my atlantis.yaml not clone into each workspace directory. I am using both methods now and things appear stable, would love to keep the conversation going and see what you come up with @dmattia.

My use case is for multi account and by passing in account name I'm able to generate the config just for the instance of atlantis set for the account. This line is in my root terragrunt.hcl (hopefully it helps someone else):

locals {
  atlantis_skip = get_env("ATLANTIS_ENABLED_ACCOUNTS", "") == local.account_name ? false : true
}

It does mean that bad configs will break everything and that there is no way to ignore a directory (per the way I am parsing the environment variable, suggestions welcome!).

@kitos9112
Copy link

Many thanks @tsunamishaun for sharing the above code snippet. It has just solved the first impediment I was facing with this fantastic tool to generate the atlantis.yaml - Although, I slightly modified the Terraform built-in function as I didn't bother about hardcoding the name of my AWS workload in the top-level terragrunt.hcl:

locals {
  (...)
  atlantis_skip = contains(["dev"], local.aws_account_workload) ? false : true
}

At the moment, we only let Atlantis run in our AWS development account so we can take careful decisions about moving code into other more sensitive environments by leveraging a dedicated GitLab runner.

I even think it should be clearly indicated in the README.md of this project given the fact it also works despite utilising the CLI flag --ignore-parent-terragrunt:

How to limit the automatic generation of an atlantis.yaml configuration for a well-known Terragrunt directory-driven layout:

account
 └ _global
 └ region
    └ _global
    └ environment
       └ resource

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants