Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Collapse service names #14

Merged
merged 5 commits into from
May 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading