【问题标题】:IBM Cloud Functions: How to create secured web action using TerraformIBM Cloud Functions:如何使用 Terraform 创建安全的 Web 操作
【发布时间】:2023-03-08 22:29:01
【问题描述】:

我可以create a new IBM Cloud Functions action using the Terraform provider

resource "ibm_function_action" "sendEmail" {
  name      = "${ibm_function_package.cloudmailer.name}/sendEmail"
  namespace = ibm_function_namespace.namespace.name

  exec {
    kind = "nodejs:12"
    code = file("smtp_email.js")
  }
  publish = true
  user_defined_parameters = var.server_config
}

如何将上述操作变成web action?如何指定密码保护的配置?

【问题讨论】:

    标签: terraform ibm-cloud openwhisk ibm-cloud-functions terraform-provider-ibm


    【解决方案1】:

    这可以使用annotations argument 来实现。它拥有这些documented action annotations 的键/值对。

    resource "ibm_function_action" "sendEmail" {
      name      = "${ibm_function_package.cloudmailer.name}/sendEmail"
      namespace = ibm_function_namespace.namespace.name
    
      exec {
        kind = "nodejs:12"
        code = file("smtp_email.js")
      }
      publish = true
      user_defined_parameters = var.server_config
      user_defined_annotations =  <<EOF
        [
          {
            "key": "web-export",
            "value": true
          },
          {
            "key": "require-whisk-auth",
            "value": "your-web-secret"
          }
        ]
    EOF
    
    }
    

    上面的 web-export 将操作转换为 Web 操作,require-whisk-auth 启用身份验证以确保安全,其值设置密码。我已经把它变成了working sample

    【讨论】:

      猜你喜欢
      • 2021-12-18
      • 2021-02-06
      • 2017-09-17
      • 2019-09-06
      • 1970-01-01
      • 2019-04-27
      • 2021-05-18
      • 2020-12-12
      • 1970-01-01
      相关资源
      最近更新 更多