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

bland-thailand-60821

09/15/2022, 10:14 PM
Copy code
import pulumi
import pulumi_equinix_metal as equinix_metal

test = equinix_metal.Connection("test",
    organization_id=local["my_organization_id"],
    project_id=local["my_project_id"],
    metro="sv",
    redundancy="redundant",
    type="shared")
__ERROR-----------------------
Diagnostics:
  pulumi:pulumi:Stack (mosk-auto-test):
    error: Program failed with an unhandled exception:
    Traceback (most recent call last):
      File "./__main__.py", line 4, in <module>
        test = equinix_metal.Connection("test",
    AttributeError: module 'pulumi_equinix_metal' has no attribute 'Connection'
s

stocky-father-68249

09/16/2022, 5:13 AM
Are you sure the function exists? Check that first then try out and then try using
from pulumi_equinix_metal import Connection
b

bland-thailand-60821

09/16/2022, 4:14 PM
Copy code
import pulumi
import pulumi_equinix_metal as equinix_metal
from pulumi_equinix_metal import Connection
test = equinix_metal.Connection("test",
    organization_id=local["my_organization_id"],
    project_id=local["my_project_id"],
    metro="sv",
    redundancy="redundant",
    type="shared")
----------
iagnostics:
  pulumi:pulumi:Stack (mosk-auto-test):
    error: Program failed with an unhandled exception:
    Traceback (most recent call last):
      File "./__main__.py", line 4, in <module>
        from pulumi_equinix_metal import Connection
    ImportError: cannot import name 'Connection' from 'pulumi_equinix_metal' (/Users/dsayyed/mosk-auto/venv/lib/python3.7/site-packages/pulumi_equinix_metal/__init__.py)
@stocky-father-68249 ^^ same error
s

stocky-father-68249

09/16/2022, 4:31 PM
That's not the same error. Can you give me the pull debug output?
b

bland-thailand-60821

09/16/2022, 4:32 PM
Copy code
source /Users/dsayyed/mosk-auto/venv/bin/activate
dsayyed@dsayyed-MBP16-1911 mosk-auto % source /Users/dsayyed/mosk-auto/venv/bin/activate
(venv) dsayyed@dsayyed-MBP16-1911 mosk-auto %  /usr/bin/env /Users/dsayyed/mosk-auto/venv/bin/
python /Users/dsayyed/.vscode/extensions/ms-python.python-2022.14.0/pythonFiles/lib/python/deb
ugpy/adapter/../../debugpy/launcher 64940 -- /Users/dsayyed/mosk-auto/__main__.py
Copy code
source /Users/dsayyed/mosk-auto/venv/bin/activate
dsayyed@dsayyed-MBP16-1911 mosk-auto % source /Users/dsayyed/mosk-auto/venv/bin/activate
(venv) dsayyed@dsayyed-MBP16-1911 mosk-auto %  /usr/bin/env /Users/dsayyed/mosk-auto/venv/bin/
python /Users/dsayyed/.vscode/extensions/ms-python.python-2022.14.0/pythonFiles/lib/python/deb
ugpy/adapter/../../debugpy/launcher 64940 -- /Users/dsayyed/mosk-auto/__main__.py 
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/Users/dsayyed/.vscode/extensions/ms-python.python-2022.14.0/pythonFiles/lib/python/debugpy/adapter/../../debugpy/launcher/../../debugpy/__main__.py", line 39, in <module>
    cli.main()
  File "/Users/dsayyed/.vscode/extensions/ms-python.python-2022.14.0/pythonFiles/lib/python/debugpy/adapter/../../debugpy/launcher/../../debugpy/../debugpy/server/cli.py", line 430, in main
    run()
  File "/Users/dsayyed/.vscode/extensions/ms-python.python-2022.14.0/pythonFiles/lib/python/debugpy/adapter/../../debugpy/launcher/../../debugpy/../debugpy/server/cli.py", line 284, in run_file
    runpy.run_path(target, run_name="__main__")
  File "/Users/dsayyed/.vscode/extensions/ms-python.python-2022.14.0/pythonFiles/lib/python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 322, in run_path
    pkg_name=pkg_name, script_name=fname)
  File "/Users/dsayyed/.vscode/extensions/ms-python.python-2022.14.0/pythonFiles/lib/python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 136, in _run_module_code
    mod_name, mod_spec, pkg_name, script_name)
  File "/Users/dsayyed/.vscode/extensions/ms-python.python-2022.14.0/pythonFiles/lib/python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 124, in _run_code
    exec(code, run_globals)
  File "/Users/dsayyed/mosk-auto/__main__.py", line 4, in <module>
    from pulumi_equinix_metal import Connection
ImportError: cannot import name 'Connection' from 'pulumi_equinix_metal' (/Users/dsayyed/mosk-auto/venv/lib/python3.7/site-packages/pulumi_equinix_metal/__init__.py)
s

stocky-father-68249

09/16/2022, 4:35 PM
Try going to the source maybe?
b

bland-thailand-60821

09/16/2022, 4:35 PM
how to do that ?
How to fix it ?
Above doc doesn’t mentioned any ?
s

stocky-father-68249

09/16/2022, 6:50 PM
Take a look at init.py
b

bland-thailand-60821

09/20/2022, 4:10 PM
Copy code
dsayyed@dsayyed-MBP16-1911 mosk-auto % cat  /Users/dsayyed/mosk-auto/venv/lib/python3.7/site-packages/pulumi_equinix_metal/__init__.py
# coding=utf-8
# *** WARNING: this file was generated by the Pulumi Terraform Bridge (tfgen) Tool. ***
# *** Do not edit by hand unless you're certain you know what you are doing! ***

# Export this package's modules as members:
from ._enums import *
from .bgp_session import *
from .device import *
from .device_network_type import *
from .get_connection import *
from .get_device import *
from .get_device_bgp_neighbors import *
from .get_facility import *
from .get_ip_block_ranges import *
from .get_metro import *
from .get_operating_system import *
from .get_organization import *
from .get_precreated_ip_block import *
from .get_project import *
from .get_project_ssh_key import *
from .get_spot_market_price import *
from .get_spot_market_request import *
from .get_virtual_circuit import *
from .get_volume import *
from .ip_attachment import *
from .organization import *
from .port_vlan_attachment import *
from .project import *
from .project_ssh_key import *
from .provider import *
from .reserved_ip_block import *
from .spot_market_request import *
from .ssh_key import *
from .vlan import *
from .volume import *
from .volume_attachment import *
from ._inputs import *
from . import outputs

# Make subpackages available:
from . import (
    config,
)

def _register_module():
    import pulumi
    from . import _utilities


    class Module(pulumi.runtime.ResourceModule):
        _version = _utilities.get_semver_version()

        def version(self):
            return Module._version

        def construct(self, name: str, typ: str, urn: str) -> pulumi.Resource:
            if typ == "equinix-metal:index/bgpSession:BgpSession":
                return BgpSession(name, pulumi.ResourceOptions(urn=urn))
            elif typ == "equinix-metal:index/device:Device":
                return Device(name, pulumi.ResourceOptions(urn=urn))
            elif typ == "equinix-metal:index/deviceNetworkType:DeviceNetworkType":
                return DeviceNetworkType(name, pulumi.ResourceOptions(urn=urn))
            elif typ == "equinix-metal:index/ipAttachment:IpAttachment":
                return IpAttachment(name, pulumi.ResourceOptions(urn=urn))
            elif typ == "equinix-metal:index/organization:Organization":
                return Organization(name, pulumi.ResourceOptions(urn=urn))
            elif typ == "equinix-metal:index/portVlanAttachment:PortVlanAttachment":
                return PortVlanAttachment(name, pulumi.ResourceOptions(urn=urn))
            elif typ == "equinix-metal:index/project:Project":
                return Project(name, pulumi.ResourceOptions(urn=urn))
            elif typ == "equinix-metal:index/projectSshKey:ProjectSshKey":
                return ProjectSshKey(name, pulumi.ResourceOptions(urn=urn))
            elif typ == "equinix-metal:index/reservedIpBlock:ReservedIpBlock":
                return ReservedIpBlock(name, pulumi.ResourceOptions(urn=urn))
            elif typ == "equinix-metal:index/spotMarketRequest:SpotMarketRequest":
                return SpotMarketRequest(name, pulumi.ResourceOptions(urn=urn))
            elif typ == "equinix-metal:index/sshKey:SshKey":
                return SshKey(name, pulumi.ResourceOptions(urn=urn))
            elif typ == "equinix-metal:index/vlan:Vlan":
                return Vlan(name, pulumi.ResourceOptions(urn=urn))
            elif typ == "equinix-metal:index/volume:Volume":
                return Volume(name, pulumi.ResourceOptions(urn=urn))
            elif typ == "equinix-metal:index/volumeAttachment:VolumeAttachment":
                return VolumeAttachment(name, pulumi.ResourceOptions(urn=urn))
            else:
                raise Exception(f"unknown resource type {typ}")


    _module_instance = Module()
    pulumi.runtime.register_resource_module("equinix-metal", "index/bgpSession", _module_instance)
    pulumi.runtime.register_resource_module("equinix-metal", "index/device", _module_instance)
    pulumi.runtime.register_resource_module("equinix-metal", "index/deviceNetworkType", _module_instance)
    pulumi.runtime.register_resource_module("equinix-metal", "index/ipAttachment", _module_instance)
    pulumi.runtime.register_resource_module("equinix-metal", "index/organization", _module_instance)
    pulumi.runtime.register_resource_module("equinix-metal", "index/portVlanAttachment", _module_instance)
    pulumi.runtime.register_resource_module("equinix-metal", "index/project", _module_instance)
    pulumi.runtime.register_resource_module("equinix-metal", "index/projectSshKey", _module_instance)
    pulumi.runtime.register_resource_module("equinix-metal", "index/reservedIpBlock", _module_instance)
    pulumi.runtime.register_resource_module("equinix-metal", "index/spotMarketRequest", _module_instance)
    pulumi.runtime.register_resource_module("equinix-metal", "index/sshKey", _module_instance)
    pulumi.runtime.register_resource_module("equinix-metal", "index/vlan", _module_instance)
    pulumi.runtime.register_resource_module("equinix-metal", "index/volume", _module_instance)
    pulumi.runtime.register_resource_module("equinix-metal", "index/volumeAttachment", _module_instance)


    class Package(pulumi.runtime.ResourcePackage):
        _version = _utilities.get_semver_version()

        def version(self):
            return Package._version

        def construct_provider(self, name: str, typ: str, urn: str) -> pulumi.ProviderResource:
            if typ != "pulumi:providers:equinix-metal":
                raise Exception(f"unknown provider type {typ}")
            return Provider(name, pulumi.ResourceOptions(urn=urn))


    pulumi.runtime.register_resource_package("equinix-metal", Package())

_register_module()
4 Views