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

add .hcl to supported file filter #748

Merged
merged 7 commits into from
Aug 26, 2019
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 36 additions & 1 deletion runatlantis.io/docs/custom-workflows.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ Given a directory structure:
.
├── live
│   ├── prod
│   │   └── terraform.tfvars
│   │   └── terraform.tfvars # OR terragrunt.hcl for terragrunt 0.19+
│   └── staging
│   └── terraform.tfvars
└── modules
Expand Down Expand Up @@ -176,6 +176,41 @@ Atlantis will need to have the `terragrunt` binary in its PATH.
If you're using Docker you can build your own image, see [Customization](/docs/deployment.html#customization).
:::

#### Terragrunt Autoplan Configuration
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you call this section Terragrunt 0.19+

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this actually applies to Terragrunt 0.18 as well. I think it could be confusing to call it Terragrunt 0.19+ since it really applies to all versions.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So is the section above where we tell people to list all the projects obsolete then?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there still might be a place for the above config. It depends on how you're using Terragrunt, really. If you have just a few modules then listing out each project works well. But if you have a ton of modules (like we do) then it makes more sense to use autoplan.

Since many Terragrunt projects have numerous nested folders where project files reside,
updating your repo-level `atlantis.yaml` to include every possible path can be tedious.

Instead, you can use a server-side repo config like this to enable autoplanning of your Terragrunt projects:

```json
{
"repos": [
{
"id": "/.*/",
"workflow": "terragrunt"
}
],
"workflows": {
"terragrunt": {
"plan": {
"steps": [
{
"run": "terragrunt plan -no-color -out=$PLANFILE"
}
]
},
"apply": {
"steps": [
{
"run": "terragrunt apply -no-color $PLANFILE"
}
]
}
}
}
}
```

### Running custom commands
Atlantis supports running completely custom commands. In this example, we want to run
a script after every `apply`:
Expand Down
4 changes: 2 additions & 2 deletions server/events/project_finder.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func (p *DefaultProjectFinder) DetermineProjects(log *logging.SimpleLogger, modi
if len(modifiedTerraformFiles) == 0 {
return projects
}
log.Info("filtered modified files to %d .tf files: %v",
log.Info("filtered modified files to %d .tf or terragrunt.hcl files: %v",
len(modifiedTerraformFiles), modifiedTerraformFiles)

var dirs []string
Expand Down Expand Up @@ -123,7 +123,7 @@ func (p *DefaultProjectFinder) filterToTerraform(files []string) []string {
for _, fileName := range files {
// Filter out tfstate files since they usually checked in by accident
// and regardless, they don't affect a plan.
if !p.isStatefile(fileName) && strings.Contains(fileName, ".tf") {
if !p.isStatefile(fileName) && (strings.Contains(fileName, ".tf") || fileName == "terragrunt.hcl") {
filtered = append(filtered, fileName)
}
}
Expand Down
6 changes: 6 additions & 0 deletions server/events/project_finder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,12 @@ func TestDetermineProjects(t *testing.T) {
[]string{},
"",
},
{
"Should not ignore terragrunt.hcl files",
[]string{"terragrunt.hcl"},
[]string{"."},
nestedModules2,
},
}
for _, c := range cases {
t.Run(c.description, func(t *testing.T) {
Expand Down