Skip to content

Commit 8e668dd

Browse files
authored
docs(eventarc): update ReadMes (GoogleCloudPlatform#5348)
## Description Fixes GoogleCloudPlatform#5057 Note: It's a good idea to open an issue first for discussion. ## Checklist - [ ] I have followed [Sample Guidelines from AUTHORING_GUIDE.MD](https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/AUTHORING_GUIDE.md) - [ ] README is updated to include [all relevant information](https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/AUTHORING_GUIDE.md#readme-file) - [ ] **Tests** pass: `nox -s py-3.6` (see [Test Environment Setup](https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/AUTHORING_GUIDE.md#test-environment-setup)) - [ ] **Lint** pass: `nox -s lint` (see [Test Environment Setup](https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/AUTHORING_GUIDE.md#test-environment-setup)) - [ ] These samples need a new **API enabled** in testing projects to pass (let us know which ones) - [ ] These samples need a new/updated **env vars** in testing projects set to pass (let us know which ones) - [ ] Please **merge** this PR for me once it is approved. - [ ] This sample adds a new sample directory, and I updated the [CODEOWNERS file](https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/.github/CODEOWNERS) with the codeowners for this sample
1 parent ee74610 commit 8e668dd

File tree

2 files changed

+22
-69
lines changed

2 files changed

+22
-69
lines changed

eventarc/audit-storage/README.md

Lines changed: 4 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,7 @@
11
# Cloud Eventarc - Cloud Storage via Audit Logs tutorial
22

3-
This sample shows how to create a service that processes GCS using [the CloudEvents SDK](https://github.com/cloudevents/sdk-python).
3+
This sample shows how to create a service that processes GCS using
4+
[the CloudEvents SDK](https://github.com/cloudevents/sdk-python).
45

5-
## Setup
6-
7-
Configure environment variables:
8-
9-
```sh
10-
MY_RUN_SERVICE=gcs-service
11-
MY_RUN_CONTAINER=gcs-container
12-
MY_GCS_BUCKET=gcs-bucket # Must be globally unique.
13-
```
14-
15-
## Quickstart
16-
17-
Deploy your Cloud Run service:
18-
19-
```sh
20-
gcloud builds submit \
21-
--tag gcr.io/$(gcloud config get-value project)/$MY_RUN_CONTAINER
22-
gcloud run deploy $MY_RUN_SERVICE \
23-
--image gcr.io/$(gcloud config get-value project)/$MY_RUN_CONTAINER \
24-
--platform managed
25-
```
26-
27-
Create a _single region_ Cloud Storage bucket:
28-
29-
```sh
30-
gsutil mb -p $(gcloud config get-value project) \
31-
-l us-central1 \
32-
gs://"$MY_GCS_BUCKET"
33-
```
34-
35-
Create Cloud Storage trigger:
36-
37-
```sh
38-
gcloud beta eventarc triggers create my-gcs-trigger \
39-
--destination-run-service $MY_RUN_SERVICE \
40-
--matching-criteria type=google.cloud.audit.log.v1.written \
41-
--matching-criteria methodName=storage.buckets.update \
42-
--matching-criteria serviceName=storage.googleapis.com \
43-
--matching-criteria resourceName=projects/_/buckets/"$MY_GCS_BUCKET"
44-
```
45-
46-
## Test
47-
48-
Test your Cloud Run service by creating a GCS event:
49-
50-
```sh
51-
gsutil defstorageclass set STANDARD gs://$MY_GCS_BUCKET
52-
```
53-
54-
Observe the Cloud Run service printing upon receiving an event in Cloud Logging:
55-
56-
```sh
57-
gcloud logging read "resource.type=cloud_run_revision AND \
58-
resource.labels.service_name=$MY_RUN_SERVICE" \
59-
--project $(gcloud config get-value project) \
60-
--limit 30 \
61-
--format 'value(textPayload)'
62-
```
63-
64-
One of the logs you'll see shows the Run service confirming the event was received:
65-
66-
```
67-
GCS CloudEvent type: storage.googleapis.com/projects/_/buckets/gcs-bucket
68-
```
6+
See tutorial, [Quickstart: Receiving Cloud Storage events](https://cloud.google.com/eventarc/docs/run/quickstart?hl=en#python),
7+
tutorial for instructions for setting up and deploying this sample application.

eventarc/pubsub/README.md

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,38 @@
33
This sample shows how to create a service that processes Pub/Sub events using
44
[the CloudEvents SDK](https://github.com/cloudevents/sdk-python).
55

6+
## Setup
7+
8+
Set the `gcloud` configuration variables:
9+
10+
```sh
11+
gcloud config set project <PROJECT_ID>
12+
gcloud config set run/region us-central1
13+
gcloud config set run/platform managed
14+
gcloud config set eventarc/location us-central1
15+
```
16+
617
## Quickstart
718

819
Deploy your Cloud Run service:
920

1021
```sh
1122
gcloud builds submit \
1223
--tag gcr.io/$(gcloud config get-value project)/eventarc-pubsub
24+
1325
gcloud run deploy eventarc-pubsub \
1426
--image gcr.io/$(gcloud config get-value project)/eventarc-pubsub \
15-
--platform managed
27+
--platform managed \
28+
--allow-unauthenticated
1629
```
1730

1831
Create a Cloud Eventarc trigger, which will also create a Pub/Sub topic:
1932

2033
```sh
21-
gcloud beta eventarc triggers create pubsub-trigger \
22-
--destination-run-service eventarc-pubsub \
23-
--matching-criteria "type=google.cloud.pubsub.topic.v1.messagePublished"
34+
gcloud eventarc triggers create pubsub-trigger \
35+
--destination-run-service=events-pubsub \
36+
--destination-run-region=us-central1 \
37+
--event-filters="type=google.cloud.pubsub.topic.v1.messagePublished"
2438
```
2539

2640
## Test

0 commit comments

Comments
 (0)