使用 FailurePolicy 将“gcloud beta functions deploy”命令转换为 Deployment Manager 模板
Turn `gcloud beta functions deploy` command into a Deployment Manager template with a FailurePolicy
我是运行这个命令:
gcloud beta functions deploy myfunc \
--entry-point handler \
--project my-project \
--runtime python37 \
--trigger-resource 'gs://my-bucket' \
--trigger-event google.storage.object.finalize
如何在 Jinja 模板中指定 xxx 和 xxx?看起来我必须在模板中使用 EventTrigger,但我不确定它的格式如何?
resources:
- name: resource-name
type: 'gcp-types/cloudfunctions-v1:projects.locations.functions'
properties:
function: test
parent: projects/my-project/locations/us-central1
location: us-central1
sourceArchiveUrl: 'gs://my-project-bucket/sdfsd.zip'
runtime: python37
entryPoint: handler
maxInstances: 10
timeout: 30s
availableMemoryMb: 64
eventTrigger: ????
是否有包含 FailurePolicy 的 YAML 中指定的 EventTrigger 的完整示例?
文档没有说得很清楚:https://cloud.google.com/functions/docs/reference/rest/v1/projects.locations.functions#FailurePolicy
不确定这在 yaml 模板中应该是什么样子:
这适用于在 Jinja 中设置 failurePolicy:
...
eventTrigger:
...
failurePolicy:
retry: {}
非常不稳定,但要禁用您只是不指定它:
{% if properties['failurePolicy'] %}
failurePolicy:
retry: {}
{% endif %}
部署管理器有一些 specific examples on Github。这是一个 eventTrigger
与 Cloud Pub/Sub:
的示例
eventTrigger:
resource: $(ref.my-topic.name)
eventType: providers/cloud.pubsub/eventTypes/topic.publish
对于 FailurePolicy,我会尝试添加:
eventTrigger:
...
failurePolicy:
retry: true
参考:
我是运行这个命令:
gcloud beta functions deploy myfunc \
--entry-point handler \
--project my-project \
--runtime python37 \
--trigger-resource 'gs://my-bucket' \
--trigger-event google.storage.object.finalize
如何在 Jinja 模板中指定 xxx 和 xxx?看起来我必须在模板中使用 EventTrigger,但我不确定它的格式如何?
resources:
- name: resource-name
type: 'gcp-types/cloudfunctions-v1:projects.locations.functions'
properties:
function: test
parent: projects/my-project/locations/us-central1
location: us-central1
sourceArchiveUrl: 'gs://my-project-bucket/sdfsd.zip'
runtime: python37
entryPoint: handler
maxInstances: 10
timeout: 30s
availableMemoryMb: 64
eventTrigger: ????
是否有包含 FailurePolicy 的 YAML 中指定的 EventTrigger 的完整示例?
文档没有说得很清楚:https://cloud.google.com/functions/docs/reference/rest/v1/projects.locations.functions#FailurePolicy
不确定这在 yaml 模板中应该是什么样子:
这适用于在 Jinja 中设置 failurePolicy:
...
eventTrigger:
...
failurePolicy:
retry: {}
非常不稳定,但要禁用您只是不指定它:
{% if properties['failurePolicy'] %}
failurePolicy:
retry: {}
{% endif %}
部署管理器有一些 specific examples on Github。这是一个 eventTrigger
与 Cloud Pub/Sub:
eventTrigger:
resource: $(ref.my-topic.name)
eventType: providers/cloud.pubsub/eventTypes/topic.publish
对于 FailurePolicy,我会尝试添加:
eventTrigger:
...
failurePolicy:
retry: true
参考: