diff --git a/.changelog/1028.txt b/.changelog/1028.txt new file mode 100644 index 000000000..5c75966e0 --- /dev/null +++ b/.changelog/1028.txt @@ -0,0 +1,3 @@ +```release-note:fix +harness_platform_policy: Fixed the import logic. +``` diff --git a/docs/resources/platform_policy.md b/docs/resources/platform_policy.md index 09bcf2d82..6b9d5e078 100644 --- a/docs/resources/platform_policy.md +++ b/docs/resources/platform_policy.md @@ -86,6 +86,10 @@ REGO Import is supported using the following syntax: ```shell -# Import using the organization id -terraform import harness_platform_policy.example +# Import account level policy +terraform import harness_platform_policy.example +# Import org level policy +terraform import harness_platform_policy.example / +# Import proj level policy +terraform import harness_platform_policy.example // ``` diff --git a/internal/service/platform/policy/resource_policy.go b/internal/service/platform/policy/resource_policy.go index b852f4664..f64fb2982 100644 --- a/internal/service/platform/policy/resource_policy.go +++ b/internal/service/platform/policy/resource_policy.go @@ -20,7 +20,7 @@ func ResourcePolicy() *schema.Resource { UpdateContext: resourcePolicyCreateOrUpdate, DeleteContext: resourcePolicyDelete, CreateContext: resourcePolicyCreateOrUpdate, - Importer: helpers.OrgResourceImporter, + Importer: helpers.MultiLevelResourceImporter, Schema: map[string]*schema.Schema{ "name": { diff --git a/internal/service/platform/policy/resource_policy_test.go b/internal/service/platform/policy/resource_policy_test.go index 9b94c2d59..9677bb83d 100644 --- a/internal/service/platform/policy/resource_policy_test.go +++ b/internal/service/platform/policy/resource_policy_test.go @@ -80,6 +80,13 @@ func TestAccResourcePolicy(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "rego", updatedRego), ), }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + ImportStateIdFunc: acctest.ProjectResourceImportStateIdFunc(resourceName), + ImportStateVerifyIgnore: []string{"description", "git_base_branch", "git_branch", "git_commit_msg", "git_import", "git_is_new_branch"}, + }, }, }) }