-
Notifications
You must be signed in to change notification settings - Fork 1
/
example.fixed.tf
81 lines (72 loc) · 2.87 KB
/
example.fixed.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
module "gke_cluster" {
source = "github.com/terraform-google-modules/terraform-google-kubernetes-engine//modules/cluster"
}
resource "google_service_account" "some_account" {
account_id = "some-account"
project = "foo"
}
resource "google_service_account_iam_member" "sa_member" {
service_account_id = google_service_account.some_account.account_id
role = "roles/iam.workloadIdentityUser"
member = "principalSet://iam.googleapis.com/${google_iam_workload_identity_pool.something-something.name}/attribute.repository/my-github/repository-name"
}
resource "google_service_account_iam_member" "sa_member2" {
service_account_id = google_service_account.foo-bar.account_id
role = "roles/iam.workloadIdentityUser"
member = "principalSet://iam.googleapis.com/${google_iam_workload_identity_pool.something-something.name}/attribute.repository/my-github/repository-name"
}
#resource "google_pubsub_topic" "foo" {
# name = "foo"
# labels = {
# foo = "bar"
# }
#}
# resource "google_pubsub_topic" "foo" {
# name = "foo"
# labels = {
# foo = "bar"
# }
# }
variable "project_id" {
type = string
default = "foo-bar"
}
resource "google_service_account_iam_member" "some_workloadIdentityUser" {
service_account_id = google_service_account.some.name
role = "roles/iam.workloadIdentityUser"
member = "serviceAccount:foo.svc.id.goog[kube-system/bar]"
}
# ---------------------------------------------------- #
# ---- some-team google artifact registry resource --- #
resource "google_artifact_registry_repository" "some_image_registry" {
project = var.project_id
location = "us"
repository_id = "some-images"
description = "some repository"
format = "DOCKER"
}
resource "google_service_account_iam_member" "some_service_account_impersonation" {
service_account_id = "projects/my-project-id/serviceAccounts/some-service-account-name@my-project-id.iam.gserviceaccount.com"
role = "roles/iam.workloadIdentityUser"
member = "principalSet://iam.googleapis.com/${module.my-cluster.iam-workload_identity-pool}/attribute.repository/my-org/my-repo"
}
resource "google_pubsub_topic_iam_binding" "some_team_pubsub_topic_publisher" {
project = var.project_id
topic = google_pubsub_topic.some_team-pubsub.name
role = "roles/pubsub.publisher"
members = [
"serviceAccount:${google_service_account.some-team_service-account.email}",
"serviceAccount:some-service-account@my-project-id.iam.gserviceaccount.com",
"group:some_gcp_user-group@example.com",
]
}
resource "google_pubsub_subscription" "some_team_name_engineer_subscription" {
name = "some_team-name_engineer_subscription"
topic = google_pubsub_topic.some_team-name_topic.name
bigquery_config {
table = "my-project-id.some.table-name"
}
labels = {
team = "some-team-name"
}
}