I'm using pulumi automation to setup different gcp...
# google-cloud
b
I'm using pulumi automation to setup different gcp projects using the same infra code. I'm trying to setup the service account in runtime, but I didn't not find any example so far. Does anyone has this case or could appoint me a direction?
f
Hi, we creates service accounts with this code:
Copy code
import pulumi_gcp as gcp
service_account = gcp.serviceaccount.Account(
    resource_name,
    account_id=...,
    display_name=...,
)
It is also needed to set
project=<project_id>
if gcp:project is not set with
pulumi config set gcp:project <project_id>
There is also possible to not use default gcp provider and set the project id with:
Copy code
gcp_provider = gcp.Provider(
    resource_name="gcp-provider",
    project=<project_id>,
)
However then you have to pass the provider to Account resource directly:
Copy code
service_account = gcp.serviceaccount.Account(
    resource_name,
    account_id=...,
    display_name=...,
    opts=pulumi.ResourceOptions(provider=gcp_provider)
)
Hope it helps you :)