diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index fbdf614..5848441 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -14,6 +14,6 @@ jobs: steps: - uses: actions/setup-go@v2 with: - go-version: 1.18 + go-version: 1.20 - uses: actions/checkout@v3 - run: go build ./... diff --git a/main.tf b/main.tf index a4b0150..b576302 100644 --- a/main.tf +++ b/main.tf @@ -10,7 +10,7 @@ variable "project_id" { variable "location" { type = string description = "The location of the Cloud Run service." - default = "us-central1" + default = "us-east4" } variable "domain" { @@ -57,6 +57,16 @@ 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" } variable "dns_zone" { diff --git a/module/main.tf b/module/main.tf index 86d1a64..09ee870 100644 --- a/module/main.tf +++ b/module/main.tf @@ -10,6 +10,7 @@ terraform { } resource "ko_build" "image" { + repo = "gcr.io/${var.project_id}/${var.name}" importpath = "github.com/imjasonh/kontain.me/cmd/${var.name}" } @@ -41,7 +42,17 @@ resource "google_cloud_run_service" "service" { } } } + + depends_on = [ + google_project_service.run-api, + ] } +// Enable Cloud Run API. +resource "google_project_service" "run-api" { + project = var.project_id + service = "run.googleapis.com" +} + data "google_iam_policy" "noauth" { binding { @@ -74,10 +85,10 @@ resource "google_cloud_run_domain_mapping" "mapping" { resource "google_dns_record_set" "dns-record" { name = "${var.name}.${var.domain}." - type = "CNAME" + type = google_cloud_run_domain_mapping.mapping.status[0].resource_records[0].type ttl = 300 managed_zone = var.dns_zone - rrdatas = ["ghs.googlehosted.com."] + rrdatas = [google_cloud_run_domain_mapping.mapping.status[0].resource_records[0].rrdata] }