https://pulumi.com logo
#general
Title
# general
w

wonderful-dog-9045

05/12/2020, 4:14 PM
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

faint-table-42725

05/12/2020, 4:48 PM
Importing
@pulumi/pulumi
will initialize the pulumi runtime. Part of that is establishing the necessary setup for things like stack transformations.
w

wonderful-dog-9045

05/12/2020, 4:50 PM
hmm
thats strange.
i am accessing
registerStackTransformation
because I imported
runtime
from
@pulumi/pulumi
.
could it be a bug related to asynchronous resolutions?
s

swift-lunch-74411

05/12/2020, 5:13 PM
Is this working for the Azure too?
f

faint-table-42725

05/12/2020, 5:32 PM
Do you
import * as pulumi from @pulumi/pulumi
?
w

wonderful-dog-9045

05/12/2020, 6:03 PM
`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

faint-table-42725

05/13/2020, 5:26 PM
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

wonderful-dog-9045

05/14/2020, 7:59 AM
only one entry there. what if
pulumi up
loads its own, regardless of package-lock?
f

faint-table-42725

05/14/2020, 4:04 PM
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

wonderful-dog-9045

05/14/2020, 4:28 PM
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.