I am trying to apply tags automatically as describ...
# general
w
I am trying to apply tags automatically as described here: https://www.pulumi.com/blog/automatically-enforcing-aws-resource-tagging-policies/#automatically-applying-tags However i get the following error:
Copy code
Error: The root stack resource was referenced before it was initialized.
        at Object.registerStackTransformation (/home/gsuess/empirica/meteor-deploy/node_modules/@pulumi/pulumi/runtime/stack.js:211:15)
What am I doing wrong?
What initialises it, or how do I initialise it?
f
Importing
@pulumi/pulumi
will initialize the pulumi runtime. Part of that is establishing the necessary setup for things like stack transformations.
w
hmm
thats strange.
i am accessing
registerStackTransformation
because I imported
runtime
from
@pulumi/pulumi
.
could it be a bug related to asynchronous resolutions?
s
Is this working for the Azure too?
f
Do you
import * as pulumi from @pulumi/pulumi
?
w
`import { runtime } from @pulumi/pulumi`;
@swift-lunch-74411. Don't know, don't have an azure account.
maybe two different package versions of pulumi?
I've added
throw new Error("init abort");
here https://github.com/pulumi/pulumi/blob/master/sdk/nodejs/runtime/stack.ts#L71. Looks like I can do a whole
pulumi up
(without autotags), and
initialize
never runs. very strange
Are you sure that importing
@pulumi/pulumi
has the side-effect of invoking the initialisation? I cannot find it in the code where this is happening.
starting to think that it's the pulumi runtime that invokes it instead.
My hypothesis is that the pulumi runtime that is invoked with
pulumi up
invokes the initialisation and somehow ends up with a different copy of the
@pulumi/pulumi
package, which would explain why the initialisation of the package that I am interacting with never gets invoked.
f
Bringing in
@pulumi/pulumi
will also bring in the runtime. It’s entirely possible you somehow have two copies of
@pulumi/pulumi
depending on how your dependencies are setup. You can easily verify this via your
package-lock.json
or
yarn.lock
w
only one entry there. what if
pulumi up
loads its own, regardless of package-lock?
f
It doesn’t as the CLI doesn’t actually bring the SDK with itself
If you’re willing to share your code, that’s probably easiest at this point to try to see what’s going on
w
Entrypoint is here: https://github.com/empiricaly/meteor-deploy/blob/master/src/stacks/aws-ecs-ec2/index.ts#L29 Configuring auto-tags is the first thing that happens.
thanks for looking into it, let me know if there is any else I can clarify about the code or the project.
i just tried to revisit it
still can't figure it out
Would like to make first release on this
and this fix it.