Skip to content

Commit

Permalink
atlantis import not works on workspace
Browse files Browse the repository at this point in the history
  • Loading branch information
krrrr38 committed Jan 5, 2023
1 parent b1b0b89 commit d46b2ae
Show file tree
Hide file tree
Showing 7 changed files with 102 additions and 0 deletions.
15 changes: 15 additions & 0 deletions server/controllers/events/events_controller_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,21 @@ func TestGitHubWorkflow(t *testing.T) {
{"exp-output-merge.txt"},
},
},
{
Description: "import workspace",
RepoDir: "import-workspace",
Comments: []string{
"atlantis import -d dir1 -w ops 'random_id.dummy1[0]' AA",
"atlantis import -p dir1-ops 'random_id.dummy2[0]' BB",
"atlantis plan -p dir1-ops",
},
ExpReplies: [][]string{
{"exp-output-import-dir1-ops-dummy1.txt"},
{"exp-output-import-dir1-ops-dummy2.txt"},
{"exp-output-plan.txt"},
{"exp-output-merge.txt"},
},
},
{
Description: "import single project with -var",
RepoDir: "import-single-project-var",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
version: 3
projects:
- name: dir1-ops
dir: dir1
workspace: ops
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
resource "random_id" "dummy1" {
count = terraform.workspace == "ops" ? 1 : 0

keepers = {}
byte_length = 1
}

resource "random_id" "dummy2" {
count = terraform.workspace == "ops" ? 1 : 0

keepers = {}
byte_length = 1
}

output "workspace" {
value = terraform.workspace
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Ran Import for project: `dir1-ops` dir: `dir1` workspace: `ops`

```diff
random_id.dummy1[0]: Importing from ID "AA"...
random_id.dummy1[0]: Import prepared!
Prepared random_id for import
random_id.dummy1[0]: Refreshing state... [id=AA]

Import successful!

The resources that were imported are shown above. These resources are now in
your Terraform state and will henceforth be managed by Terraform.


```

* :repeat: To **plan** this project again, comment:
* `atlantis plan -p dir1-ops`


Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Ran Import for project: `dir1-ops` dir: `dir1` workspace: `ops`

```diff
random_id.dummy2[0]: Importing from ID "BB"...
random_id.dummy2[0]: Import prepared!
Prepared random_id for import
random_id.dummy2[0]: Refreshing state... [id=BB]

Import successful!

The resources that were imported are shown above. These resources are now in
your Terraform state and will henceforth be managed by Terraform.


```

* :repeat: To **plan** this project again, comment:
* `atlantis plan -p dir1-ops`


Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Locks and plans deleted for the projects and workspaces modified in this pull request:

- dir: `dir1` workspace: `ops`
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Ran Plan for project: `dir1-ops` dir: `dir1` workspace: `ops`

```diff

No changes. Your infrastructure matches the configuration.

Terraform has compared your real infrastructure against your configuration
and found no differences, so no changes are needed.

```

* :arrow_forward: To **apply** this plan, comment:
* `atlantis apply -p dir1-ops`
* :put_litter_in_its_place: To **delete** this plan click [here](lock-url)
* :repeat: To **plan** this project again, comment:
* `atlantis plan -p dir1-ops`

---
* :fast_forward: To **apply** all unapplied plans from this pull request, comment:
* `atlantis apply`
* :put_litter_in_its_place: To delete all plans and locks for the PR, comment:
* `atlantis unlock`

0 comments on commit d46b2ae

Please sign in to comment.