Skip to content

Commit

Permalink
Collapse service names (#14)
Browse files Browse the repository at this point in the history
* Collapse service names to a single value

* Add Cloud Run dashboard

from https://github.com/GoogleCloudPlatform/monitoring-dashboard-samples/

* Fix plan github comment
  • Loading branch information
joecorall authored May 20, 2024
1 parent 1ef212a commit 9f50612
Show file tree
Hide file tree
Showing 3 changed files with 318 additions and 272 deletions.
14 changes: 8 additions & 6 deletions .github/workflows/plan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,22 +66,24 @@ jobs:
echo "::set-output name=plan::$out"
continue-on-error: true

- uses: actions/github-script@v5
- name: Post comment with Terraform plan
uses: actions/github-script@v5
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const output = `#### Terraform Plan 📖\`${{ steps.plan.outcome }}\`
const output = `#### Terraform Plan 📖
\`${{ steps.plan.outcome }}\`
<details><summary>Show Plan</summary>
\`\`\`terraform\n
\`\`\`terraform
${{ steps.plan.outputs.plan }}
\n\`\`\`
\`\`\`
</details>
</details>`;
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: output
})
});
26 changes: 15 additions & 11 deletions modules/cloudrun/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,16 @@ data "docker_registry_image" "image" {
}

resource "google_cloud_run_service" "cloudrun" {
count = length(var.regions)
name = format("%s-%s", var.name, var.regions[count.index])
location = var.regions[count.index]
for_each = toset(var.regions)
name = var.name
location = each.value

lifecycle {
ignore_changes = [
metadata[0].annotations["run.googleapis.com/launch-stage"],
metadata[0].effective_annotations["run.googleapis.com/launch-stage"]
]
create_before_destroy = true
}

metadata {
Expand Down Expand Up @@ -110,24 +111,27 @@ resource "google_cloud_run_service" "cloudrun" {
}

resource "google_cloud_run_service_iam_member" "invoker" {
count = length(var.regions)
location = google_cloud_run_service.cloudrun[count.index].location
service = google_cloud_run_service.cloudrun[count.index].name
for_each = toset(var.regions)
location = each.value
service = google_cloud_run_service.cloudrun[each.value].name
role = "roles/run.invoker"
member = "allUsers"
}

# create a serverless NEG for this set of regional services
resource "google_compute_region_network_endpoint_group" "neg" {
count = length(var.regions)

name = "libops-neg-${google_cloud_run_service.cloudrun[count.index].name}"
for_each = toset(var.regions)
name = "libops-neg-${var.name}-${each.value}"
network_endpoint_type = "SERVERLESS"
region = google_cloud_run_service.cloudrun[count.index].location
region = each.value
project = var.project

cloud_run {
service = google_cloud_run_service.cloudrun[count.index].name
service = google_cloud_run_service.cloudrun[each.value].name
}

lifecycle {
create_before_destroy = true
}
}

Expand Down
Loading

0 comments on commit 9f50612

Please sign in to comment.