https://pulumi.com logo
#azure
Title
# azure
p

prehistoric-kite-30979

06/04/2021, 6:01 PM
Hi all, does anyone have an azure(-native) equivalent of this aws taggable resources list? https://github.com/joeduffy/aws-tags-example/blob/master/autotag-ts/taggable.ts
p

prehistoric-nail-50687

06/07/2021, 8:45 AM
I just check for the the prefix:
"azure-native:"
and did not have any issues so far.. something like this:
Copy code
/**
 * Registers a global stack transformation that merges a set
 * of tags with whatever was also explicitly added to the resource definition.
 *
 * The current implementation checks whether the type starts with "azure-native:",
 * if so it will blindly add the 'tags'.
 *
 * The basic idea was taken from <https://github.com/joeduffy/aws-tags-example/tree/master/autotag-ts>
 */
export function registerAutoTags(autoTags: Record<string, string>): void {
  pulumi.runtime.registerStackTransformation((args: pulumi.ResourceTransformationArgs) => {
    if (args.type.startsWith("azure-native:")) {
      args.props["tags"] = {
        ...args.props["tags"],
        ...autoTags,
      };
      return {
        props: args.props,
        opts: args.opts,
      };
    }
    return undefined;
  });
}
🙌 1
3 Views