ForeverConfused
ForeverConfused

Reputation: 1777

Is there any way to automatically add labels when creating a GCE server?

In AWS it was possible to run cloudwatch to trigger callback lambda functions on events.

Is it possible in GCE to automatically tag servers with the user who created it based on the activity logs? Google Cloud functions seem to only be able run a non-public callback based on GCS events.

How would I do this?

Upvotes: 0

Views: 542

Answers (1)

Rubén C.
Rubén C.

Reputation: 1098

As a matter of fact, there are four types of triggers for Google Cloud Functions. But none of them is useful in this case.

There is a way to automatically do so, though.

  1. You can create an application setting up Stackdriver Logging using a Client Library, as for example Python, in App Engine.
  2. Then you can schedule a task using a cron job which triggers the application. You can use the client library to review the logs and search for compute.instance.insert (CE creation), the "actor" or "user" and...
  3. finally add a label to the existing resource.

Upvotes: 1

Related Questions