Hi all,
currently I am looking into Aspects to add tags to certain resources.
export class TagsAddingAspect implements IAspect {
constructor(private tagsToAdd: Record<string, string>) {}
// This method is called on every Construct within the specified scope (resources, data sources, etc.).
visit(node: IConstruct): void {
node.node.findAll().map((e) => {
if (e instanceof TerraformResource) {
if (e.hasOwnProperty('_tags')) {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
//@ts-ignore
e['_tags'] = { ...e['_tags'], ...this.tagsToAdd }
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
//@ts-ignore
console.log(e['_tags'])
}
}
})
}
}
beside that i find it a bit strange why all private attributes are implemented with _
. That leads to a lot of trouble, e.g. destructuring. You end up with strange things likes const { attr: _attr = '' } = { ...resource }
to satisfy the compiler and the above code is as well not really nice.
Maybe I am just doing something wrong, so if anybody has a better solution I would be really glad to hear it.
regards
Mathias