is this possible to do with Pulumi. if yes, can so...
# general
m
is this possible to do with Pulumi. if yes, can someone please give me some example.
a
This is a great use case for stacks! There's a tutorial on this here https://www.pulumi.com/learn/building-with-pulumi/stack-outputs/
m
thank you @agreeable-eye-87399.
i have another question. I am creating a new GCP Project and I want the stack name to be append to the actual project name.
Example - if my stack is stage, then the new GCP project should be airflow-stage and likewise in prod it should be airflow-prod
how can i achieve this
any help will be highly appreciated!!!
we are trying to move from terraform to pulumi and i am trying to understand pulumi, whether what I was able to do in terraform is it possible to do with pulumi
a
You want to use stack references there (you can get the current stack name programmatically and then add that to the name when creating the gcp project) https://www.pulumi.com/learn/building-with-pulumi/stack-references/
m
thanks so much.
I might have more questions. Please let me know, if it is ok to post it here.
a
please do!
m
1. Created a new GCP Project
Copy code
bureau_data_project = gcp.organizations.Project(project_name,

     org_id="99999999",

  project_id=project_name)
2. Creating a new service account for this Project bureau_data_project = gcp.organizations.Project(project_name,    org_id="99999999",  project_id=project_name)
3. setting up the IAMBinding project = gcp.projects.IAMBinding(project_name, members =[], project=project_name, role="roles/editor")
My question on the step 3 -
1. how do I access the service account created in Step 2 here.
2. In google_project_iam_binding, why can't I assign roles/bigquery.dataviewer.
i should be able to do something like this - service_account.email
but how do i string concatenation here
example - "serviceAccount:" + service_account.email
r
pulumi.Output.concat("serviceAccount:", service_account.email)
https://www.pulumi.com/docs/intro/concepts/inputs-outputs/#outputs-and-strings
m
thanks so much.
why does it complains that "project - required field is not set" in gcp.bigquery.DatasetIamBinding.
Here is what i have -
Copy code
reader = gcp.bigquery.DatasetIamBinding("reader", dataset_id = dataset.dataset_id, roles="roles/bigquery.dataviewer", members = ['users:"ssss]
r
Looks like you need to either have the project set on the gcp provider or in the resource: https://www.pulumi.com/registry/packages/gcp/api-docs/bigquery/datasetiambinding/#project_python
pulumi config set gcp:project [your_project_id]
m
where do I set this. can I set it up in the pulumi.yaml file
r
m
but I am creating a brand new project using pulumi.
First i am creating a new GCP project, then service account, then Big query access
r
Then pass the project ID to the
DatasetIamBinding
Copy code
reader = gcp.bigquery.DatasetIamBinding("reader", project=project.id, dataset_id = dataset.dataset_id, ...)
m
@agreeable-eye-87399 - sorry to bug you. i ran into few issues yesterday.
Copy code
error: deleting urn:pulumi:stage::ek-data-source::gcp:projects/service:Service::project: 1 error occurred:
	* Error when reading or editing Project Service ek-data-source-stage/bigquery.googleapis.com: Error disabling service "<http://bigquery.googleapis.com|bigquery.googleapis.com>" for project "ek-data-source-stage": googleapi: Error 400: The service <http://bigquery.googleapis.com|bigquery.googleapis.com> is depended on by the following active service(s): <http://bigquerystorage.googleapis.com|bigquerystorage.googleapis.com>; Please specify disable_dependent_services=true if you want to proceed with disabling all services.
Help Token: Ae-hA1P5o6go9HANTZgPEqnXwbDS4C9MI-KVWMAlNhh9dGSJp2l95ver_wdySZRAaAGxDnKXomqspnmQDKXcEojtPgi9MMduRwg5b6zGEy23CkXa
Details:
[
  {
    "@type": "<http://type.googleapis.com/google.rpc.PreconditionFailure|type.googleapis.com/google.rpc.PreconditionFailure>",
    "violations": [
      {
        "subject": "?error_code=100001\u0026service_name=<http://bigquery.googleapis.com|bigquery.googleapis.com>\u0026services=<http://bigquerystorage.googleapis.com|bigquerystorage.googleapis.com>",
        "type": "<http://googleapis.com|googleapis.com>"
      }
    ]
  },
  {
    "@type": "<http://type.googleapis.com/google.rpc.ErrorInfo|type.googleapis.com/google.rpc.ErrorInfo>",
    "domain": "<http://serviceusage.googleapis.com|serviceusage.googleapis.com>",
    "metadata": {
      "service_name": "<http://bigquery.googleapis.com|bigquery.googleapis.com>",
      "services": "<http://bigquerystorage.googleapis.com|bigquerystorage.googleapis.com>"
    },
    "reason": "COMMON_SU_SERVICE_HAS_DEPENDENT_SERVICES"
  }
]
, failedPrecondition
Copy code
Enable Google Biquery api
project = gcp.projects.Service("project",
  project=bureau_data_project.id,
  service="<http://bigquery.googleapis.com|bigquery.googleapis.com>")
Copy code
The service <http://bigquery.googleapis.com|bigquery.googleapis.com> is depended on by the following active service(s): <http://bigquerystorage.googleapis.com|bigquerystorage.googleapis.com>
so how can I enable this service then ?