简体   繁体   English

从 Google Cloud Function 修改 Google Cloud 项目资源

[英]Modify Google Cloud Project resources from a Google Cloud Function

For instance, I want to run the following gcloud CLI command,例如,我想运行以下 gcloud CLI 命令,

gcloud run services delete [SERVICE]

But, from a triggered Google Cloud Function.但是,来自触发的 Google Cloud Function。

PS附言
I've looked in a few places and have found a few similar things,找了好几个地方,也发现了一些类似的东西

But, I find them a bit tricky to follow and/or replicate.但是,我发现它们有点难以遵循和/或复制。

Any help appreciated!任何帮助表示赞赏! Thanks in advanced!先谢谢了!

The Google Cloud CLI is a Python program. Google Cloud CLI 是一个 Python 程序。 That means a lot of dependencies and a requirement for a shell and OS environment.这意味着对 shell 和操作系统环境的大量依赖和要求。 Cloud Functions does not provide either. Cloud Functions 也不提供。

A better option for running the CLI is Cloud Run.运行 CLI 的更好选择是 Cloud Run。 This provides the additional benefit of being able to test the Cloud Run container locally.这提供了能够在本地测试 Cloud Run 容器的额外好处。 You will need to wrap the CLI with an HTTP server responding to HTTP requests which then execute the CLI.您需要使用响应 HTTP 请求的 HTTP 服务器包装 CLI,然后执行 CLI。

However, most CLI commands can be easily duplicated with the Python SDKs and/or direct REST API calls which are supported by Cloud Functions.但是,大多数 CLI 命令可以通过 Cloud Functions 支持的 Python SDK 和/或直接 REST API 调用轻松复制。 This will require a solid understanding of the services, APIs, and language.这需要对服务、API 和语言有深入的了解。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM