in lambda/src/tags.ts [20:51]
export async function updateTags(
resourceArn: string,
tags?: Record<string, string>
): Promise<void> {
console.log('updating tags');
console.log(tags);
// get tags from the resource
const resourceTags = await auditManager
.listTagsForResource({ resourceArn })
.promise();
// remove all tags from resource
if (resourceTags.tags) {
await auditManager
.untagResource({
resourceArn,
tagKeys: Object.keys(resourceTags.tags),
})
.promise();
}
// add tags to resource
if (tags) {
await auditManager
.tagResource({
resourceArn,
tags,
})
.promise();
}
}