Closed pepoluan closed 4 years ago
Hi @pepoluan, sorry I didn't see this until recently.
This code passes terraform validate
:
from pretf.blocks import resource
def pretf_blocks(var):
yield resource.aws_lb.test(
name="test",
lifecycle={
"ignore_changes": [
'tags["Name"]'
]
}
)
or using the more verbose block function:
from pretf.api import block
def pretf_blocks(var):
yield block("resource", "aws_lb", "test", {
"name": "test",
"lifecycle": {
"ignore_changes": [
'tags["Name"]'
]
}
})
Pretf is just converting the dictionary into JSON so we have to figure out (or guess) what Terraform is expecting the JSON to be, and then do that. I just guessed that it was meant to be provided as a simple string.
The Terraform documentation describes a way of ignoring specific changes; the second example given shows how to ignore changes to the "Name" key of the "tags" attribute by writing it (in HCL) as:
The
tags["Name"]
syntax caught me; at a glance, it seems to be referring a mapping. So I did it like this:but I ended up with the following error when doing
pretf validate
:So how do I do the same (that is, ignore only changes to the "Name" key in the "tags" attribute) in a pretf
block
?