Hey folks! :wave: I’m trying to create a GCP proj...
# google-cloud
f
Hey folks! 👋 I’m trying to create a GCP project via Pulumi and set it to use an existing billing account that we have. However, I see nowhere in the Project type where we could specify the billing account. And if it’s not specified, then many Google services fail to activate, because they require a billing account. In Terraform, we were doing this at project level:
Copy code
resource "google_project" "my_project" {
  name            = "my_project"
  project_id      = "my_project_123456"
  billing_account = "01913E-D7CA1E-9371A0"
  org_id          = "my_org"
}
What am I missing here? 🤔
p
let me take a look at our repo but I guess you must have missed an obvious property
oh, you’re using google native version (I’m still using “the old one”)
Just in case, that’s the working version for the old provider (package is called
pulumi-gcp
in python):
Copy code
import pulumi_gcp as gcp

project = gcp.organizations.Project(
    "project",
    name=config.project_name,
    project_id=config.project_id,
    billing_account=config.billing_account,
    auto_create_network=False,
    folder_id=config.folder_id,
)
Hah, it really looks like it’s missing the property. Anyway, looking at v1 I’ve found:
You can set or update the billing account associated with a project using the [
projects.updateBillingInfo
] (/billing/reference/rest/v1/projects/updateBillingInfo) method.
SRC: https://www.pulumi.com/docs/reference/pkg/google-native/cloudresourcemanager/v1/project/#project
Did you try that?
f
Hey @prehistoric-activity-61023! 👋 Sorry for the delay and thanks for your answer! Indeed, I see we have to use the “classic” provider for project creation. What’s good is that we can mix and match “classic” and “native” together, however the experience is not seamless. For example, the “classic” provider output a
project.id
in the form of
projects/123456
, whereas the “native” one expects just
12345
as project ID, so I need to dynamically strip the
projects/
prefix before passing it to the other native resources. That was annoying to troubleshoot initially, but now that it’s figured out, it works like a charm! 😉
p
@future-nail-59564 I’m glad you managed to make it work 🙂! Regarding the stripping part, check for additional fields other than
id
. I think you can use
project.project_id
.
f
Hmm… not sure… when I look at this resource for example: https://www.pulumi.com/docs/reference/pkg/google-native/cloudresourcemanager/v3/folder/ Both the
id
and
name
outputs seem to have the same format (ie:
folders/1234
) and I see no other property… 😕
So I ended up creating helpers to strip or add prefixes