Skip to content

Commit

Permalink
Fix: [PIPE-21769]: Import Policies to Terraform fix (#1067)
Browse files Browse the repository at this point in the history
* Updated Policy Import Logic for TF Resource

* ChangeLogUodate
  • Loading branch information
sameed-haq authored Sep 19, 2024
1 parent 7570cf7 commit c6f296f
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .changelog/1028.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:fix
harness_platform_policy: Fixed the import logic.
```
8 changes: 6 additions & 2 deletions docs/resources/platform_policy.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ REGO
Import is supported using the following syntax:

```shell
# Import using the organization id
terraform import harness_platform_policy.example <organization_id>
# Import account level policy
terraform import harness_platform_policy.example <policy_id>
# Import org level policy
terraform import harness_platform_policy.example <org_id>/<policy_id>
# Import proj level policy
terraform import harness_platform_policy.example <org_id>/<project_id>/<policy_id>
```
2 changes: 1 addition & 1 deletion internal/service/platform/policy/resource_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
7 changes: 7 additions & 0 deletions internal/service/platform/policy/resource_policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
},
},
})
}
Expand Down

0 comments on commit c6f296f

Please sign in to comment.