【问题标题】:how to initially we can invoke cloud function from deployment manager?最初我们如何从部署管理器调用云功能?
【发布时间】:2022-07-01 18:54:54
【问题描述】:

问题 1. 我正在尝试通过云部署管理器创建云功能。部署后,该函数最初无法调用。测试或点击 URL 后,函数正在调用。

Deployment.jinja

{% set deployment_name =  env["deployment"]  %}
{% set project = env['project']  %}
{% set region = "us-central1" %}

resources:
- type: storage.v1.bucket
  name: {{ deployment_name }}
  properties:
    project: {{ project }}
- name: CloudFunction
  type:  gcp-types/cloudfunctions-v1:projects.locations.functions
  properties:
    parent: projects/{{ project }}/locations/us-central1
    function: {{ deployment_name }}
    entryPoint: handler
    timeout: 60s
    availableMemoryMb: 256
    runtime: python39
    location: {{ region }}
    sourceArchiveUrl: gs://bucket/archive.zip
    httpsTrigger:
      url: https://{{ region }}-{{ project }}.cloudfunctions.net/{{ deployment_name }}
    environmentVariables:
      BUCKET: {{ deployment_name }}
      FUNCTION_REGION: {{ region }}
      PROJECT: {{ project }}

问题 2. 我们可以调用基于 CreateFunction 或 DeleteFunction 的函数吗? 同样,我们如何在 AWS lambda 中调用 requestType=Create 和 requestType=Delete。

堆栈驱动程序日志 Ex: methodName: google.cloud.functions.v1.CloudFunctionsService.DeleteFunction and methodName: google.cloud.functions.v1.CloudFunctionsService.CreateFunction

simmillar like this:
def hello_world(request):
    if request['methodName']=="DeleteFunction":
       print("delete bucket")
    if request['methodName']=="CreateFunction":
       print("create bucket")
    

【问题讨论】:

    标签: google-cloud-platform google-cloud-functions jinja2 python-3.7 google-deployment-manager


    【解决方案1】:

    根据本文档:https://cloud.google.com/functions/docs/reference/rest/v1/projects.locations.functions/call

    - name: function-call
      type: gcp-types/cloudfunctions-v1:cloudfunctions.projects.locations.functions.call
      properties:
        name: "$(ref.CloudFunction.name)"
        data: '{"test":"test"}'
    
    

    【讨论】:

      猜你喜欢
      • 2019-10-27
      • 1970-01-01
      • 2020-11-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-06-26
      • 2019-10-09
      • 2018-12-29
      相关资源
      最近更新 更多