Skip to content

Commit 5d0eba7

Browse files
feat: add resources for account and resource owners profiles [ENG-5590] (#101)
[ENG-5590](https://stacklet.atlassian.net/browse/ENG-5590) ### what add resources for account and resource owner profiles ### why support configuring owner profiles through terraform ### testing tested in sandbox, added acceptance tests ### docs updated here [ENG-5590]: https://stacklet.atlassian.net/browse/ENG-5590?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
1 parent 336590c commit 5d0eba7

24 files changed

+2116
-20
lines changed
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "stacklet_configuration_profile_account_owners Resource - terraform-provider-stacklet"
4+
subcategory: ""
5+
description: |-
6+
Manage the account owners configuration profile.
7+
The profile is global, adding multiple resources of this kind will cause them to override each other.
8+
---
9+
10+
# stacklet_configuration_profile_account_owners (Resource)
11+
12+
Manage the account owners configuration profile.
13+
14+
The profile is global, adding multiple resources of this kind will cause them to override each other.
15+
16+
## Example Usage
17+
18+
```terraform
19+
resource "stacklet_configuration_profile_account_owners" "example" {
20+
tags = ["Owner", "AccountOwner"]
21+
default = [
22+
{
23+
account = "1111111111"
24+
owners = [
25+
26+
27+
]
28+
},
29+
{
30+
account = "2222222222"
31+
owners = [
32+
33+
34+
]
35+
},
36+
]
37+
}
38+
```
39+
40+
<!-- schema generated by tfplugindocs -->
41+
## Schema
42+
43+
### Optional
44+
45+
- `default` (Attributes List) List of default account owners. (see [below for nested schema](#nestedatt--default))
46+
- `org_domain` (String) The organization domain to append to users for matching.
47+
- `org_domain_tag` (String) The name of the tag to look up the organization domain.
48+
- `tags` (List of String) List of tag names to look up the resource owner.
49+
50+
### Read-Only
51+
52+
- `id` (String) The GraphQL Node ID of the configuration profile.
53+
- `profile` (String) The profile name.
54+
55+
<a id="nestedatt--default"></a>
56+
### Nested Schema for `default`
57+
58+
Required:
59+
60+
- `account` (String) The account identifier.
61+
- `owners` (List of String) List of owner addresses for this account.
62+
63+
## Import
64+
65+
Import is supported using the following syntax:
66+
67+
The [`terraform import` command](https://developer.hashicorp.com/terraform/cli/commands/import) can be used, for example:
68+
69+
```shell
70+
terraform import stacklet_configuration_profile_account_owners.example '' # the resource ID is ignored since it's global
71+
```
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "stacklet_configuration_profile_resource_owner Resource - terraform-provider-stacklet"
4+
subcategory: ""
5+
description: |-
6+
Manage the resource owner configuration profile.
7+
The profile is global, adding multiple resources of this kind will cause them to override each other.
8+
---
9+
10+
# stacklet_configuration_profile_resource_owner (Resource)
11+
12+
Manage the resource owner configuration profile.
13+
14+
The profile is global, adding multiple resources of this kind will cause them to override each other.
15+
16+
## Example Usage
17+
18+
```terraform
19+
resource "stacklet_configuration_profile_resource_owner" "example" {
20+
tags = ["Owner", "ResourceOwner"]
21+
default = [
22+
23+
24+
]
25+
}
26+
```
27+
28+
<!-- schema generated by tfplugindocs -->
29+
## Schema
30+
31+
### Optional
32+
33+
- `default` (List of String) List of default resource owners.
34+
- `org_domain` (String) The organization domain to append to users for matching.
35+
- `org_domain_tag` (String) The name of the tag to look up the organization domain.
36+
- `tags` (List of String) List of tag names to look up the resource owner.
37+
38+
### Read-Only
39+
40+
- `id` (String) The GraphQL Node ID of the configuration profile.
41+
- `profile` (String) The profile name.
42+
43+
## Import
44+
45+
Import is supported using the following syntax:
46+
47+
The [`terraform import` command](https://developer.hashicorp.com/terraform/cli/commands/import) can be used, for example:
48+
49+
```shell
50+
terraform import stacklet_configuration_profile_resource_owner.example '' # the resource ID is ignored since it's global
51+
```

docs/resources/report_group.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
page_title: "stacklet_report_group Resource - terraform-provider-stacklet"
44
subcategory: ""
55
description: |-
6-
Retrieve information about a notification report group by name.
6+
Manage a notification report group.
77
---
88

99
# stacklet_report_group (Resource)
1010

11-
Retrieve information about a notification report group by name.
11+
Manage a notification report group.
1212

1313
## Example Usage
1414

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
terraform import stacklet_configuration_profile_account_owners.example '' # the resource ID is ignored since it's global
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
resource "stacklet_configuration_profile_account_owners" "example" {
2+
tags = ["Owner", "AccountOwner"]
3+
default = [
4+
{
5+
account = "1111111111"
6+
owners = [
7+
8+
9+
]
10+
},
11+
{
12+
account = "2222222222"
13+
owners = [
14+
15+
16+
]
17+
},
18+
]
19+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
terraform import stacklet_configuration_profile_resource_owner.example '' # the resource ID is ignored since it's global
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
resource "stacklet_configuration_profile_resource_owner" "example" {
2+
tags = ["Owner", "ResourceOwner"]
3+
default = [
4+
5+
6+
]
7+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// Copyright (c) 2025 - Stacklet, Inc.
2+
3+
package acceptance_tests
4+
5+
import (
6+
"testing"
7+
8+
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
9+
)
10+
11+
func TestAccConfigurationProfileAccountOwnersDataSource(t *testing.T) {
12+
steps := []resource.TestStep{
13+
{
14+
Config: `
15+
resource "stacklet_configuration_profile_account_owners" "test" {
16+
default = [
17+
{
18+
account = "123456789012"
19+
20+
}
21+
]
22+
org_domain = "example.com"
23+
tags = ["owner", "team"]
24+
}
25+
26+
data "stacklet_configuration_profile_account_owners" "test" {
27+
depends_on = [stacklet_configuration_profile_account_owners.test]
28+
}
29+
`,
30+
Check: resource.ComposeAggregateTestCheckFunc(
31+
resource.TestCheckResourceAttrPair("stacklet_configuration_profile_account_owners.test", "id", "data.stacklet_configuration_profile_account_owners.test", "id"),
32+
resource.TestCheckResourceAttrPair("stacklet_configuration_profile_account_owners.test", "profile", "data.stacklet_configuration_profile_account_owners.test", "profile"),
33+
resource.TestCheckResourceAttr("data.stacklet_configuration_profile_account_owners.test", "default.#", "1"),
34+
resource.TestCheckResourceAttr("data.stacklet_configuration_profile_account_owners.test", "default.0.account", "123456789012"),
35+
resource.TestCheckResourceAttr("data.stacklet_configuration_profile_account_owners.test", "default.0.owners.#", "2"),
36+
resource.TestCheckResourceAttr("data.stacklet_configuration_profile_account_owners.test", "default.0.owners.0", "[email protected]"),
37+
resource.TestCheckResourceAttr("data.stacklet_configuration_profile_account_owners.test", "default.0.owners.1", "[email protected]"),
38+
resource.TestCheckResourceAttr("data.stacklet_configuration_profile_account_owners.test", "org_domain", "example.com"),
39+
resource.TestCheckResourceAttr("data.stacklet_configuration_profile_account_owners.test", "tags.#", "2"),
40+
resource.TestCheckResourceAttr("data.stacklet_configuration_profile_account_owners.test", "tags.0", "owner"),
41+
resource.TestCheckResourceAttr("data.stacklet_configuration_profile_account_owners.test", "tags.1", "team"),
42+
),
43+
},
44+
}
45+
runRecordedAccTest(t, "TestAccConfigurationProfileAccountOwnersDataSource", steps)
46+
}
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
// Copyright (c) 2025 - Stacklet, Inc.
2+
3+
package acceptance_tests
4+
5+
import (
6+
"testing"
7+
8+
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
9+
)
10+
11+
func TestAccConfigurationProfileAccountOwnersResource(t *testing.T) {
12+
steps := []resource.TestStep{
13+
// Minimal configuration
14+
{
15+
Config: `
16+
resource "stacklet_configuration_profile_account_owners" "test" {
17+
}
18+
`,
19+
Check: resource.ComposeAggregateTestCheckFunc(
20+
resource.TestCheckResourceAttrSet("stacklet_configuration_profile_account_owners.test", "id"),
21+
resource.TestCheckResourceAttrSet("stacklet_configuration_profile_account_owners.test", "profile"),
22+
resource.TestCheckResourceAttr("stacklet_configuration_profile_account_owners.test", "default.#", "0"),
23+
resource.TestCheckResourceAttr("stacklet_configuration_profile_account_owners.test", "tags.#", "0"),
24+
resource.TestCheckNoResourceAttr("stacklet_configuration_profile_account_owners.test", "org_domain"),
25+
resource.TestCheckNoResourceAttr("stacklet_configuration_profile_account_owners.test", "org_domain_tag"),
26+
),
27+
},
28+
// Full configuration
29+
{
30+
Config: `
31+
resource "stacklet_configuration_profile_account_owners" "test" {
32+
default = [
33+
{
34+
account = "123456789012"
35+
36+
}
37+
]
38+
org_domain = "example.com"
39+
org_domain_tag = "domain"
40+
tags = ["owner", "team"]
41+
}
42+
`,
43+
Check: resource.ComposeAggregateTestCheckFunc(
44+
resource.TestCheckResourceAttrSet("stacklet_configuration_profile_account_owners.test", "id"),
45+
resource.TestCheckResourceAttrSet("stacklet_configuration_profile_account_owners.test", "profile"),
46+
resource.TestCheckResourceAttr("stacklet_configuration_profile_account_owners.test", "default.#", "1"),
47+
resource.TestCheckResourceAttr("stacklet_configuration_profile_account_owners.test", "default.0.account", "123456789012"),
48+
resource.TestCheckResourceAttr("stacklet_configuration_profile_account_owners.test", "default.0.owners.#", "2"),
49+
resource.TestCheckResourceAttr("stacklet_configuration_profile_account_owners.test", "default.0.owners.0", "[email protected]"),
50+
resource.TestCheckResourceAttr("stacklet_configuration_profile_account_owners.test", "default.0.owners.1", "[email protected]"),
51+
resource.TestCheckResourceAttr("stacklet_configuration_profile_account_owners.test", "org_domain", "example.com"),
52+
resource.TestCheckResourceAttr("stacklet_configuration_profile_account_owners.test", "org_domain_tag", "domain"),
53+
resource.TestCheckResourceAttr("stacklet_configuration_profile_account_owners.test", "tags.#", "2"),
54+
resource.TestCheckResourceAttr("stacklet_configuration_profile_account_owners.test", "tags.0", "owner"),
55+
resource.TestCheckResourceAttr("stacklet_configuration_profile_account_owners.test", "tags.1", "team"),
56+
),
57+
},
58+
// ImportState testing
59+
{
60+
ResourceName: "stacklet_configuration_profile_account_owners.test",
61+
ImportState: true,
62+
ImportStateVerify: true,
63+
},
64+
// Update and Read testing
65+
{
66+
Config: `
67+
resource "stacklet_configuration_profile_account_owners" "test" {
68+
default = [
69+
{
70+
account = "123456789012"
71+
owners = ["[email protected]"]
72+
},
73+
{
74+
account = "210987654321"
75+
76+
}
77+
]
78+
org_domain = "updated.com"
79+
org_domain_tag = "domain_tag"
80+
tags = ["updated_owner", "updated_team", "department"]
81+
}
82+
`,
83+
Check: resource.ComposeAggregateTestCheckFunc(
84+
resource.TestCheckResourceAttr("stacklet_configuration_profile_account_owners.test", "default.#", "2"),
85+
resource.TestCheckResourceAttr("stacklet_configuration_profile_account_owners.test", "default.0.account", "123456789012"),
86+
resource.TestCheckResourceAttr("stacklet_configuration_profile_account_owners.test", "default.0.owners.#", "1"),
87+
resource.TestCheckResourceAttr("stacklet_configuration_profile_account_owners.test", "default.0.owners.0", "[email protected]"),
88+
resource.TestCheckResourceAttr("stacklet_configuration_profile_account_owners.test", "default.1.account", "210987654321"),
89+
resource.TestCheckResourceAttr("stacklet_configuration_profile_account_owners.test", "default.1.owners.#", "2"),
90+
resource.TestCheckResourceAttr("stacklet_configuration_profile_account_owners.test", "default.1.owners.0", "[email protected]"),
91+
resource.TestCheckResourceAttr("stacklet_configuration_profile_account_owners.test", "default.1.owners.1", "[email protected]"),
92+
resource.TestCheckResourceAttr("stacklet_configuration_profile_account_owners.test", "org_domain", "updated.com"),
93+
resource.TestCheckResourceAttr("stacklet_configuration_profile_account_owners.test", "org_domain_tag", "domain_tag"),
94+
resource.TestCheckResourceAttr("stacklet_configuration_profile_account_owners.test", "tags.#", "3"),
95+
resource.TestCheckResourceAttr("stacklet_configuration_profile_account_owners.test", "tags.0", "updated_owner"),
96+
resource.TestCheckResourceAttr("stacklet_configuration_profile_account_owners.test", "tags.1", "updated_team"),
97+
resource.TestCheckResourceAttr("stacklet_configuration_profile_account_owners.test", "tags.2", "department"),
98+
),
99+
},
100+
}
101+
runRecordedAccTest(t, "TestAccConfigurationProfileAccountOwnersResource", steps)
102+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// Copyright (c) 2025 - Stacklet, Inc.
2+
3+
package acceptance_tests
4+
5+
import (
6+
"testing"
7+
8+
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
9+
)
10+
11+
func TestAccConfigurationProfileResourceOwnerDataSource(t *testing.T) {
12+
steps := []resource.TestStep{
13+
{
14+
Config: `
15+
resource "stacklet_configuration_profile_resource_owner" "test" {
16+
17+
org_domain = "example.com"
18+
tags = ["owner", "team"]
19+
}
20+
21+
data "stacklet_configuration_profile_resource_owner" "test" {
22+
depends_on = [stacklet_configuration_profile_resource_owner.test]
23+
}
24+
`,
25+
Check: resource.ComposeAggregateTestCheckFunc(
26+
resource.TestCheckResourceAttrPair("stacklet_configuration_profile_resource_owner.test", "id", "data.stacklet_configuration_profile_resource_owner.test", "id"),
27+
resource.TestCheckResourceAttrPair("stacklet_configuration_profile_resource_owner.test", "profile", "data.stacklet_configuration_profile_resource_owner.test", "profile"),
28+
resource.TestCheckResourceAttr("data.stacklet_configuration_profile_resource_owner.test", "default.#", "2"),
29+
resource.TestCheckResourceAttr("data.stacklet_configuration_profile_resource_owner.test", "default.0", "[email protected]"),
30+
resource.TestCheckResourceAttr("data.stacklet_configuration_profile_resource_owner.test", "default.1", "[email protected]"),
31+
resource.TestCheckResourceAttr("data.stacklet_configuration_profile_resource_owner.test", "org_domain", "example.com"),
32+
resource.TestCheckResourceAttr("data.stacklet_configuration_profile_resource_owner.test", "tags.#", "2"),
33+
resource.TestCheckResourceAttr("data.stacklet_configuration_profile_resource_owner.test", "tags.0", "owner"),
34+
resource.TestCheckResourceAttr("data.stacklet_configuration_profile_resource_owner.test", "tags.1", "team"),
35+
),
36+
},
37+
}
38+
runRecordedAccTest(t, "TestAccConfigurationProfileResourceOwnerDataSource", steps)
39+
}

0 commit comments

Comments
 (0)