question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Python import of `service_account` fails / documenation wrong

See original GitHub issue

I am trying to create a Service Account on GCP with the pulumi python module according to the documentation. This fails with an import error

Following the example usage described in the documentation https://www.pulumi.com/docs/reference/pkg/gcp/serviceaccount/account/

import pulumi
import pulumi_gcp as gcp

service_account = gcp.service_account.Account("serviceAccount",
    account_id="service-account-id",
    display_name="Service Account")

results in this error:

  File "./__main__.py", line 24, in <module>
    service_account = gcp.service_account.Account(
AttributeError: module 'pulumi_gcp' has no attribute 'service_account'

I would expect this to properly create a service account

Versions: pulumi-gcp==5.3.0, pulumi version v3.2.1

Looking at the code https://github.com/pulumi/pulumi-gcp/blob/master/sdk/python/pulumi_gcp/__init__.py#L75 shows that underscores seem to be removed.

So the above code works when removing the underscore in the module as well. I am assuming this will fail for other modules as well.

I would propose to either fix the documentation or change the code to not remove the underscores

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:3
  • Comments:5

github_iconTop GitHub Comments

1reaction
noahdatasherpascommented, Oct 11, 2022

This still isn’t fixed… it’s been a year and a half since this issue was opened. All other threads point back to this one.

What would it take to make the change to the documentation? I’d be happy to make the change if someone can point me in the right direction. Seems like updating the documentation example should be a quick one liner?

0reactions
jdosscommented, Mar 23, 2022

~Can I make a PR for this fix? If so, where? I ran into this documentation snafu today.~

Nevermind found it 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Built-in Exceptions — Python 3.11.1 documentation
This exception is raised when a system function returns a system-related error, including I/O failures such as “file not found” or “disk full”...
Read more >
Resolve "Unable to import module" errors from Python ...
I receive an "Unable to import module" error when I try to run my AWS Lambda code in Python. How do I resolve...
Read more >
python - Why am I getting the fiollowing error when calling the ...
You're using from_service_account_file incorrectly. See the Service Account private key files from google.cloud import language_v1 from ...
Read more >
ModuleNotFoundError: no module named Python Error [Fixed]
you are importing a module using the wrong path. How to fix the ModuleNotFoundError in Python. As I mentioned in the previous section,...
Read more >
Setting Up Error Reporting for Python | Google Cloud
Use the Compute Engine default service account or another service account of your choice, and select Allow full access to all Cloud APIs...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found