Skip to content

Commit 0ee8a63

Browse files
mayuthombremayuthombre
authored andcommitted
updated cloud run service with role binding to write to bigquery
1 parent aa4e5c6 commit 0ee8a63

File tree

5 files changed

+33
-15
lines changed

5 files changed

+33
-15
lines changed

infrastructure/gcp/bigquery_component.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
import json
22

33
from cdktf_cdktf_provider_google import (
4-
bigquery_dataset, bigquery_table,
5-
data_google_bigquery_default_service_account, kms_crypto_key,
6-
kms_crypto_key_iam_binding, kms_key_ring)
4+
bigquery_dataset,
5+
bigquery_table,
6+
data_google_bigquery_default_service_account,
7+
kms_crypto_key,
8+
kms_crypto_key_iam_binding,
9+
kms_key_ring
10+
)
711
from constructs import Construct
812

913

infrastructure/gcp/cloudrun_component.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def __init__(
2626
"spec": {
2727
"containers": [
2828
{
29-
"image": "australia-southeast1-docker.pkg.dev/contino-squad0-fc/flight-contoller-event-receiver/event_receiver:latest",
29+
"image": "australia-southeast1-docker.pkg.dev/contino-squad0-fc/flight-controller-event-receiver/event_receiver:latest",
3030
"ports": [{"container_port": 8080}],
3131
},
3232
],
@@ -38,7 +38,7 @@ def __init__(
3838
self.bigquery_job = project_iam_member.ProjectIamMember(
3939
self,
4040
"bigquery_job",
41-
role="roles/bigquery.jobUser",
41+
role="roles/bigquery.dataEditor",
4242
member=f"serviceAccount:{cloudrun_account.email}",
4343
project=project_id,
4444
)

infrastructure/gcp/eventarc_with_pubsub_component.py

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
1-
from cdktf_cdktf_provider_google import (cloud_run_service, eventarc_trigger,
2-
kms_crypto_key,
3-
kms_crypto_key_iam_binding,
4-
kms_key_ring, project_iam_binding,
5-
pubsub_topic, service_account)
1+
from cdktf_cdktf_provider_google import (
2+
cloud_run_service,
3+
eventarc_trigger,
4+
kms_crypto_key,
5+
kms_crypto_key_iam_binding,
6+
kms_key_ring,
7+
project_iam_binding,
8+
pubsub_topic,
9+
service_account,
10+
)
611
from constructs import Construct
712

813

@@ -86,3 +91,11 @@ def __init__(
8691
role="roles/eventarc.eventReceiver",
8792
members=[f"serviceAccount:{cloudrun_account.email}"],
8893
)
94+
95+
self.eventarc = project_iam_binding.ProjectIamBinding(
96+
self,
97+
"eventarc_binding",
98+
project=project_id,
99+
role="roles/run.invoker",
100+
members=[f"serviceAccount:{service_account.email}"],
101+
)

infrastructure/gcp/main.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,9 @@ def __init__(
140140
NAME_PREFIX,
141141
DOMAIN_NAME
142142
)
143-
# self.grafana_workspace_id = lb_component.global_address.address
144143

145-
# GCP Grafana Stack
144+
145+
## GCP Grafana Stack
146146
# class GcpGrafana(TerraformStack):
147147
# def __init__(self, scope: Construct, id: str, workspace_id: str,):
148148
# super().__init__(scope, id)
@@ -151,8 +151,7 @@ def __init__(
151151
# self,
152152
# "Grafana",
153153
# auth="",
154-
# url=workspace_id
155-
# + ":80",
154+
# url="https://"+DOMAIN_NAME
156155
# )
157156

158157
# # Create Grafana dashboard

infrastructure/gcp/service_account_component.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,7 @@ def __init__(
1919
)
2020

2121
self.cloud_run = service_account.ServiceAccount(
22-
self, "cloud-run", project=project_id, account_id="fc-cloud-run"
22+
self, "cloud-run",
23+
project=project_id,
24+
account_id="fc-cloud-run"
2325
)

0 commit comments

Comments
 (0)