» alicloud_fc_service

Provides a Alicloud Function Compute Service resource. The resource is the base of launching Function and Trigger configuration. For information about Service and how to use it, see What is Function Compute.

» Example Usage

Basic Usage

variable "name" {
  default = "tf-testaccalicloudfcservice"

resource "alicloud_log_project" "foo" {
  name = "${var.name}"

resource "alicloud_log_store" "foo" {
  project = "${alicloud_log_project.foo.name}"
  name    = "${var.name}"

resource "alicloud_ram_role" "role" {
  name     = "${var.name}"
  document = <<DEFINITION
  "Statement": [
      "Action": "sts:AssumeRole",
      "Effect": "Allow",
      "Principal": {
        "Service": [
  "Version": "1"
  description = "this is a test"
  force = true

resource "alicloud_ram_role_policy_attachment" "attac" {
  role_name = "${alicloud_ram_role.role.name}"
  policy_name = "AliyunLogFullAccess"
  policy_type = "System"

resource "alicloud_fc_service" "foo" {
  name = "${var.name}"
  description = "tf unit test"
  role = "${alicloud_ram_role.role.arn}"
  depends_on = ["alicloud_ram_role_policy_attachment.attac"]

» Module Support

You can use to the existing fc module to create a service and a function quickly and then set several triggers for it.

» Argument Reference

The following arguments are supported:

  • name - (ForceNew) The Function Compute service name. It is the only in one Alicloud account and is conflict with "name_prefix".
  • name_prefix - (ForceNew) Setting a prefix to get a only name. It is conflict with "name".
  • description - (Optional) The function compute service description.
  • internet_access - (Optional) Whether to allow the service to access Internet. Default to "true".
  • role - (Optional) RAM role arn attached to the Function Compute service. This governs both who / what can invoke your Function, as well as what resources our Function has access to. See User Permissions for more details.
  • log_config - (Optional) Provide this to store your FC service logs. Fields documented below. See Create a Service.
  • vpc_config - (Optional) Provide this to allow your FC service to access your VPC. Fields documented below. See Function Compute Service in VPC.

log_config requires the following:

  • project - (Required) The project name of Logs service.
  • logstore - (Required) The log store name of Logs service.

vpc_config requires the following:

  • vswitch_ids - (Required) A list of vswitch IDs associated with the FC service.
  • security_group_id - (Required) A security group ID associated with the FC service.

» Attributes Reference

The following arguments are exported:

  • id - The ID of the FC service. The value is same as name.
  • service_id - The Function Compute service ID.
  • last_modified - The date this resource was last modified.

» Import

Function Compute Service can be imported using the id or name, e.g.

$ terraform import alicloud_fc_service.foo my-fc-service