export PROJECT_ID=das-ct-lab
export SERVICE_ACCOUNT_ID_RUNTIME=sa-cloudrun-firestore
gcloud iam service-accounts create $SERVICE_ACCOUNT_ID_RUNTIME \
--description="To cloud run runtime use firestore" \
--display-name="cloud run sa firestore" \
--project=$PROJECT_ID
角色綁定
gcloud projects add-iam-policy-binding $PROJECT_ID \
--member="serviceAccount:$SERVICE_ACCOUNT_ID_RUNTIME@$PROJECT_ID.iam.gserviceaccount.com" \
--role="roles/datastore.user"
gcloud projects add-iam-policy-binding $PROJECT_ID \
--member="serviceAccount:$SERVICE_ACCOUNT_ID_RUNTIME@$PROJECT_ID.iam.gserviceaccount.com" \
--role="roles/cloudtrace.agent"
gcloud projects add-iam-policy-binding $PROJECT_ID \
--member="serviceAccount:$SERVICE_ACCOUNT_ID_RUNTIME@$PROJECT_ID.iam.gserviceaccount.com" \
--role="roles/logging.serviceAgent"
gcloud projects add-iam-policy-binding $PROJECT_ID \
--member="serviceAccount:$SERVICE_ACCOUNT_ID_RUNTIME@$PROJECT_ID.iam.gserviceaccount.com" \
--role="roles/monitoring.metricWriter"