Skip to content

Commit

Permalink
Adding new samples for PubSub with Cloud Run tutorials (hashicorp#6126)…
Browse files Browse the repository at this point in the history
… (hashicorp#11930)

* feat: add in samples for pubsub tutorials for cloud run

refactor: switching to erb

* Update mmv1/templates/terraform/examples/cloud_run_service_pubsub.tf.erb

Co-authored-by: Stephen Lewis (Burrows) <stephen.r.burrows@gmail.com>

* Update mmv1/templates/terraform/examples/cloud_run_service_pubsub.tf.erb

Co-authored-by: Stephen Lewis (Burrows) <stephen.r.burrows@gmail.com>

* Update mmv1/templates/terraform/examples/cloud_run_service_pubsub.tf.erb

Co-authored-by: Stephen Lewis (Burrows) <stephen.r.burrows@gmail.com>

* Update mmv1/templates/terraform/examples/cloud_run_service_pubsub.tf.erb

Co-authored-by: Stephen Lewis (Burrows) <stephen.r.burrows@gmail.com>

* refactor: remove extra cloud pubsub vars

* Update mmv1/templates/terraform/examples/cloud_run_service_pubsub.tf.erb

Co-authored-by: Stephen Lewis (Burrows) <stephen.r.burrows@gmail.com>

* Update mmv1/templates/terraform/examples/cloud_run_service_pubsub.tf.erb

Co-authored-by: Stephen Lewis (Burrows) <stephen.r.burrows@gmail.com>

Co-authored-by: Stephen Lewis (Burrows) <stephen.r.burrows@gmail.com>
Signed-off-by: Modular Magician <magic-modules@google.com>

Co-authored-by: Stephen Lewis (Burrows) <stephen.r.burrows@gmail.com>
  • Loading branch information
modular-magician and melinath authored Jun 21, 2022
1 parent 1d061ea commit 6e28de4
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .changelog/6126.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
google_cloud_run_service: added samples for pubsub tutorials
```
55 changes: 55 additions & 0 deletions website/docs/r/cloud_run_service.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,61 @@ To get more information about Service, see:
a Cloud Run Service on Anthos(GKE/VMWare) then you will need to create it using the kubernetes alpha provider.
Have a look at the Cloud Run Anthos example below.

## Example Usage - Cloud Run Service Pubsub


```hcl
resource "google_cloud_run_service" "default" {
name = "cloud_run_service_name"
location = "us-central1"
template {
spec {
containers {
image = "gcr.io/cloudrun/hello"
}
}
}
traffic {
percent = 100
latest_revision = true
}
}
resource "google_service_account" "sa" {
account_id = "cloud-run-pubsub-invoker"
display_name = "Cloud Run Pub/Sub Invoker"
}
resource "google_cloud_run_service_iam_binding" "binding" {
location = google_cloud_run_service.default.location
service = google_cloud_run_service.default.name
role = "roles/run.invoker"
members = ["serviceAccount:${google_service_account.sa.email}"]
}
resource "google_project_iam_binding" "project" {
role = "roles/iam.serviceAccountTokenCreator"
members = ["serviceAccount:${google_service_account.sa.email}"]
}
resource "google_pubsub_topic" "topic" {
name = "pubsub_topic"
}
resource "google_pubsub_subscription" "subscription" {
name = "pubsub_subscription"
topic = google_pubsub_topic.topic.name
push_config {
push_endpoint = google_cloud_run_service.default.status[0].url
oidc_token {
service_account_email = google_service_account.sa.email
}
attributes = {
x-goog-version = "v1"
}
}
}
```
## Example Usage - Cloud Run Service Basic


Expand Down

0 comments on commit 6e28de4

Please sign in to comment.