I’m trying to understand if I’m doing something wr...
# getting-started
i
I’m trying to understand if I’m doing something wrong or right in my code organization. I have a place in my code i’m creating an AWS Route Table. At that place in my code, I do a ctx.Export(“route_table_id”, rt.ID()) Later in a different function, I want to access this previously exported route table ID — so I started with using NewStackReference()… but it seems to fail an internal error / traceback when I try to use that ID. Is there a better way to “import” a resource that may be in the “current” stack?
Copy code
panic: fatal: An assertion has failed

goroutine 169 [running]:
<http://github.com/pulumi/pulumi/sdk/v3/go/common/util/contract.failfast(...)|github.com/pulumi/pulumi/sdk/v3/go/common/util/contract.failfast(...)>
	/private/tmp/pulumi-20210422-70582-1bpvlru/sdk/go/common/util/contract/failfast.go:23
<http://github.com/pulumi/pulumi/sdk/v3/go/common/util/contract.Assert(...)|github.com/pulumi/pulumi/sdk/v3/go/common/util/contract.Assert(...)>
	/private/tmp/pulumi-20210422-70582-1bpvlru/sdk/go/common/util/contract/assert.go:26
<http://github.com/pulumi/pulumi/sdk/v3/go/common/resource/plugin.(*provider).Read|github.com/pulumi/pulumi/sdk/v3/go/common/resource/plugin.(*provider).Read>(0xc000f0f920, 0xc00159eb40, 0x5b, 0x0, 0x0, 0x0, 0xc00050aea0, 0x4a7cc0d, 0x4, 0x0, ...)
	/private/tmp/pulumi-20210422-70582-1bpvlru/sdk/go/common/resource/plugin/provider_plugin.go:784 +0x1025
<http://github.com/pulumi/pulumi/pkg/v3/resource/deploy.(*ReadStep).Apply(0xc00050af60|github.com/pulumi/pulumi/pkg/v3/resource/deploy.(*ReadStep).Apply(0xc00050af60>, 0x1, 0x596f0d8, 0x23, 0xc0016bbe30, 0x3)
	/private/tmp/pulumi-20210422-70582-1bpvlru/pkg/resource/deploy/step.go:620 +0x103
<http://github.com/pulumi/pulumi/pkg/v3/resource/deploy.(*stepExecutor).executeStep(0xc00072b700|github.com/pulumi/pulumi/pkg/v3/resource/deploy.(*stepExecutor).executeStep(0xc00072b700>, 0x15, 0x5cda780, 0xc00050af60, 0x0, 0x100000005cca5a0)
	/private/tmp/pulumi-20210422-70582-1bpvlru/pkg/resource/deploy/step_executor.go:271 +0x209
<http://github.com/pulumi/pulumi/pkg/v3/resource/deploy.(*stepExecutor).executeChain(0xc00072b700|github.com/pulumi/pulumi/pkg/v3/resource/deploy.(*stepExecutor).executeChain(0xc00072b700>, 0x15, 0xc000622c20, 0x1, 0x1)
	/private/tmp/pulumi-20210422-70582-1bpvlru/pkg/resource/deploy/step_executor.go:221 +0xef
<http://github.com/pulumi/pulumi/pkg/v3/resource/deploy.(*stepExecutor).worker.func1(0xc00072b700|github.com/pulumi/pulumi/pkg/v3/resource/deploy.(*stepExecutor).worker.func1(0xc00072b700>, 0x15, 0xc000622c20, 0x1, 0x1, 0xc00159eba0)
	/private/tmp/pulumi-20210422-70582-1bpvlru/pkg/resource/deploy/step_executor.go:377 +0xc5
created by <http://github.com/pulumi/pulumi/pkg/v3/resource/deploy.(*stepExecutor).worker|github.com/pulumi/pulumi/pkg/v3/resource/deploy.(*stepExecutor).worker>
	/private/tmp/pulumi-20210422-70582-1bpvlru/pkg/resource/deploy/step_executor.go:374 +0x2c8
b
I just had this exact stack trace, and in my case the issue was that I was referring to a non-existing terraform remote state. I don't know if this is your case but one thing's for sure, this stack trace did not help me at all.
s
from my experience with python version of the tool
export doesn't mean you can use it anywhere you want
exported values can be accessed at the end, only at the end, after everything is done
if you need to pass a value from one operation to another, there are more complex steps to track
and we found them in from the examples in tutorial in python case, there wasn't a clear documentation
g
Paul, what we do is create a state object that stores shared resources, and we pass that state object into different functions/modules. In other words, we don't use any Pulumi tooling for this, we just use features of the programming language.
c
Can you open a git issue for
panic: fatal: An assertion has failed
You should not be getting that type of an error.