-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathmain.tf
143 lines (116 loc) · 3.15 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
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
terraform {
backend "gcs" {
bucket = "kontaindotme-tfstate"
prefix = "terraform/state"
}
required_providers {
google = { source = "hashicorp/google" }
ko = { source = "ko-build/ko" }
}
}
provider "google" {
project = var.project_id
}
variable "project_id" {
type = string
description = "The project ID to deploy to."
}
variable "location" {
type = string
description = "The location of the Cloud Run service."
default = "us-east4"
}
variable "domain" {
type = string
description = "The domain to map the Cloud Run service to."
}
variable "notification_channels" {
type = set(string)
description = "The notification channels to send alerts to."
default = []
}
module "dashboard" {
for_each = tomap(local.apps)
source = "git::https://github.com/chainguard-dev/terraform-infra-common//modules/dashboard/service?ref=main"
project_id = var.project_id
service_name = each.key
//alerts = lookup(each.value, "alert_id", "") == "" ? [] : [each.value.alert_id]
notification_channels = var.notification_channels
}
resource "google_storage_bucket" "bucket" {
name = "${var.project_id}-kontainme"
location = "US"
uniform_bucket_level_access = true
# Delete objects after 1 day.
lifecycle_rule {
condition {
age = 1
}
action {
type = "Delete"
}
}
# Allow
cors {
origin = ["*"]
method = ["GET", "HEAD"]
response_header = ["*"]
}
}
# Make the bucket publicly readable.
resource "google_storage_bucket_iam_member" "public-read" {
bucket = google_storage_bucket.bucket.name
role = "roles/storage.objectViewer"
member = "allUsers"
}
resource "google_service_account" "service_account" {
account_id = "kontaindotme"
}
resource "google_storage_bucket_iam_member" "bucket-member" {
bucket = google_storage_bucket.bucket.name
role = "roles/storage.admin"
member = "serviceAccount:${google_service_account.service_account.email}"
}
resource "google_dns_managed_zone" "zone" {
name = "kontainme-zone"
dns_name = "${var.domain}."
depends_on = [google_project_service.dns-api]
}
// Enable Cloud DNS API.
resource "google_project_service" "dns-api" {
project = var.project_id
service = "dns.googleapis.com"
disable_on_destroy = false
}
// Redirect kontain.me to github.com/imjasonh/kontain.me
resource "google_dns_record_set" "root-a-record" {
name = "${var.domain}."
type = "A"
ttl = 300
managed_zone = google_dns_managed_zone.zone.name
rrdatas = [
"216.239.32.21",
"216.239.34.21",
"216.239.36.21",
"216.239.38.21",
]
}
// Redirect kontain.me to github.com/imjasonh/kontain.me
resource "google_dns_record_set" "root-aaaa-record" {
name = "${var.domain}."
type = "AAAA"
ttl = 300
managed_zone = google_dns_managed_zone.zone.name
rrdatas = [
"2001:4860:4802:32::15",
"2001:4860:4802:34::15",
"2001:4860:4802:36::15",
"2001:4860:4802:38::15",
]
}
// Enable Cloud Run API.
resource "google_project_service" "run-api" {
project = var.project_id
service = "run.googleapis.com"
disable_on_destroy = false
}