Writing a Function Resource Script
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
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.