Skip to content

Commit

Permalink
Bootstrap actions, add a trivial module. (#1)
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Moore <[email protected]>
  • Loading branch information
mattmoor authored Dec 9, 2023
1 parent 9018264 commit 2563713
Show file tree
Hide file tree
Showing 7 changed files with 96 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
version: 2
updates:
- package-ecosystem: gomod
directory: "/"
schedule:
interval: "daily"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
26 changes: 26 additions & 0 deletions .github/workflows/documentation.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Generate terraform docs

on:
pull_request:

jobs:
docs:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
module:
- authorize-private-service

steps:
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2

- uses: terraform-docs/gh-actions@f6d59f89a280fa0a3febf55ef68f146784b20ba0 # v1.0.0
with:
working-dir: ${{ matrix.module }}
output-file: README.md
output-method: inject
fail-on-diff: "true"

- if: failure()
run: cat README.md
21 changes: 21 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Validate, Lint and Test

on:
push:
branches:
- main
pull_request:

jobs:
lint-and-validate:
name: "Terraform fmt and validate"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
- uses: hashicorp/setup-terraform@633666f66e0061ca3b725c73b2ec20cd13a8fdd1 # v2.0.3

- run: terraform fmt -check

- run: |
terraform init
terraform validate
Empty file.
16 changes: 16 additions & 0 deletions authorize-private-service/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
resource "google_cloud_run_v2_service_iam_member" "authorize-calls" {
project = var.project_id
location = var.region
name = var.name

role = "roles/run.invoker"
member = "serviceAccount:${var.service-account}"
}

data "google_cloud_run_v2_service" "this" {
depends_on = [google_cloud_run_v2_service_iam_member.authorize-calls]

project = var.project_id
location = var.region
name = var.name
}
4 changes: 4 additions & 0 deletions authorize-private-service/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
output "uri" {
description = "The URI of the private Cloud Run service."
value = data.google_cloud_run_v2_service.this.uri
}
18 changes: 18 additions & 0 deletions authorize-private-service/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
variable "project_id" {
type = string
}

variable "region" {
description = "The region in which this Cloud Run service is based."
type = string
}

variable "name" {
description = "The name of the Cloud Run service in this region."
type = string
}

variable "service-account" {
description = "The email of the service account being authorized to invoke the private Cloud Run service."
type = string
}

0 comments on commit 2563713

Please sign in to comment.