-
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.
Adding ignore_changes lifecycle meta property
- Loading branch information
1 parent
bfc107f
commit a1939e7
Showing
10 changed files
with
193 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,3 +18,4 @@ website/node_modules | |
*.bak | ||
*~ | ||
.*.swp | ||
.idea |
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,17 @@ | ||
resource "aws_instance" "web" { | ||
ami = "foo" | ||
lifecycle { | ||
ignore_changes = ["ami"] | ||
} | ||
} | ||
|
||
resource "aws_instance" "bar" { | ||
ami = "foo" | ||
lifecycle { | ||
ignore_changes = [] | ||
} | ||
} | ||
|
||
resource "aws_instance" "baz" { | ||
ami = "foo" | ||
} |
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,32 @@ | ||
package terraform | ||
import ( | ||
"github.com/hashicorp/terraform/config" | ||
"strings" | ||
) | ||
|
||
// EvalIgnoreChanges is an EvalNode implementation that removes diff | ||
// attributes if their name matches names provided by the resource's | ||
// IgnoreChanges lifecycle. | ||
type EvalIgnoreChanges struct { | ||
Resource *config.Resource | ||
Diff **InstanceDiff | ||
} | ||
|
||
func (n *EvalIgnoreChanges) Eval(ctx EvalContext) (interface{}, error) { | ||
if n.Diff == nil || *n.Diff == nil || n.Resource == nil || n.Resource.Id() == "" { | ||
return nil, nil | ||
} | ||
|
||
diff := *n.Diff | ||
ignoreChanges := n.Resource.Lifecycle.IgnoreChanges | ||
|
||
for _, ignoredName := range ignoreChanges { | ||
for name := range diff.Attributes { | ||
if strings.HasPrefix(name, ignoredName) { | ||
delete(diff.Attributes, name) | ||
} | ||
} | ||
} | ||
|
||
return nil, nil | ||
} |
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,9 @@ | ||
variable "foo" {} | ||
|
||
resource "aws_instance" "foo" { | ||
ami = "${var.foo}" | ||
|
||
lifecycle { | ||
ignore_changes = ["ami"] | ||
} | ||
} |
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