https://pulumi.com logo
#google-cloud
Title
# google-cloud
e

eager-room-52651

01/06/2022, 2:28 PM
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

great-queen-39697

01/06/2022, 3:12 PM
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

eager-room-52651

01/06/2022, 3:14 PM
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

great-queen-39697

01/06/2022, 3:24 PM
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

eager-room-52651

01/06/2022, 3:40 PM
i'm running
v3.21.0
g

great-queen-39697

01/06/2022, 3:56 PM
perfect; thanks! Trying to get the right feedback to the right people
b

billowy-army-68599

01/06/2022, 4:05 PM
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

great-queen-39697

01/06/2022, 4:06 PM
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

eager-room-52651

01/06/2022, 4:07 PM
gotcha that makes sense.
b

billowy-army-68599

01/06/2022, 4:10 PM
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

great-queen-39697

01/06/2022, 4:15 PM
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

billowy-army-68599

01/06/2022, 4:16 PM
❤️
e

eager-room-52651

01/06/2022, 4:20 PM
perfect. this was my thought for a work around but just wanted to check in. thanks y'all! ill give it a shot