sparse-arm-65382
08/20/2024, 5:43 AMlet tags: { [key: string]: string } = {
foo: "abc",
bar: "def"
}
const existingRG = azure.resources.getResourceGroup({ resourceGroupName: args.rgName }, options)
const combinedTags = existingRG.then(t => {
const existingTags = t.tags || {}
Object.keys(tags).forEach(k => {
existingTags[k] = tags[k]
})
return existingTags
}).catch(e => {
console.warn(`Failed to retrieve resource group: ${e.message}.`);
return tags
})
I tried setting ignoreChanges to "tags", but that would ignore all changes, even those where I wanted to set a specific value and disable "drift-detection" on the important tags configured by my pulumi-code.
Is there a simpler way to achieve this?
I also have the problem that removing tags is not that easy that way and needs additional logic. Unfortunatly I did not found a way to access the state(stack-state) that was applied to azure during the last "pulumi up". Is there a way to access this state programmatically?adventurous-butcher-54166
08/21/2024, 9:36 AMPreview
, PropertyDiff
& DiffKind
– although I've never tested those and that would probably require a bigger change to your usage pattern.
Another solution which would be more transparent is to register a stack transform and do the lookup/combination in there. That way your declaration of resources doesn't get bloated with those extra lookups.No matter how you like to participate in developer communities, Pulumi wants to meet you there. If you want to meet other Pulumi users to share use-cases and best practices, contribute code or documentation, see us at an event, or just tell a story about something cool you did with Pulumi, you are part of our community.
Powered by