average-translator-13806
05/15/2024, 2:28 AMpulumi up
the next day it doesn't try to change the tag.
I tried
class CurrentDateComponent(pulumi.ComponentResource):
def __init__(self, name: str, opts: Optional[pulumi.ResourceOptions] = None):
super().__init__('custom:resource:CurrentDateComponent', name, None, opts)
self.date = datetime.now(UTC).date().strftime('%Y-%m-%d') # Store the current UTC date in ISO format
current_date = CurrentDateComponent("currentDate").date
and this seems to work. But, the resource shows as creating
the entire time the stack is being created.
What is an easy way to do this?average-translator-13806
05/15/2024, 2:29 AMmodern-zebra-45309
05/16/2024, 4:35 PMdatetime.now(UTC).date().strftime('%Y-%m-%d')
directly?
current_date = datetime.now(UTC).date().strftime('%Y-%m-%d')
resource1 = SomeAzureResource(..., tags={"created_at": current_date})
resource2 = SomeAzureResource(..., tags={"created_at": current_date})
This should update the resource every time you run pulumi up
if the value of current_date
has changed compared to the previous run.modern-zebra-45309
05/16/2024, 4:39 PMpulumi up
but only if some property of the resource changes (other than the tag) you can use the ignoreChanges resource option for that and ignore changes to the created_at
tag.