Michael
Michael

Reputation: 572

cdktf lifecycle ignore_changes doesn't seem to work for tags

I have a terraform stack that is managed using the python version of cdktf where each instance has some tags associated with it, something like:

start_time = datetime.now(timezone.utc).strftime("%Y-%m-%d %H:%M")

self.instance = Instance(
    self,
    f"some-instance",
    ami=ami,
    instance_type=instance_type,
    ...
    tags=dict(
        start_time=start_time,
        ...
    )
)

When I do a cdktf deploy with this, I always get a change to the "starting" tag. I would like to avoid this being marked as a diff so going by this post it seems it should be possible to add a lifecycle entry and it will be ignored:

self.instance = Instance(
    ...
    lifecycle=dict(ignore_changes=["tags.start_time"]),
)

However, this doesn't seem to work. It doesn't seem to have much documentation in this area so I suspect I'm doing something wrong with the format.

Does anyone know what the correct format is? Or if this should even work?


[1] https://registry.terraform.io/providers/hashicorp/aws/latest/docs/guides/resource-tagging#ignoring-changes-in-individual-resources

Upvotes: 0

Views: 330

Answers (0)

Related Questions