You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: README.md
+41-13
Original file line number
Diff line number
Diff line change
@@ -45,13 +45,13 @@ Read about [Why We Built Atlantis](https://www.atlantis.run/blog/atlantis-releas
45
45
- Optionally, require a **review and approval** prior to running `apply`
46
46
47
47
➜ Also
48
-
- No more **copy-pasted code across workspaces/environments**. Atlantis supports using an `env/{env}.tfvars` file per workspace/environment so you can write your base configuration once
49
48
- Support **multiple versions of Terraform** with a simple project config file
50
49
51
50
## Atlantis Works With
52
51
* GitHub (public, private or enterprise) and GitLab (public, private or enterprise)
53
52
* Any Terraform version (see [Terraform Versions](#terraform-version))
54
53
* Can be run with a [single binary](https://github.com/runatlantis/atlantis/releases) or with our [Docker image](https://hub.docker.com/r/runatlantis/atlantis/)
54
+
* Any repository structure
55
55
56
56
## Getting Started
57
57
Download from [https://github.com/runatlantis/atlantis/releases](https://github.com/runatlantis/atlantis/releases)
@@ -71,15 +71,42 @@ If you're ready to permanently set up Atlantis see [Production-Ready Deployment]
71
71
## Pull/Merge Request Commands
72
72
Atlantis currently supports three commands that can be run via pull request comments (or merge request comments on GitLab):
73
73
74
+

74
75
#### `atlantis help`
75
76
View help
76
77
77
-
#### `atlantis plan [workspace]`
78
-
Runs `terraform plan` for the changes in this pull request. If `[workspace]` is specified, will switch to that workspace, before running `plan`. Any additional arguments passed to `atlantis plan` will be passed on to `terraform plan`. For example if you'd like to run `terraform plan -target={target}` then you can comment `atlantis plan -target={target}`.
78
+
---
79
+

80
+
#### `atlantis plan [options] -- [terraform plan flags]`
81
+
Runs `terraform plan` for the changes in this pull request.
82
+
83
+
Options:
84
+
*`-d directory` Which directory to run plan in relative to root of repo. Use '.' for root. If not specified, will attempt to run plan for all Terraform projects we think were modified in this changeset.
85
+
* -w workspace` Switch to this [Terraform workspace](https://www.terraform.io/docs/state/workspaces.html) before planning. Defaults to 'default'. If not using Terraform workspaces you can ignore this.
86
+
*`--verbose` Append Atlantis log to comment.
87
+
88
+
Additional Terraform flags:
89
+
90
+
If you need to run `terraform plan` with additional arguments, like `-target=resource` or `-var 'foo-bar'`
91
+
you can append them to the end of the comment after `--`, ex.
92
+
```
93
+
atlantis plan -d dir -- -var 'foo=bar'
94
+
```
95
+
If you always need to append a certain flag, see [Project-Specific Customization](#project-specific-customization).
Runs `terraform plan` for the changes in this pull request.
101
+
102
+
Options:
103
+
*`-d directory` Apply the plan for this directory, relative to root of repo. Use '.' for root. If not specified, will run apply against all plans created for this workspace.
104
+
* -w workspace` Apply the plan for this [Terraform workspace](https://www.terraform.io/docs/state/workspaces.html). Defaults to 'default'. If not using Terraform workspaces you can ignore this.
105
+
*`--verbose` Append Atlantis log to comment.
106
+
107
+
Additional Terraform flags:
79
108
80
-
#### `atlantis apply [workspace]`
81
-
Runs `terraform apply` for the plan generated by `atlantis plan`. If `[workspace]` is specified, will switch to that workspace.
82
-
Any additional arguments passed to `atlantis apply` will be passed on to `terraform apply`.
109
+
Same as with `atlantis plan`.
83
110
84
111
## Project Structure
85
112
Atlantis supports several Terraform project structures:
@@ -131,23 +158,24 @@ or
131
158
│ └── staging.tfvars
132
159
└── main.tf
133
160
```
134
-
With the above project structure you can de-duplicate your Terraform code between workspaces/environments without requiring extensive use of modules. At Hootsuite we've found this project format to be very successful and use it in all of our 100+ Terraform repositories.
161
+
With the above project structure you can de-duplicate your Terraform code between workspaces/environments without requiring extensive use of modules. At Hootsuite we found this project format to be very successful and use it in all of our 100+ Terraform repositories.
135
162
136
163
## Workspaces/Environments
137
164
Terraform introduced [Workspaces](https://www.terraform.io/docs/state/workspaces.html) in 0.9. They allow for
138
165
> a single directory of Terraform configuration to be used to manage multiple distinct sets of infrastructure resources
139
166
140
-
If you're using a Terraform version >= 0.9.0, Atlantis supports workspaces through an additional argument to the `atlantis plan` and `atlantis apply` commands.
167
+
If you're using a Terraform version >= 0.9.0, Atlantis supports workspaces through the `-w` flag.
141
168
For example,
142
169
```
143
-
atlantis plan staging
170
+
atlantis plan -w staging
144
171
```
145
172
146
173
If a workspace is specified, Atlantis will use `terraform workspace select {workspace}` prior to running `terraform plan` or `terraform apply`.
147
174
148
175
If you're using the `env/{env}.tfvars`[project structure](#project-structure) we will also append `-tfvars=env/{env}.tfvars` to `plan` and `apply`.
149
176
150
-
If no workspace is specified, terraform will use the `default` workspace by default.
177
+
If no workspace is specified, we'll use the `default` workspace by default.
178
+
This replicates Terraform's default behaviour which also uses the `default` workspace.
151
179
152
180
## Terraform Versions
153
181
By default, Atlantis will use the `terraform` executable that is in its path. To use a specific version of Terraform just install that version on the server that Atlantis is running on.
@@ -209,13 +237,13 @@ extra_arguments:
209
237
```
210
238
211
239
When running the `pre_plan`, `post_plan`, `pre_apply`, and `post_apply` commands the following environment variables are available
212
-
- `WORKSPACE`: if a workspace argument is supplied to `atlantis plan` or `atlantis apply`, ex `atlantis plan staging`, this will
240
+
- `WORKSPACE`: if a workspace argument is supplied to `atlantis plan` or `atlantis apply`, ex `atlantis plan -w staging`, this will
213
241
be the value of that argument. Else it will be `default`
214
242
- `ATLANTIS_TERRAFORM_VERSION`: local version of `terraform` or the version from `terraform_version` if specified, ex. `0.10.0`
215
243
- `DIR`: absolute path to the root of the project on disk
216
244
217
245
## Locking
218
-
When `plan` is run, the [project](#project) and [workspace](#workspaceenvironment) are **Locked** until an `apply` succeeds **and** the pull request/merge request is merged.
246
+
When `plan` is run, the [project](#project) and [workspace](#workspaceenvironment) (**but not the whole repo**) are **Locked** until an `apply` succeeds **and** the pull request/merge request is merged.
219
247
This protects against concurrent modifications to the same set of infrastructure and prevents
220
248
users from seeing a `plan` that will be invalid if another pull request is merged.
221
249
@@ -463,7 +491,7 @@ A Terraform workspace. See [terraform docs](https://www.terraform.io/docs/state/
463
491
## FAQ
464
492
**Q: Does Atlantis affect Terraform [remote state](https://www.terraform.io/docs/state/remote.html)?**
465
493
466
-
A: No. Atlantis does not interfere with Terraform remote state in anyway. Under the hood, Atlantis is simply executing `terraform plan` and `terraform apply`.
494
+
A: No. Atlantis does not interfere with Terraform remote state in any way. Under the hood, Atlantis is simply executing `terraform plan` and `terraform apply`.
467
495
468
496
**Q: How does Atlantis locking interact with Terraform [locking](https://www.terraform.io/docs/state/locking.html)?**
flagSet.StringVarP(&workspace, "workspace", "w", defaultWorkspace, fmt.Sprintf("Switch to this Terraform workspace before planning. Defaults to '%s'", defaultWorkspace))
98
+
flagSet.StringVarP(&dir, "dir", "d", "", "Which directory to run plan in relative to root of repo. Use '.' for root. If not specified, will attempt to run plan for all Terraform projects we think were modified in this changeset.")
99
+
flagSet.BoolVarP(&verbose, "verbose", "", false, "Append Atlantis log to comment.")
flagSet.StringVarP(&workspace, "workspace", "w", defaultWorkspace, fmt.Sprintf("Apply the plan for this Terraform workspace. Defaults to '%s'", defaultWorkspace))
104
+
flagSet.StringVarP(&dir, "dir", "d", "", "Apply the plan for this directory, relative to root of repo. Use '.' for root. If not specified, will run apply against all plans created for this workspace.")
105
+
flagSet.BoolVarP(&verbose, "verbose", "", false, "Append Atlantis log to comment.")
106
+
} else {
107
+
returnnil, fmt.Errorf("unknown command %q – this is a bug", command)
108
+
}
109
+
110
+
// Now parse the flags.
111
+
iferr:=flagSet.Parse(args[2:]); err!=nil {
112
+
returnnil, err
113
+
}
114
+
// We only use the extra args after the --. For example given a comment:
115
+
// "atlantis plan -bad-option -- -target=hi"
116
+
// we only append "-target=hi" to the eventual command.
117
+
// todo: keep track of the args we're discarding and include that with
0 commit comments