Hey all - is anyone managing a GCP project via pul...
# google-cloud
e
Hey all - is anyone managing a GCP project via pulumi? I'm trying to enable GCP APIs and hitting a type error. I'm passing in a list of service APIs to enable but pulumi is interpreting the list as as a string. Example:
Copy code
project = gcp.projects.Service(PROJECT_NAME,
            disable_dependent_services=True,
            project=PROJECT_ID,
            service=["<http://compute.googleapis.com|compute.googleapis.com>", "<http://container.googleapis.com|container.googleapis.com>"])
out put:
Copy code
AssertionError: Unexpected type. Expected 'list' got '<class 'str'>'
g
Odd. If I remember correctly,
service
is a string in the GCP Classic API (defined in GCP Classic (Pulumi Registry) with the SDK code. Let me ask around and see if there's a better way than doing a single declaration for each service API.
e
awesome, thank you. i can pass in a string for
service
which works fine. but its odd that the error is stating that it is expecting a list but then throws an error expecting a string
g
Yeah, that error doesn't make much sense to me, either. I'd expect it to say the opposite. If you'd like to open an issue while I'm still rooting around, here's the repo: https://github.com/pulumi/pulumi-gcp/issues If not, I'll open one once I find the right spot to highlight in the code.
Quick question: Which version of Pulumi are you running? You can get that with
pulumi version
in the CLI.
e
i'm running
v3.21.0
g
perfect; thanks! Trying to get the right feedback to the right people
b
hey Brian, I think the error is wrong. I think the
service
property takes a string? https://www.pulumi.com/registry/packages/gcp/api-docs/projects/service/#service_python
g
Yep! It does; I just don't know how people define multiple service APIs. Do they make a call for each API, or is there a better way to do it with a single definition?
e
gotcha that makes sense.
b
the easiest way would be a loop, I think:
Copy code
services = ["<http://compute.googleapis.com|compute.googleapis.com>", "<http://container.googleapis.com|container.googleapis.com>"]
for i, service in enumerate(services):
            project = gcp.projects.Service(f"{project_name}-{i},
            disable_dependent_services=True,
            project=PROJECT_ID,
            service=service)
untested, please verify before you run it!
g
Thanks, @billowy-army-68599! Still going to look into the error message, though; it's backwards from expected Python errors. I'll drop a link when I've got more info
b
❤️
e
perfect. this was my thought for a work around but just wanted to check in. thanks y'all! ill give it a shot