https://pulumi.com logo
#python
Title
# python
d

damp-elephant-82829

09/02/2020, 7:49 PM
Copy code
Step #9 - "Pulumi Create Stack":     error: Program failed with an unhandled exception:
Step #9 - "Pulumi Create Stack":     error: Traceback (most recent call last):
Step #9 - "Pulumi Create Stack":       File "/pulumi/pulumi-language-python-exec", line 85, in <module>
Step #9 - "Pulumi Create Stack":         loop.run_until_complete(coro)
Step #9 - "Pulumi Create Stack":       File "/usr/local/lib/python3.7/asyncio/base_events.py", line 587, in run_until_complete
Step #9 - "Pulumi Create Stack":         return future.result()
Step #9 - "Pulumi Create Stack":       File "/usr/local/lib/python3.7/site-packages/pulumi/runtime/stack.py", line 83, in run_in_stack
Step #9 - "Pulumi Create Stack":         await run_pulumi_func(lambda: Stack(func))
Step #9 - "Pulumi Create Stack":       File "/usr/local/lib/python3.7/site-packages/pulumi/runtime/stack.py", line 51, in run_pulumi_func
Step #9 - "Pulumi Create Stack":         await RPC_MANAGER.rpcs.pop()
Step #9 - "Pulumi Create Stack":       File "/usr/local/lib/python3.7/site-packages/pulumi/runtime/stack.py", line 35, in run_pulumi_func
Step #9 - "Pulumi Create Stack":         func()
Step #9 - "Pulumi Create Stack":       File "/usr/local/lib/python3.7/site-packages/pulumi/runtime/stack.py", line 83, in <lambda>
Step #9 - "Pulumi Create Stack":         await run_pulumi_func(lambda: Stack(func))
Step #9 - "Pulumi Create Stack":       File "/usr/local/lib/python3.7/site-packages/pulumi/runtime/stack.py", line 106, in __init__
Step #9 - "Pulumi Create Stack":         func()
Step #9 - "Pulumi Create Stack":       File "/pulumi/pulumi-language-python-exec", line 84, in <lambda>
Step #9 - "Pulumi Create Stack":         coro = pulumi.runtime.run_in_stack(lambda: runpy.run_path(args.PROGRAM, run_name='__main__'))
Step #9 - "Pulumi Create Stack":       File "/usr/local/lib/python3.7/runpy.py", line 280, in run_path
Step #9 - "Pulumi Create Stack":         run_name, mod_spec, pkg_name).copy()
Step #9 - "Pulumi Create Stack":       File "/usr/local/lib/python3.7/runpy.py", line 85, in _run_code
Step #9 - "Pulumi Create Stack":         exec(code, run_globals)
Step #9 - "Pulumi Create Stack":       File "./__main__.py", line 56, in <module>
Step #9 - "Pulumi Create Stack":         organization_name=organization,
Step #9 - "Pulumi Create Stack":       File "./ephemeral_project.py", line 37, in __init__
Step #9 - "Pulumi Create Stack":         organization=args.organization_name
Step #9 - "Pulumi Create Stack":       File "/usr/local/lib/python3.7/site-packages/pulumi_gcp/organizations/get_organization.py", line 101, in get_organization
Step #9 - "Pulumi Create Stack":         __ret__ = pulumi.runtime.invoke('gcp:organizations/getOrganization:getOrganization', __args__, opts=opts).value
Step #9 - "Pulumi Create Stack":       File "/usr/local/lib/python3.7/site-packages/pulumi/runtime/invoke.py", line 133, in invoke
Step #9 - "Pulumi Create Stack":         return InvokeResult(_sync_await(asyncio.ensure_future(do_rpc())))
Step #9 - "Pulumi Create Stack":       File "/usr/local/lib/python3.7/site-packages/pulumi/runtime/sync_await.py", line 95, in _sync_await
Step #9 - "Pulumi Create Stack":         return fut.result()
Step #9 - "Pulumi Create Stack":       File "/usr/local/lib/python3.7/site-packages/pulumi/runtime/invoke.py", line 130, in do_rpc
Step #9 - "Pulumi Create Stack":         raise exn
Step #9 - "Pulumi Create Stack":       File "/usr/local/lib/python3.7/site-packages/pulumi/runtime/rpc_manager.py", line 67, in rpc_wrapper
Step #9 - "Pulumi Create Stack":         result = await rpc
Step #9 - "Pulumi Create Stack":       File "/usr/local/lib/python3.7/site-packages/pulumi/runtime/invoke.py", line 90, in do_invoke
Step #9 - "Pulumi Create Stack":         inputs = await rpc.serialize_properties(props, {})
Step #9 - "Pulumi Create Stack":       File "/usr/local/lib/python3.7/site-packages/pulumi/runtime/rpc.py", line 71, in serialize_properties
Step #9 - "Pulumi Create Stack":         result = await serialize_property(v, deps, input_transformer)
Step #9 - "Pulumi Create Stack":       File "/usr/local/lib/python3.7/site-packages/pulumi/runtime/rpc.py", line 163, in serialize_property
Step #9 - "Pulumi Create Stack":         return await serialize_property(future_return, deps, input_transformer)
Step #9 - "Pulumi Create Stack":       File "/usr/local/lib/python3.7/site-packages/pulumi/runtime/rpc.py", line 210, in serialize_property
Step #9 - "Pulumi Create Stack":         raise ValueError(f"unexpected input of type {type(value).__name__}")
Step #9 - "Pulumi Create Stack":     ValueError: unexpected input of type GetOrganizationResult
Step #9 - "Pulumi Create Stack":     error: an unhandled error occurred: Program exited with non-zero exit code: 1
Step #9 - "Pulumi Create Stack":  
Step #9 - "Pulumi Create Stack":     exception calling callback for <Future at 0x7f58bd80f510 state=finished returned ReadResourceResponse>
Step #9 - "Pulumi Create Stack":     Traceback (most recent call last):
Step #9 - "Pulumi Create Stack":       File "/usr/local/lib/python3.7/concurrent/futures/_base.py", line 324, in _invoke_callbacks
Step #9 - "Pulumi Create Stack":         callback(self)
Step #9 - "Pulumi Create Stack":       File "/usr/local/lib/python3.7/asyncio/futures.py", line 365, in _call_set_state
Step #9 - "Pulumi Create Stack":         dest_loop.call_soon_threadsafe(_set_state, destination, source)
Step #9 - "Pulumi Create Stack":       File "/usr/local/lib/python3.7/asyncio/base_events.py", line 736, in call_soon_threadsafe
Step #9 - "Pulumi Create Stack":         self._check_closed()
Step #9 - "Pulumi Create Stack":       File "/usr/local/lib/python3.7/asyncio/base_events.py", line 479, in _check_closed
Step #9 - "Pulumi Create Stack":         raise RuntimeError('Event loop is closed')
Step #9 - "Pulumi Create Stack":     RuntimeError: Event loop is closed
m

microscopic-pilot-97530

09/02/2020, 8:49 PM
Copy code
Step #9 - "Pulumi Create Stack":       File "./__main__.py", line 56, in <module>
Step #9 - "Pulumi Create Stack":         organization_name=organization,
You’re setting
organization_name
to
organization
on line 56 of your
__main__.py
. Is
organization
a
str
?
d

damp-elephant-82829

09/03/2020, 7:23 AM
thanks, there was something that was left from copy paste
now there is an additional failure, which is more surprising
Copy code
Step #9 - "Pulumi Create Stack":     error: Program failed with an unhandled exception:
Step #9 - "Pulumi Create Stack":     error: Traceback (most recent call last):
Step #9 - "Pulumi Create Stack":       File "/pulumi/pulumi-language-python-exec", line 85, in <module>
Step #9 - "Pulumi Create Stack":         loop.run_until_complete(coro)
Step #9 - "Pulumi Create Stack":       File "/usr/local/lib/python3.7/asyncio/base_events.py", line 587, in run_until_complete
Step #9 - "Pulumi Create Stack":         return future.result()
Step #9 - "Pulumi Create Stack":       File "/usr/local/lib/python3.7/site-packages/pulumi/runtime/stack.py", line 83, in run_in_stack
Step #9 - "Pulumi Create Stack":         await run_pulumi_func(lambda: Stack(func))
Step #9 - "Pulumi Create Stack":       File "/usr/local/lib/python3.7/site-packages/pulumi/runtime/stack.py", line 35, in run_pulumi_func
Step #9 - "Pulumi Create Stack":         func()
Step #9 - "Pulumi Create Stack":       File "/usr/local/lib/python3.7/site-packages/pulumi/runtime/stack.py", line 83, in <lambda>
Step #9 - "Pulumi Create Stack":         await run_pulumi_func(lambda: Stack(func))
Step #9 - "Pulumi Create Stack":       File "/usr/local/lib/python3.7/site-packages/pulumi/runtime/stack.py", line 106, in __init__
Step #9 - "Pulumi Create Stack":         func()
Step #9 - "Pulumi Create Stack":       File "/pulumi/pulumi-language-python-exec", line 84, in <lambda>
Step #9 - "Pulumi Create Stack":         coro = pulumi.runtime.run_in_stack(lambda: runpy.run_path(args.PROGRAM, run_name='__main__'))
Step #9 - "Pulumi Create Stack":       File "/usr/local/lib/python3.7/runpy.py", line 280, in run_path
Step #9 - "Pulumi Create Stack":         run_name, mod_spec, pkg_name).copy()
Step #9 - "Pulumi Create Stack":       File "/usr/local/lib/python3.7/runpy.py", line 85, in _run_code
Step #9 - "Pulumi Create Stack":         exec(code, run_globals)
Step #9 - "Pulumi Create Stack":       File "./__main__.py", line 55, in <module>
Step #9 - "Pulumi Create Stack":         project=ephemeral_project.new_project_id,
Step #9 - "Pulumi Create Stack":     AttributeError: 'Project' object has no attribute 'new_project_id'
Step #9 - "Pulumi Create Stack":     error: an unhandled error occurred: Program exited with non-zero exit code: 1
As you see from the code @microscopic-pilot-97530 there is the output in the component and it is even registered
@green-school-95910 or @gentle-diamond-70147 might now what might be going on with the output?
Copy code
Step #9 - "Pulumi Create Stack":     AttributeError: 'Project' object has no attribute 'new_project_id'
g

green-school-95910

09/03/2020, 7:58 PM
Indeed it seems like it should be
ehemeral_project.project_id
not
.new_project_id
Oh,
new_project_id
is the Output of you
Project
component
d

damp-elephant-82829

09/03/2020, 8:01 PM
right
is my last statement self.register_output breaking something?
g

green-school-95910

09/03/2020, 8:05 PM
You need to assign it to the instance variable and call
register_outputs
Copy code
self.new_project_id = ephemeral_project.project_id
self.register_outputs({"new_project_id": ephemeral_project.project_id})
d

damp-elephant-82829

09/03/2020, 8:07 PM
make sense, what does registering do? it makes it available for export?
g

green-school-95910

09/03/2020, 8:07 PM
The first allows you to reference the graph on your code, normal Python code The second is to effectively add them to the correct place on Pulumi resource graph
It could have been done differently on Pulumi side to make that line disappear, but maybe it just wasn't worth it...
Like, with a metaclass intercepting the attribute assignments and resource creation on the runtime to add their registration to the event queue automatically...
Yeah, not worth it. Would be hell to maintain
d

damp-elephant-82829

09/03/2020, 8:14 PM
thanks that was it