Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resource/alicloud_fc_function: Adds new attribute function_arn #8089

Merged
merged 1 commit into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions alicloud/resource_alicloud_fc_function.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package alicloud
import (
"encoding/json"
"fmt"
"log"
"time"

"github.com/hashicorp/terraform-plugin-sdk/helper/validation"
Expand Down Expand Up @@ -107,6 +108,10 @@ func resourceAlicloudFCFunction() *schema.Resource {
Type: schema.TypeString,
Computed: true,
},
"function_arn": {
Type: schema.TypeString,
Computed: true,
},
"initializer": {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -278,6 +283,11 @@ func resourceAlicloudFCFunctionRead(d *schema.ResourceData, meta interface{}) er
d.Set("code_checksum", object.CodeChecksum)
d.Set("name", object.FunctionName)
d.Set("function_id", object.FunctionID)
if accountId, err := client.AccountId(); err != nil {
log.Print(WrapError(err))
} else {
d.Set("function_arn", fmt.Sprintf("acs:fc:%s:%s:services/%s.LATEST/functions/%s", client.RegionId, accountId, parts[0], parts[1]))
}
d.Set("description", object.Description)
d.Set("handler", object.Handler)
d.Set("memory_size", object.MemorySize)
Expand Down
30 changes: 23 additions & 7 deletions alicloud/resource_alicloud_fc_function_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,14 @@ func TestAccAlicloudFCFunction_basic(t *testing.T) {
rand := acctest.RandIntRange(10000, 999999)
name := fmt.Sprintf("tf-testaccalicloudfcfunction-%d", rand)
var basicMap = map[string]string{
"service": CHECKSET,
"name": name,
"runtime": "nodejs12",
"description": "tf",
"handler": "hello.handler",
"oss_bucket": CHECKSET,
"oss_key": CHECKSET,
"service": CHECKSET,
"name": name,
"runtime": "nodejs12",
"description": "tf",
"handler": "hello.handler",
"oss_bucket": CHECKSET,
"oss_key": CHECKSET,
"function_arn": CHECKSET,
}
resourceId := "alicloud_fc_function.default"
ra := resourceAttrInit(resourceId, basicMap)
Expand Down Expand Up @@ -444,6 +445,11 @@ output "container_args" {
resource "alicloud_log_project" "default" {
name = "${var.name}"
description = "tf unit test"
lifecycle {
ignore_changes = [
policy
]
}
}

resource "alicloud_log_store" "default" {
Expand Down Expand Up @@ -561,6 +567,11 @@ php server.php`)
resource "alicloud_log_project" "default" {
name = "${var.name}"
description = "tf unit test"
lifecycle {
ignore_changes = [
policy
]
}
}

resource "alicloud_log_store" "default" {
Expand Down Expand Up @@ -673,6 +684,11 @@ func TestAccAlicloudFCFunction_code_checksum(t *testing.T) {
resource "alicloud_log_project" "default" {
name = "${var.name}"
description = "tf unit test"
lifecycle {
ignore_changes = [
policy
]
}
}

resource "alicloud_log_store" "default" {
Expand Down
5 changes: 3 additions & 2 deletions website/docs/r/fc_function.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,10 @@ The custom_container_config following arguments:

The following arguments are exported:

* `id` - The ID of the function. The value is formate as `<service>:<name>`.
* `id` - The ID of the function. It formats as `<service>:<name>`.
* `last_modified` - The date this resource was last modified.
* `function_id` - The Function Compute service ID.
* `function_id` - The Function Compute service function ID.
* `function_arn` - The Function Compute service function arn. It formats as `acs:fc:<region>:<uid>:services/<serviceName>.LATEST/functions/<functionName>`.

## Import

Expand Down
Loading