![[やってみた] Cloud Run に対応した Gemini Cloud Assist を試してみた #GoogleCloudNext](https://images.ctfassets.net/ct0aopd36mqt/mfvnpH15PsVPOaNIwYZ33/4e17c25441441bdd9f44672815983fd3/eyechatch_googlecloudnext25.png)
[やってみた] Cloud Run に対応した Gemini Cloud Assist を試してみた #GoogleCloudNext
はじめに
2025/4/9-11 の 3日間の日程で Google Cloud Next '25 がラスベガスで開催されました!
開催中のセッション「What’s new in Cloud Run」 の中で発表された Gemini Cloud Assist での Cloud Run サポート(プレビュー)について実際に試してみましたので速報します。
「What’s new in Cloud Run」のセッションンレポートは以下をご参照ください。
Gemini Cloud Assist とは
Gemini Cloud Assist は、BigQuery、Cloud Storage などといった様々な Google Cloud サービスに対し、AI チャットボットによるアシストを受けられるサービスです。現状プレビュー提供されており、プロジェクト上のコンテキストを理解したアプリケーション設計、デプロイ、トラブルシュート、最適化といった支援が受けられます。プレビュー期間中は無償で利用可能です。
詳細は以下をご参照ください。
触ってみた
Cloud Run が Gemini Code Assist に対応(プレビュー)したということで早速触ってみました。
以下ドキュメントを参考に設定し、動作確認していきます。なお、2025/4/15 時点で英語ドキュメントのみ公開されているため、参照する際はドキュメントの言語設定を「English」に変更してください。
Gemini Cloud Assist の設定
Gemini Cloud Assist はフォルダまたはプロジェクト単位で有効化できますが、今回はプロジェクト単位で有効化していきます。
Cloud Console より Gemini の管理 にアクセスし、有効化対象のプロジェクトに切り替えます。
[Get Gemini Cloud Assist] をクリックします。
表示されたダイアログから必要な API が有効化されていることを確認します(有効化されていない場合でも、この後の手順で [Enable Gemini Cloud Assist at no cost] をクリックすると有効化されます)。
[プロンプトと回答を共有して Cloud Assist の改善にご協力ください] は必要に応じてチェックをします(なお、あとでチェックを変更することは可能です)。
最後に [Enable Gemini Cloud Assist at no cost] をクリックします。
Gemini Cloud Assist を利用するユーザーに Gemini Cloud Assist ユーザー と Recommennder 閲覧者 を付与します。
使ってみる
Cloud Console から Cloud Run のページに移動します。現在、検証環境では Cloud Run サービスを2つデプロイしている状態です。
Gemini のマークをクリックし、チャットを開始します。
日本語対応もしていますが、私が試したところでは英語に比べて精度が落ちたので、英語で試した結果を以下より共有します。
Please list the Cloud Run services deployed in this project.
There are 2 Cloud Run services deployed in the current project.
kind
Service
Service
You can view the results in Cloud Asset Inventory with the query:
SELECT resource.data.kind FROM run_googleapis_com_Service WHERE resource.data.kind LIKE '%Service%'
プロジェクト内のコンテキストを理解し回答してくれました。
Please tell me the name of each Cloud Run service.
The Cloud Run services are //run.googleapis.com/projects/xxx/locations/us-central1/services/hello and example.
//run.googleapis.com/projects/xxx/locations/us-central1/services/hello
//run.googleapis.com/projects/xxx/locations/asia-northeast1/services/example
You can view the results in Cloud Asset Inventory with the query:
ELECT name FROM run_googleapis_com_Service
サービス名も教えてくれます。(プロジェクトIDはマスクしています)
Please convert the service 'hello' into Terraform code.
resource "google_cloud_run_v2_service" "default" {
name = "hello"
location = "us-central1"
template {
containers {
image = "us-docker.pkg.dev/cloudrun/container/hello"
}
}
}
This Terraform code defines a Cloud Run v2 service named "hello" in the "us-central1" region. The template block specifies the container image to be used for the service. In this case, it's using the public "hello" image from Google Cloud Run's container registry. The name and location attributes are required to define the Cloud Run service. You may also need to specify the project if it's not already defined in the provider configuration. This configuration will create a basic Cloud Run service using the specified image.
デプロイされている Cloud Run サービスを Terraform コード化してくれました。
How can I better secure my Cloud Run service 'hello'?
Securing your Cloud Run service "hello" is crucial for protecting your application and data. Here's a breakdown of key areas to focus on, along with actionable steps:
1. Identity and Access Management (IAM):
Dedicated Service Account: Instead of using the default Compute Engine service account, create a dedicated service account specifically for the "hello" service. Grant this service account only the minimum necessary permissions to access other Google Cloud resources. This follows the principle of least privilege. This limits the impact if the service is compromised.
Restrict Unauthenticated Access: For internal services, disable unauthenticated access. This ensures that only authorized users or services can invoke your Cloud Run service.
IAM Permissions: Use IAM to control who can access the Cloud Run service itself. The run.routes.invoke permission determines who can trigger the service. You can grant this permission to specific service accounts or groups.
Domain Restricted Sharing: To further restrict access, configure your organization policy to allow only members of your organization to invoke Cloud Run services.
2. Network Security:
Ingress Control: Block direct traffic to the run.app URL and use one of the internal options for ingress. If you use a load balancer you can disable the default run.app URL.
VPC Service Controls: Enclose your Cloud Run service within a VPC Service Controls perimeter. This mitigates the risk of data exfiltration by controlling access to Google Cloud services based on network origin.
Firewall Rules: If you're using Direct VPC egress or Serverless VPC Access, apply firewall rules to control what your Cloud Run service can access via the network.
3. Software Supply Chain Security
Binary Authorization: Enable Binary Authorization to ensure that only trusted container images are deployed to your Cloud Run service. This prevents the deployment of potentially malicious or vulnerable images.
Automatic Security Updates: Enable automatic runtime security updates to ensure that your Cloud Run service benefits from the latest security patches.
4. Data Protection:
Secret Manager: Never store sensitive information like API keys, passwords, or database credentials directly in your code or environment variables. Instead, use Secret Manager to securely store and manage these secrets.
Encryption: Ensure that data is encrypted both at rest and in transit. Google Cloud provides encryption by default, but consider using Customer-Managed Encryption Keys (CMEK) for greater control.
5. Load Balancer Security (If Applicable):
Cloud Armor: If you're using a Google Cloud load balancer in front of your Cloud Run service, enable Cloud Armor to protect against DDoS attacks and other web application threats.
Identity-Aware Proxy (IAP): Use IAP to enforce authentication and authorization for users accessing your Cloud Run service through the load balancer.
SSL Policies: Configure SSL policies on the load balancer to enforce strong TLS versions and cipher suites.
6. Monitoring and Logging:
Cloud Logging: Ensure that Cloud Logging is properly configured to capture all relevant logs from your Cloud Run service.
Cloud Monitoring: Set up Cloud Monitoring to track key performance metrics and security-related events.
7. General Security Practices:
Regular Security Audits: Conduct regular security audits of your Cloud Run service and its dependencies.
Stay Updated: Keep your container images and dependencies up to date with the latest security patches.
Principle of Least Privilege: Always adhere to the principle of least privilege when granting permissions to service accounts and users.
Team Training: Regularly train your team on security best practices for Cloud Run and Google Cloud.
By implementing these measures, you can significantly enhance the security of your Cloud Run service "hello" and protect your applications and data from potential threats. Also, look for a blue light bulb icon in the Cloud Run user interface or in the Recommendations tab of the Cloud Console home page for recommendations to improve the security of your Cloud Run services.
デプロイされている Cloud Run サービスの設定を理解し、推奨するセキュリティ設定を教えてくれました。
おわりに
Gemini Cloud Assist でプロジェクトのコンテキストを踏まえた Cloud Run に関するやり取りができることがわかりました。Cloud Run の Gemini Cloud Assist で他にどのようなことができるかは以下をご参照ください。
設計
最適化
トラブルシュート