diff --git a/docs/resources/fgs_dependency_version.md b/docs/resources/fgs_dependency_version.md index a858703d205..88ef7e4ff9d 100644 --- a/docs/resources/fgs_dependency_version.md +++ b/docs/resources/fgs_dependency_version.md @@ -102,3 +102,21 @@ Or using related dependency package `name` and the `version` number, separated b ```bash $ terraform import huaweicloud_fgs_dependency_version.test / ``` + +Note that the imported state may not be identical to your resource definition, due to some attributes missing from the +API response, security or some other reason. The missing attributes include: `link`. +It is generally recommended running `terraform plan` after importing a dependency package. +You can then decide if changes should be applied to the resource, or the resource definition should be updated to +align with the dependency package. Also you can ignore changes as below. + +```hcl +resource "huaweicloud_fgs_dependency_version" "test" { + ... + + lifecycle { + ignore_changes = [ + link, + ] + } +} +``` diff --git a/huaweicloud/services/acceptance/fgs/resource_huaweicloud_fgs_dependency_version_test.go b/huaweicloud/services/acceptance/fgs/resource_huaweicloud_fgs_dependency_version_test.go index 613027d7c48..65945c26e9e 100644 --- a/huaweicloud/services/acceptance/fgs/resource_huaweicloud_fgs_dependency_version_test.go +++ b/huaweicloud/services/acceptance/fgs/resource_huaweicloud_fgs_dependency_version_test.go @@ -62,6 +62,9 @@ func TestAccDependencyVersion_basic(t *testing.T) { ResourceName: resourceName, ImportState: true, ImportStateVerify: true, + ImportStateVerifyIgnore: []string{ + "link", + }, }, // Test the ID format: / { @@ -69,6 +72,9 @@ func TestAccDependencyVersion_basic(t *testing.T) { ImportState: true, ImportStateVerify: true, ImportStateIdFunc: testAccDependencyVersionImportStateFunc_withDependName(resourceName), + ImportStateVerifyIgnore: []string{ + "link", + }, }, // Test the ID format: / { @@ -76,6 +82,9 @@ func TestAccDependencyVersion_basic(t *testing.T) { ImportState: true, ImportStateVerify: true, ImportStateIdFunc: testAccDependencyVersionImportStateFunc_withVersionId(resourceName), + ImportStateVerifyIgnore: []string{ + "link", + }, }, }, }) diff --git a/huaweicloud/services/fgs/resource_huaweicloud_fgs_dependency_version.go b/huaweicloud/services/fgs/resource_huaweicloud_fgs_dependency_version.go index 725e912d111..30afe74c9ed 100644 --- a/huaweicloud/services/fgs/resource_huaweicloud_fgs_dependency_version.go +++ b/huaweicloud/services/fgs/resource_huaweicloud_fgs_dependency_version.go @@ -157,11 +157,14 @@ func resourceDependencyVersionRead(_ context.Context, d *schema.ResourceData, me return common.CheckDeletedDiag(d, err, "FunctionGraph dependency version") } + // FunctionGraph will store the compressed package content pointed to by the link into the storage bucket provided + // by FunctionGraph and return a new link. + // If the ReadContext is set this value according to the query result, ForceNew behavior will be triggered the next + // time it is applied. mErr := multierror.Append( d.Set("runtime", resp.Runtime), d.Set("name", resp.Name), d.Set("description", resp.Description), - d.Set("link", resp.Link), d.Set("etag", resp.Etag), d.Set("size", resp.Size), d.Set("owner", resp.Owner),