Skip to content

Commit 7a9d257

Browse files
authored
Merge pull request #407 from dflook/import-warnings
2 parents 6111533 + 83a60c0 commit 7a9d257

File tree

3 files changed

+83
-2
lines changed

3 files changed

+83
-2
lines changed

CHANGELOG.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,16 @@ The actions are versioned as a suite. Some actions may have no change in behavio
1111

1212
When using an action you can specify the version as:
1313

14-
- `@v2.2.1` to use an exact release
14+
- `@v2.2.2` to use an exact release
1515
- `@v2.2` to use the latest patch release for the specific minor version
1616
- `@v2` to use the latest patch release for the specific major version
1717

18+
## [2.2.2] - 2025-08-08
19+
20+
### Fixed
21+
- [dflook/terraform-apply](https://github.com/dflook/terraform-github-actions/tree/main/terraform-apply)/[dflook/tofu-apply](https://github.com/dflook/terraform-github-actions/tree/main/tofu-apply)
22+
could mistakenly think the plan had changed and abort the apply operation, if the plan imported resources and also contained warnings.
23+
1824
## [2.2.1] - 2025-08-02
1925

2026
### Fixed
@@ -791,6 +797,7 @@ First release of the GitHub Actions:
791797
- [dflook/terraform-new-workspace](terraform-new-workspace)
792798
- [dflook/terraform-destroy-workspace](terraform-destroy-workspace)
793799

800+
[2.2.2]: https://github.com/dflook/terraform-github-actions/compare/v2.2.1...v2.2.2
794801
[2.2.1]: https://github.com/dflook/terraform-github-actions/compare/v2.2.0...v2.2.1
795802
[2.2.0]: https://github.com/dflook/terraform-github-actions/compare/v2.1.0...v2.2.0
796803
[2.1.0]: https://github.com/dflook/terraform-github-actions/compare/v2.0.1...v2.1.0

image/src/github_pr_comment/cmp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def remove_warnings(plan: str) -> str:
2323

2424
plan_lines.append(line)
2525

26-
if re.match(r'Plan: \d+ to add, \d+ to change, \d+ to destroy', line):
26+
if re.match(r'Plan: \d+ to \S+', line):
2727
plan_summary_reached = True
2828

2929
return '\n'.join(plan_lines).strip()

tests/github_pr_comment/test_cmp.py

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,80 @@ def test_remove_unchanged_attributes():
2121

2222
assert remove_unchanged_attributes(plan) == expected
2323

24+
25+
def test_remove_warnings_with_import():
26+
plan = '''
27+
Terraform used the selected providers to generate the following execution
28+
plan. Resource actions are indicated with the following symbols:
29+
+ create
30+
31+
Terraform will perform the following actions:
32+
33+
# random_string.count[0] will be created
34+
+ resource "random_string" "count" {
35+
+ id = (known after apply)
36+
+ length = 5
37+
+ lower = true
38+
+ min_lower = 0
39+
+ min_numeric = 0
40+
+ min_special = 0
41+
+ min_upper = 0
42+
+ number = true
43+
+ numeric = true
44+
+ result = (known after apply)
45+
+ special = false
46+
+ upper = true
47+
}
48+
49+
Plan: 26 to import, 1 to add, 0 to change, 0 to destroy.
50+
51+
Changes to Outputs:
52+
+ count = (known after apply)
53+
54+
Warning: Resource targeting is in effect
55+
56+
You are creating a plan with the -target option, which means that the result
57+
of this plan may not represent all of the changes requested by the current
58+
configuration.
59+
60+
The -target option is not for routine use, and is provided only for
61+
exceptional situations such as recovering from errors or mistakes, or when
62+
Terraform specifically suggests to use it as part of an error message.
63+
'''
64+
65+
expected = '''
66+
Terraform used the selected providers to generate the following execution
67+
plan. Resource actions are indicated with the following symbols:
68+
+ create
69+
70+
Terraform will perform the following actions:
71+
72+
# random_string.count[0] will be created
73+
+ resource "random_string" "count" {
74+
+ id = (known after apply)
75+
+ length = 5
76+
+ lower = true
77+
+ min_lower = 0
78+
+ min_numeric = 0
79+
+ min_special = 0
80+
+ min_upper = 0
81+
+ number = true
82+
+ numeric = true
83+
+ result = (known after apply)
84+
+ special = false
85+
+ upper = true
86+
}
87+
88+
Plan: 26 to import, 1 to add, 0 to change, 0 to destroy.
89+
90+
Changes to Outputs:
91+
+ count = (known after apply)
92+
93+
'''
94+
95+
assert remove_warnings(plan).strip() == expected.strip()
96+
97+
2498
def test_remove_warnings():
2599
plan = '''
26100
Terraform used the selected providers to generate the following execution

0 commit comments

Comments
 (0)