-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22937 from hashicorp/jbardin/cbd-modules
create_before_destroy across modules
- Loading branch information
Showing
19 changed files
with
541 additions
and
317 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
locals { | ||
l = data.null_data_source.d.id | ||
} | ||
|
||
data "null_data_source" "d" { | ||
} | ||
|
||
resource "null_resource" "a" { | ||
count = local.l == "NONE" ? 1 : 0 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
module "a" { | ||
source = "./mod1" | ||
} | ||
|
||
module "b" { | ||
source = "./mod2" | ||
ids = module.a.ids | ||
} |
10 changes: 10 additions & 0 deletions
10
terraform/testdata/apply-module-replace-cycle-cbd/mod1/main.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
resource "aws_instance" "a" { | ||
require_new = "new" | ||
lifecycle { | ||
create_before_destroy = true | ||
} | ||
} | ||
|
||
output "ids" { | ||
value = [aws_instance.a.id] | ||
} |
8 changes: 8 additions & 0 deletions
8
terraform/testdata/apply-module-replace-cycle-cbd/mod2/main.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
resource "aws_instance" "b" { | ||
count = length(var.ids) | ||
require_new = var.ids[count.index] | ||
} | ||
|
||
variable "ids" { | ||
type = list(string) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
module "a" { | ||
source = "./mod1" | ||
} | ||
|
||
module "b" { | ||
source = "./mod2" | ||
ids = module.a.ids | ||
} |
10 changes: 10 additions & 0 deletions
10
terraform/testdata/apply-module-replace-cycle/mod1/main.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
resource "aws_instance" "a" { | ||
require_new = "new" | ||
lifecycle { | ||
create_before_destroy = true | ||
} | ||
} | ||
|
||
output "ids" { | ||
value = [aws_instance.a.id] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
resource "aws_instance" "b" { | ||
count = length(var.ids) | ||
require_new = var.ids[count.index] | ||
} | ||
|
||
variable "ids" { | ||
type = list(string) | ||
} |
11 changes: 11 additions & 0 deletions
11
terraform/testdata/transform-cbd-destroy-edge-both-count/main.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
resource "test_object" "A" { | ||
count = 2 | ||
lifecycle { | ||
create_before_destroy = true | ||
} | ||
} | ||
|
||
resource "test_object" "B" { | ||
count = 2 | ||
test_string = test_object.A[*].test_string[count.index] | ||
} |
10 changes: 10 additions & 0 deletions
10
terraform/testdata/transform-cbd-destroy-edge-count/main.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
resource "test_object" "A" { | ||
lifecycle { | ||
create_before_destroy = true | ||
} | ||
} | ||
|
||
resource "test_object" "B" { | ||
count = 2 | ||
test_string = test_object.A.test_string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
resource "test_object" "A" { | ||
lifecycle { | ||
create_before_destroy = true | ||
} | ||
} | ||
|
||
resource "test_object" "B" { | ||
test_string = "${test_object.A.id}" | ||
} |
Oops, something went wrong.