package
2.1.0+incompatible
Repository: https://github.com/cloudfoundry-community/gcp-tools-release.git
Documentation: pkg.go.dev

# README

cf-stackdriver-example

A Cloud Foundry application written in Go that reports errors to Stackdriver Error Reporting and can be debugged with the Stackdriver Debugger.

Based on the Kubernetes Guestbook App. This is not an official Google product.

Prerequisites

Deploying the application

The application requires the GOOGLE_PROJECT environment variable to start. The following snippet will create the app, set the variable, and re-stage the app at which time it should start.

cf push
export project_id=$(gcloud config get-value project 2>/dev/null)
cf set-env cf-stackdriver-example GOOGLE_PROJECT ${project_id}
cf restage cf-stackdriver-example

Setting up IAM permissions

The following IAM roles are required for the service account of this application. If your Cloud Foundry is deployed on GCP with these default service account credentials then you can skip this step.

  • roles/clouddebugger.agent
  • roles/logging.logWriter
  • roles/datastore.owner

Use the following command to create a service account with these roles:

export project_id=$(gcloud config get-value project 2>/dev/null)
export account_name=cf-stackdriver-example
export service_account_email=${account_name}@${project_id}.iam.gserviceaccount.com
gcloud iam service-accounts create ${account_name}
gcloud projects add-iam-policy-binding ${project_id} --member serviceAccount:${service_account_email} --role "roles/clouddebugger.agent"
gcloud projects add-iam-policy-binding ${project_id} --member serviceAccount:${service_account_email} --role "roles/logging.logWriter"
gcloud projects add-iam-policy-binding ${project_id} --member serviceAccount:${service_account_email} --role "roles/datastore.owner"
gcloud iam service-accounts keys create service_account.json \
    --iam-account ${service_account_email}

Pass these credentials to your application and deploy it:

cf set-env cf-stackdriver-example GOOGLE_APPLICATION_CREDENTIALS '/home/vcap/app/service_account.json'
./deploy

Try it out

Navigate to your application's URL and attempt to submit a guestbook entry. You should see a new error in the Stackdriver Errors console. Try setting a debug breakpoint in main.go:69 and see if you can spot the bug.

# Functions

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Structs

Entry
No description provided by the author
No description provided by the author