forked from kishanrajput23/Java-Projects-Collections
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheventarc.txt
59 lines (45 loc) · 2.2 KB
/
eventarc.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
REGION=us-east1
gcloud config set project "$DEVSHELL_PROJECT_ID"
gcloud config set run/region "$REGION"
gcloud config set run/platform managed
gcloud config set eventarc/location "$REGION"
export PROJECT_NUMBER="$(gcloud projects list \
--filter=$(gcloud config get-value project) \
--format='value(PROJECT_NUMBER)')"
gcloud projects add-iam-policy-binding $(gcloud config get-value project) \
--member=serviceAccount:${PROJECT_NUMBER}-compute@developer.gserviceaccount.com \
--role='roles/eventarc.admin'
gcloud beta eventarc attributes types list
gcloud beta eventarc attributes types describe \
google.cloud.pubsub.topic.v1.messagePublished
export SERVICE_NAME=event-display
export IMAGE_NAME="gcr.io/cloudrun/hello"
gcloud run deploy ${SERVICE_NAME} \
--image ${IMAGE_NAME} \
--allow-unauthenticated \
--max-instances=3
gcloud beta eventarc attributes types describe \
google.cloud.pubsub.topic.v1.messagePublished
gcloud beta eventarc triggers create trigger-pubsub \
--destination-run-service=${SERVICE_NAME} \
--matching-criteria="type=google.cloud.pubsub.topic.v1.messagePublished"
export TOPIC_ID=$(gcloud eventarc triggers describe trigger-pubsub \
--format='value(transport.pubsub.topic)')
gcloud pubsub topics publish ${TOPIC_ID} --message="Hello there"
export BUCKET_NAME=$(gcloud config get-value project)-cr-bucket
gsutil mb -p $(gcloud config get-value project) \
-l $(gcloud config get-value run/region) \
gs://${BUCKET_NAME}/
#---------AUDIT LOGS : Google Cloud Storage -----------------
echo "Hello World" > random.txt
gsutil cp random.txt gs://${BUCKET_NAME}/random.txt
gcloud beta eventarc attributes types describe google.cloud.audit.log.v1.written
gcloud beta eventarc triggers create trigger-auditlog \
--destination-run-service=${SERVICE_NAME} \
--matching-criteria="type=google.cloud.audit.log.v1.written" \
--matching-criteria="serviceName=storage.googleapis.com" \
--matching-criteria="methodName=storage.objects.create" \
--service-account=${PROJECT_NUMBER}-compute@developer.gserviceaccount.com
gsutil cp random.txt gs://${BUCKET_NAME}/random.txt
#----------WAIT FOR 10 MINUTES and RUN BELOW COMMAND AGAIN 2-3 TIMES--------
gsutil cp random.txt gs://${BUCKET_NAME}/random.txt