quaint-portugal-34880
05/25/2020, 6:35 PMerror: Running program '/PATH/aws/eks/network/pulumi' failed with an unhandled exception:
Error: The root stack resource was referenced before it was initialized.
at Object.registerStackTransformation (/PATH//pulumi/adfenix_generic/node_modules/@pulumi/pulumi/runtime/stack.js:211:15)
at AdfenixGeneric.registerAutoTags (/Users/ulfmansson/RubymineProjects/infra/lib/pulumi/adfenix_generic/index.ts:86:24)
at Object.<anonymous> (/PATH/aws/eks/network/pulumi/index.ts:14:17)
The code in the module looks like this
import * as pulumi from "@pulumi/pulumi";
export function registerAutoTags(autoTags: Record<string, string>): void {
pulumi.runtime.registerStackTransformation((args) => {
if (AdfenixGeneric.isTaggable(args.type)) {
args.props["tags"] = {...args.props["tags"], ...autoTags};
return {props: args.props, opts: args.opts};
}
return undefined;
});
}
My code:
import {registerAutoTags} from "@mymodule/tags"
registerAutoTags({
"environment": environment
});
little-cartoon-10569
05/25/2020, 8:57 PMpulumi.runtime.stack.runInPulumiStack()
. Though I can't remember if that was for the same error message...pulumi.runtime
from my "main" module around, into all the other modules that needed it, but that was ick.pulumi.runtime.registerStackTransformation(mymodule.autotags({ "environment": environment}))
. That was less icky, but still not ideal.quaint-portugal-34880
05/26/2020, 8:05 AMlittle-cartoon-10569
05/27/2020, 8:14 PMexport function autoTagger(autoTags: any): ResourceTransformation {
return function (args: ResourceTransformationArgs) {
if (isTaggable(args.type)) {
args.props.tags = {
// Order is important. Later items override earlier items
// if the key conflicts. So the "Name" is a default that can
// be overwritten either by the parameters to `autoTagger`,
// or by an explicitly-set Name tag in `args.props["tags"]`.
Name: `${args.name}`, ...autoTags, ...args.props.tags,
};
return { props: args.props, opts: args.opts };
}
return undefined;
}
}
import { ResourceTransformation, ResourceTransformationArgs } from "@pulumi/pulumi";
but of course you could just use pulumi.ResourceTransformation
etc..