Deze pagina is nog niet beschikbaar in uw eigen taal. We werken er hard aan om meer taalversies toe te voegen. Bedankt voor uw steun.

On this page

Show all

Writing a Function Resource Script

Updated on 2024-02-01 GMT+08:00

Huawei Cloud has registered with Terraform as a provider. You can mount your functions to the provider as resources. For details, see https://registry.terraform.io/providers/huaweicloud/huaweicloud/latest/docs/resources/fgs_function.

The following is an example.

Create a main.tf file on the server, copy the following script to the file, and save it.

terraform {
  required_providers {
    huaweicloud = {
      source  = "huaweicloud/huaweicloud"
      version = ">= 1.40.0"
    }
  }
}
 
provider "huaweicloud" {
region = "cn-east-3" # Actual region
access_key = "*******" # Obtained key
secret_key = "*******" # Obtained key
}
 
resource "huaweicloud_fgs_function" "fgs_function" {
  name        = "test_func_rf"
  app         = "default"
  agency      = "function-admin"
  description = "function test"
  handler     = "index.handler"
  memory_size = 128
  timeout     = 3
  runtime     = "Python3.6"
  code_type   = "inline"
  func_code   = "aW1wb3J0IGpzb24KZGVmIGhhbmRsZXIgKGV2ZW50LCBjb250ZXh0KToKICAgIG91dHB1dCA9ICdIZWxsbyBtZXNzYWdlOiAnICsganNvbi5kdW1wcyhldmVudCkKICAgIHJldHVybiBvdXRwdXQ="
}

Replace access_key and secret_key with the AK/SK generated in Obtaining an Access Key.

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback