Skip to content

Commit ee99c96

Browse files
committed
Fix feedback from first workshop iteration
1 parent 2f5fe50 commit ee99c96

File tree

5 files changed

+28
-32
lines changed

5 files changed

+28
-32
lines changed

README.md

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ In order to get a custom domain up and running, we'll create a CDN with a load b
291291
1. Create a new file `cdn.tf` and add the CDN:
292292
293293
```terraform
294-
resource "google_compute_backend_bucket" "cdn_backend_bucket" {
294+
resource "google_compute_backend_bucket" "cdn_bucket" {
295295
name = "cdn-bucket-${local.id}"
296296
description = "Backend bucket for serving static content through CDN"
297297
bucket_name = google_storage_bucket.frontend.name
@@ -320,18 +320,18 @@ In order to get a custom domain up and running, we'll create a CDN with a load b
320320
2. Time to set up the load balancer:
321321
322322
```terraform
323-
resource "google_compute_url_map" "frontend_lb" {
323+
resource "google_compute_url_map" "lb" {
324324
name = "cdn-url-map-${local.id}"
325-
default_service = google_compute_backend_bucket.cdn_backend_bucket.self_link
325+
default_service = google_compute_backend_bucket.cdn_bucket.self_link
326326
}
327327
328328
resource "google_compute_target_http_proxy" "frontend" {
329329
name = "http-proxy-${local.id}"
330-
url_map = google_compute_url_map.frontend_lb.id
330+
url_map = google_compute_url_map.lb.id
331331
}
332332
333-
resource "google_compute_global_forwarding_rule" "default" {
334-
name = "website-forwarding-rule-${local.id}"
333+
resource "google_compute_global_forwarding_rule" "frontend" {
334+
name = "frontend-forwarding-rule-${local.id}"
335335
target = google_compute_target_http_proxy.frontend.id
336336
port_range = "80"
337337
load_balancing_scheme = "EXTERNAL"
@@ -359,8 +359,7 @@ We will use `cloudlabs-gcp.no` for this workshop. It is already configured in a
359359
2. Add the IP to the DNS zone:
360360
361361
```terraform
362-
resource "google_dns_record_set" "website" {
363-
provider = google
362+
resource "google_dns_record_set" "frontend" {
364363
name = "${local.id}.${data.google_dns_managed_zone.cloudlabs_gcp_no.dns_name}"
365364
type = "A"
366365
ttl = 60
@@ -396,9 +395,9 @@ To enable HTTPS for the CDN we need to create a certificate. Managed SSL certifi
396395
```terraform
397396
resource "google_compute_managed_ssl_certificate" "frontend" {
398397
provider = google-beta
399-
name = "website-certificate-${local.id}"
398+
name = "frontend-certificate-${local.id}"
400399
managed {
401-
domains = [google_dns_record_set.website.name]
400+
domains = [google_dns_record_set.frontend.name]
402401
}
403402
}
404403
```
@@ -407,8 +406,8 @@ To enable HTTPS for the CDN we need to create a certificate. Managed SSL certifi
407406
408407
```terraform
409408
resource "google_compute_target_https_proxy" "frontend" {
410-
name = "website-target-proxy-https-${local.id}"
411-
url_map = google_compute_url_map.frontend_lb.self_link
409+
name = "frontend-target-proxy-https-${local.id}"
410+
url_map = google_compute_url_map.lb.self_link
412411
ssl_certificates = [google_compute_managed_ssl_certificate.frontend.self_link]
413412
}
414413
```
@@ -417,7 +416,7 @@ To enable HTTPS for the CDN we need to create a certificate. Managed SSL certifi
417416
418417
```terraform
419418
resource "google_compute_global_forwarding_rule" "frontend_https" {
420-
name = "website-forwarding-rule-https-${local.id}"
419+
name = "frontend-forwarding-rule-https-${local.id}"
421420
load_balancing_scheme = "EXTERNAL"
422421
ip_address = google_compute_global_address.cdn_public_address.address
423422
ip_protocol = "TCP"

solutions/cdn.tf

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
resource "google_compute_backend_bucket" "cdn_backend_bucket" {
1+
resource "google_compute_backend_bucket" "cdn_bucket" {
22
name = "cdn-bucket-${local.id}"
33
description = "Backend bucket for serving static content through CDN"
44
bucket_name = google_storage_bucket.frontend.name
55
enable_cdn = true
66
}
77

8-
# # Reserve an external IP
8+
# Reserve an external IP
99
resource "google_compute_global_address" "cdn_public_address" {
1010
name = "cdn-public-address-${local.id}"
1111
}
@@ -14,18 +14,18 @@ output "cdn_public_ip" {
1414
value = google_compute_global_address.cdn_public_address.address
1515
}
1616

17-
resource "google_compute_url_map" "frontend_lb" {
17+
resource "google_compute_url_map" "lb" {
1818
name = "cdn-url-map-${local.id}"
19-
default_service = google_compute_backend_bucket.cdn_backend_bucket.self_link
19+
default_service = google_compute_backend_bucket.cdn_bucket.self_link
2020
}
2121

2222
resource "google_compute_target_http_proxy" "frontend" {
2323
name = "http-proxy-${local.id}"
24-
url_map = google_compute_url_map.frontend_lb.id
24+
url_map = google_compute_url_map.lb.id
2525
}
2626

27-
resource "google_compute_global_forwarding_rule" "default" {
28-
name = "website-forwarding-rule-${local.id}"
27+
resource "google_compute_global_forwarding_rule" "frontend" {
28+
name = "frontend-forwarding-rule-${local.id}"
2929
target = google_compute_target_http_proxy.frontend.id
3030
port_range = "80"
3131
load_balancing_scheme = "EXTERNAL"

solutions/dns.tf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ output "cloudlabs_gcp_no_dns" {
88
}
99

1010
resource "google_dns_record_set" "frontend" {
11-
provider = google
1211
name = "${local.id}.${data.google_dns_managed_zone.cloudlabs_gcp_no.dns_name}"
1312
type = "A"
1413
ttl = 60

solutions/frontend.tf

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,17 @@ resource "google_storage_bucket" "frontend" {
1818
force_destroy = true
1919
}
2020

21-
// http er ikke satt opp ennå, trengs ikke du får owner uansett
2221
resource "google_storage_bucket_iam_member" "frontend_read" {
2322
bucket = google_storage_bucket.frontend.name
2423
role = "roles/storage.objectViewer"
2524
member = "allUsers"
2625
}
2726

28-
# // dette er så alle kan se objektene i bucketen
29-
# resource "google_storage_default_object_access_control" "website_read" {
30-
# bucket = google_storage_bucket.frontend.id
31-
# role = "READER"
32-
# entity = "allUsers"
33-
# }
27+
#resource "google_storage_default_object_access_control" "website_read" {
28+
# bucket = google_storage_bucket.frontend.id
29+
# role = "READER"
30+
# entity = "allUsers"
31+
#}
3432

3533
resource "google_storage_bucket_object" "frontend" {
3634
for_each = local.frontend_files

solutions/https.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
# Create HTTPS certificate
22
resource "google_compute_managed_ssl_certificate" "frontend" {
33
provider = google-beta
4-
name = "website-certificate-${local.id}"
4+
name = "frontend-certificate-${local.id}"
55
managed {
66
domains = [google_dns_record_set.frontend.name]
77
}
88
}
99

1010
# GCP target proxy
1111
resource "google_compute_target_https_proxy" "frontend" {
12-
name = "website-target-proxy-https-${local.id}"
13-
url_map = google_compute_url_map.frontend_lb.self_link
12+
name = "frontend-target-proxy-https-${local.id}"
13+
url_map = google_compute_url_map.lb.self_link
1414
ssl_certificates = [google_compute_managed_ssl_certificate.frontend.self_link]
1515
}
1616

1717
# GCP forwarding rule
1818
resource "google_compute_global_forwarding_rule" "frontend_https" {
19-
name = "website-forwarding-rule-https-${local.id}"
19+
name = "frontend-forwarding-rule-https-${local.id}"
2020
load_balancing_scheme = "EXTERNAL"
2121
ip_address = google_compute_global_address.cdn_public_address.address
2222
ip_protocol = "TCP"

0 commit comments

Comments
 (0)