-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
55 lines (43 loc) · 1.2 KB
/
main.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
terraform {
backend "gcs" {
bucket = "two-eye-two-see-org-wide-terraform-state"
prefix = "terraform/state"
}
}
provider "google" {
region = var.region
}
resource "google_project" "fully_managed_project" {
for_each = var.fully_managed_projects
name = each.key
project_id = each.key
billing_account = each.value
org_id = var.org_id
lifecycle {
# NEVER DESTROY A PROJECT!
prevent_destroy = true
}
}
resource "google_project_iam_binding" "project_owners" {
for_each = var.fully_managed_projects
project = each.key
# FIXME: Investigate if roles/editor is enough?
role = "roles/owner"
lifecycle {
# NEVER DESTROY A PROJECT!
prevent_destroy = true
}
members = var.project_owners
}
# GCS bucket for terraform state of all projects we manage
# If we need to, we can create ACLs later for per-object permissions,
# since terraform keeps each workspace in its own object
resource "google_storage_bucket" "managed_terraform_state" {
name = "${var.project_id}-terraform-state"
project = var.project_id
# Allows us to turn on ACLs in the future if necessary
uniform_bucket_level_access = false
versioning {
enabled = true
}
}