damp-elephant-82829
08/31/2020, 10:04 AMgreen-school-95910
08/31/2020, 1:34 PMdamp-elephant-82829
08/31/2020, 2:16 PMgreen-school-95910
08/31/2020, 2:18 PMdamp-elephant-82829
08/31/2020, 2:19 PMlocation = "europe-west1"
project_name = f"myproj-dev-{branch_name}"
root_project = organizations.Project.get(
"root-project", id="myproj-qaroot"
)
organization = organizations.get_organization(organization=organization_name)
# Create an ephemeral project
project = organizations.Project(
"branch-project",
name=project_name,
project_id=project_name,
billing_account=root_project.billing_account,
org_id=organization.org_id,
)
root_project_topic_iam_binding = pubsub.TopicIAMMember(
resource_name="root-project-as-pubsub-admin",
topic=my_topic.id,
project=project.project_id,
role="roles/pubsub.admin",
member=[cloudbuild_service_accountname(root_project.number)],
)
root_project_iam_binding = projects.IAMMember(
resource_name="root-project-as-project-editor",
project=project.project_id,
role="roles/editor",
member=cloudbuild_service_accountname(root_project.number),
)
that didn’t work eithergreen-school-95910
08/31/2020, 2:34 PMgcp.Provider
for creating the project and the subscription (the default one) this should, in theory, work.damp-elephant-82829
08/31/2020, 2:38 PMgreen-school-95910
08/31/2020, 2:40 PMdamp-elephant-82829
08/31/2020, 2:46 PMgreen-school-95910
08/31/2020, 2:56 PMcloud-platform
but a combination of smaller scopes, but I'm not finding any documentation for itgcp.Provider
using this new account and try to create a subscription with it.damp-elephant-82829
08/31/2020, 3:00 PMgreen-school-95910
08/31/2020, 3:02 PMnew pubsub.Subscription("name", {...}, {provider: theProviderInstance})
pulumi.Subscription(
...
opts=pulumi.ResourceOptions(
provider=theProviderInstance,
),
)
damp-elephant-82829
08/31/2020, 3:05 PMgreen-school-95910
08/31/2020, 3:08 PMpulumi_gcp.Provider(
credentials=serviceAccountKey,
)
serviceAccountKey = keyResource.private_key.apply(base64.b64decode)
damp-elephant-82829
08/31/2020, 3:13 PMgreen-school-95910
08/31/2020, 3:14 PMdamp-elephant-82829
08/31/2020, 3:17 PMgreen-school-95910
08/31/2020, 4:39 PMdamp-elephant-82829
08/31/2020, 4:47 PMproject_owner_service_account = serviceAccount.Account(
resource_name="ephemeral_project_owner_service_account",
account_id="ephemeralprojectowner",
project=ephemeral_project.project_id,
)
project_owner_service_account_key = serviceAccount.Key(
resource_name="project_owner_service_account_key",
service_account_id=project_owner_service_account.unique_id
)
green-school-95910
08/31/2020, 4:57 PMproject
on serviceAccount.Key
or add a parent that has the project setdamp-elephant-82829
08/31/2020, 5:04 PMgreen-school-95910
08/31/2020, 5:07 PMservice_account_id=project_owner_service_account.unique_id
it should be service_account_id=project_owner_service_account.name
unique_id
is the id for Pulumidamp-elephant-82829
08/31/2020, 5:32 PM