Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit e70d98c

Browse files
committedNov 8, 2023
feat: add iam_resourcegroup data and resources
1 parent b401207 commit e70d98c

11 files changed

+668
-14
lines changed
 

Diff for: ‎ovh/data_iam_resource_group.go

+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
package ovh
2+
3+
import (
4+
"context"
5+
"fmt"
6+
"net/url"
7+
8+
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
9+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
10+
)
11+
12+
func dataSourceIamResourceGroup() *schema.Resource {
13+
return &schema.Resource{
14+
Schema: map[string]*schema.Schema{
15+
"id": {
16+
Type: schema.TypeString,
17+
Required: true,
18+
},
19+
"name": {
20+
Type: schema.TypeString,
21+
Computed: true,
22+
},
23+
"resources": {
24+
Type: schema.TypeSet,
25+
Computed: true,
26+
Elem: &schema.Schema{
27+
Type: schema.TypeString,
28+
},
29+
},
30+
"owner": {
31+
Type: schema.TypeString,
32+
Computed: true,
33+
},
34+
"created_at": {
35+
Type: schema.TypeString,
36+
Computed: true,
37+
},
38+
"updated_at": {
39+
Type: schema.TypeString,
40+
Computed: true,
41+
},
42+
"read_only": {
43+
Type: schema.TypeBool,
44+
Computed: true,
45+
},
46+
"urn": {
47+
Type: schema.TypeString,
48+
Computed: true,
49+
},
50+
},
51+
ReadContext: datasourceIamResourceGroupRead,
52+
}
53+
}
54+
55+
func datasourceIamResourceGroupRead(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics {
56+
config := meta.(*Config)
57+
id := d.Get("id").(string)
58+
59+
var pol IamResourceGroup
60+
err := config.OVHClient.GetWithContext(ctx, fmt.Sprintf("/v2/iam/resourceGroup/%s?details=true", url.PathEscape(id)), &pol)
61+
if err != nil {
62+
return diag.FromErr(err)
63+
}
64+
65+
d.SetId(id)
66+
67+
var urns []string
68+
for _, r := range pol.Resources {
69+
urns = append(urns, r.URN)
70+
}
71+
72+
d.Set("resources", urns)
73+
d.Set("name", pol.Name)
74+
d.Set("owner", pol.Owner)
75+
d.Set("created_at", pol.CreatedAt)
76+
d.Set("updated_at", pol.UpdatedAt)
77+
d.Set("read_only", pol.ReadOnly)
78+
d.Set("urn", pol.URN)
79+
80+
return nil
81+
}

Diff for: ‎ovh/data_iam_resource_group_test.go

+146
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
package ovh
2+
3+
import (
4+
"fmt"
5+
"os"
6+
"testing"
7+
8+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
9+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
10+
)
11+
12+
func TestAccIamResourceGroupDataSource_basic(t *testing.T) {
13+
resourceGroupName1 := acctest.RandomWithPrefix(test_prefix)
14+
resourceGroupName2 := acctest.RandomWithPrefix(test_prefix)
15+
16+
resource1 := "urn:v1:eu:resource:vrack:" + os.Getenv("OVH_VRACK_SERVICE_TEST")
17+
resource2 := "urn:v1:eu:resource:vps:" + os.Getenv("OVH_VPS")
18+
19+
preSetup := fmt.Sprintf(
20+
testAccIamResourceGroupDatasourceConfigInit,
21+
resourceGroupName1,
22+
resource1,
23+
resourceGroupName2,
24+
resource1,
25+
resource2,
26+
)
27+
28+
dataConfig := fmt.Sprintf(
29+
testAccIamResourceGroupDatasourceConfigData,
30+
resourceGroupName1,
31+
resource1,
32+
resourceGroupName2,
33+
resource1,
34+
resource2,
35+
)
36+
37+
config := fmt.Sprintf(
38+
testAccIamResourceGroupDatasourceConfigList,
39+
resourceGroupName1,
40+
resource1,
41+
resourceGroupName2,
42+
resource1,
43+
resource2,
44+
)
45+
46+
checks := append(
47+
checkIamResourceGroupResourceAttr("ovh_iam_resource_group.resource_group_1", resourceGroupName1, resource1),
48+
checkIamResourceGroupResourceAttr("ovh_iam_resource_group.resource_group_2", resourceGroupName2, resource1, resource2)...,
49+
)
50+
51+
checksData := append(
52+
checkIamResourceGroupResourceAttr("data.ovh_iam_resource_group.resource_group_1", resourceGroupName1, resource1),
53+
checkIamResourceGroupResourceAttr("data.ovh_iam_resource_group.resource_group_2", resourceGroupName2, resource1, resource2)...,
54+
)
55+
56+
resource.Test(t, resource.TestCase{
57+
PreCheck: func() {
58+
testAccPreCheckIamResourceGroup(t)
59+
},
60+
Providers: testAccProviders,
61+
Steps: []resource.TestStep{
62+
{
63+
Config: preSetup,
64+
Check: resource.ComposeTestCheckFunc(checks...),
65+
}, {
66+
Config: dataConfig,
67+
Check: resource.ComposeTestCheckFunc(checksData...),
68+
}, {
69+
Config: config,
70+
Check: resource.ComposeTestCheckFunc(
71+
resource.TestCheckOutput("keys_present", "true"),
72+
),
73+
},
74+
},
75+
})
76+
}
77+
78+
func checkIamResourceGroupResourceAttr(name, grpName string, resourceURNs ...string) []resource.TestCheckFunc {
79+
checks := []resource.TestCheckFunc{
80+
resource.TestCheckResourceAttr(name, "name", grpName),
81+
}
82+
for _, urn := range resourceURNs {
83+
checks = append(checks,
84+
resource.TestCheckTypeSetElemAttr(name, "resources.*", urn),
85+
)
86+
}
87+
return checks
88+
}
89+
90+
const testAccIamResourceGroupDatasourceConfigInit = `
91+
resource "ovh_iam_resource_group" "resource_group_1" {
92+
name = "%s"
93+
resources = ["%s"]
94+
}
95+
96+
resource "ovh_iam_resource_group" "resource_group_2" {
97+
name = "%s"
98+
resources = ["%s", "%s"]
99+
}
100+
`
101+
102+
const testAccIamResourceGroupDatasourceConfigData = `
103+
resource "ovh_iam_resource_group" "resource_group_1" {
104+
name = "%s"
105+
resources = ["%s"]
106+
}
107+
108+
resource "ovh_iam_resource_group" "resource_group_2" {
109+
name = "%s"
110+
resources = ["%s", "%s"]
111+
}
112+
113+
data "ovh_iam_resource_group" "resource_group_1" {
114+
id = ovh_iam_resource_group.resource_group_1.id
115+
}
116+
117+
data "ovh_iam_resource_group" "resource_group_2" {
118+
id = ovh_iam_resource_group.resource_group_2.id
119+
}
120+
`
121+
122+
const testAccIamResourceGroupDatasourceConfigList = `
123+
resource "ovh_iam_resource_group" "resource_group_1" {
124+
name = "%s"
125+
resources = ["%s"]
126+
}
127+
128+
resource "ovh_iam_resource_group" "resource_group_2" {
129+
name = "%s"
130+
resources = ["%s", "%s"]
131+
}
132+
133+
data "ovh_iam_resource_group" "data_resource_group_1" {
134+
id = ovh_iam_resource_group.resource_group_1.id
135+
}
136+
137+
138+
data "ovh_iam_resource_groups" "resource_groups" {}
139+
140+
output "keys_present" {
141+
value = tostring(
142+
contains(data.ovh_iam_resource_groups.resource_groups.resource_groups, ovh_iam_resource_group.resource_group_1.id) &&
143+
contains(data.ovh_iam_resource_groups.resource_groups.resource_groups, ovh_iam_resource_group.resource_group_2.id)
144+
)
145+
}
146+
`

Diff for: ‎ovh/data_iam_resource_groups.go

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package ovh
2+
3+
import (
4+
"context"
5+
6+
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
7+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
8+
"github.com/ovh/terraform-provider-ovh/ovh/helpers/hashcode"
9+
)
10+
11+
func dataSourceIamResourceGroups() *schema.Resource {
12+
return &schema.Resource{
13+
Schema: map[string]*schema.Schema{
14+
"resource_groups": {
15+
Type: schema.TypeSet,
16+
Elem: &schema.Schema{Type: schema.TypeString},
17+
Computed: true,
18+
},
19+
},
20+
ReadContext: datasourceIamResourceGroupsRead,
21+
}
22+
}
23+
24+
func datasourceIamResourceGroupsRead(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics {
25+
config := meta.(*Config)
26+
27+
var groups []IamResourceGroup
28+
err := config.OVHClient.GetWithContext(ctx, "/v2/iam/resourceGroup?details=true", &groups)
29+
if err != nil {
30+
return diag.FromErr(err)
31+
}
32+
33+
var grpsId []string
34+
for _, grp := range groups {
35+
grpsId = append(grpsId, grp.ID)
36+
}
37+
38+
d.SetId(hashcode.Strings(grpsId))
39+
d.Set("resource_groups", grpsId)
40+
return nil
41+
}

Diff for: ‎ovh/provider.go

+3
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ func Provider() *schema.Provider {
113113
"ovh_iam_policy": dataSourceIamPolicy(),
114114
"ovh_iam_reference_actions": dataSourceIamReferenceActions(),
115115
"ovh_iam_reference_resource_type": dataSourceIamReferenceResourceType(),
116+
"ovh_iam_resource_group": dataSourceIamResourceGroup(),
117+
"ovh_iam_resource_groups": dataSourceIamResourceGroups(),
116118
"ovh_ip_service": dataSourceIpService(),
117119
"ovh_iploadbalancing": dataSourceIpLoadbalancing(),
118120
"ovh_iploadbalancing_vrack_network": dataSourceIpLoadbalancingVrackNetwork(),
@@ -192,6 +194,7 @@ func Provider() *schema.Provider {
192194
"ovh_hosting_privatedatabase_user_grant": resourceHostingPrivateDatabaseUserGrant(),
193195
"ovh_hosting_privatedatabase_whitelist": resourceHostingPrivateDatabaseWhitelist(),
194196
"ovh_iam_policy": resourceIamPolicy(),
197+
"ovh_iam_resource_group": resourceIamResourceGroup(),
195198
"ovh_ip_reverse": resourceIpReverse(),
196199
"ovh_ip_service": resourceIpService(),
197200
"ovh_iploadbalancing": resourceIpLoadbalancing(),

Diff for: ‎ovh/provider_test.go

+6
Original file line numberDiff line numberDiff line change
@@ -373,3 +373,9 @@ func testAccPreCheckWorkflowBackup(t *testing.T) {
373373
func testAccPreCheckDedicatedServerNetworking(t *testing.T) {
374374
checkEnvOrSkip(t, "TEST_DEDICATED_SERVER_NETWORKING")
375375
}
376+
377+
func testAccPreCheckIamResourceGroup(t *testing.T) {
378+
testAccPreCheckCredentials(t)
379+
checkEnvOrSkip(t, "OVH_VRACK_SERVICE_TEST")
380+
checkEnvOrSkip(t, "OVH_VPS")
381+
}

Diff for: ‎ovh/resource_iam_resource_group.go

+153
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
package ovh
2+
3+
import (
4+
"context"
5+
"fmt"
6+
"net/url"
7+
8+
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
9+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
10+
)
11+
12+
func resourceIamResourceGroup() *schema.Resource {
13+
return &schema.Resource{
14+
Schema: map[string]*schema.Schema{
15+
"name": {
16+
Type: schema.TypeString,
17+
Required: true,
18+
},
19+
"resources": {
20+
Type: schema.TypeSet,
21+
Optional: true,
22+
Elem: &schema.Schema{
23+
Type: schema.TypeString,
24+
},
25+
},
26+
"owner": {
27+
Type: schema.TypeString,
28+
Computed: true,
29+
},
30+
"created_at": {
31+
Type: schema.TypeString,
32+
Computed: true,
33+
},
34+
"updated_at": {
35+
Type: schema.TypeString,
36+
Computed: true,
37+
},
38+
"read_only": {
39+
Type: schema.TypeBool,
40+
Computed: true,
41+
},
42+
"urn": {
43+
Type: schema.TypeString,
44+
Computed: true,
45+
},
46+
},
47+
Importer: &schema.ResourceImporter{
48+
StateContext: func(ctx context.Context, rd *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) {
49+
// Before importing, check that the resource group is not read-only.
50+
config := meta.(*Config)
51+
id := rd.Id()
52+
53+
var pol IamResourceGroup
54+
err := config.OVHClient.GetWithContext(ctx, fmt.Sprintf("/v2/iam/resourceGroup/%s?details=true", url.PathEscape(id)), &pol)
55+
if err != nil {
56+
return nil, err
57+
}
58+
59+
if pol.ReadOnly {
60+
return nil, fmt.Errorf("resource_group '%s' is read-only", id)
61+
}
62+
63+
return []*schema.ResourceData{rd}, nil
64+
},
65+
},
66+
ReadContext: resourceIamResourceGroupRead,
67+
CreateContext: resourceIamResourceGroupCreate,
68+
UpdateContext: resourceIamResourceGroupUpdate,
69+
DeleteContext: resourceIamResourceGroupDelete,
70+
}
71+
}
72+
73+
func resourceIamResourceGroupRead(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics {
74+
config := meta.(*Config)
75+
id := d.Id()
76+
77+
var pol IamResourceGroup
78+
err := config.OVHClient.GetWithContext(ctx, fmt.Sprintf("/v2/iam/resourceGroup/%s?details=true", url.PathEscape(id)), &pol)
79+
if err != nil {
80+
return diag.FromErr(err)
81+
}
82+
83+
var urns []string
84+
for _, r := range pol.Resources {
85+
urns = append(urns, r.URN)
86+
}
87+
d.Set("resources", urns)
88+
89+
d.Set("name", pol.Name)
90+
d.Set("owner", pol.Owner)
91+
d.Set("created_at", pol.CreatedAt)
92+
d.Set("updated_at", pol.UpdatedAt)
93+
d.Set("read_only", pol.ReadOnly)
94+
d.Set("urn", pol.URN)
95+
96+
return nil
97+
}
98+
99+
func resourceIamResourceGroupCreate(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics {
100+
config := meta.(*Config)
101+
102+
var grp IamResourceGroup
103+
104+
grp.Name = d.Get("name").(string)
105+
urns := d.Get("resources").(*schema.Set)
106+
for _, r := range urns.List() {
107+
urn := r.(string)
108+
grp.Resources = append(grp.Resources, IamResourceDetails{URN: urn})
109+
}
110+
111+
var grpOut IamResourceGroup
112+
err := config.OVHClient.PostWithContext(ctx, "/v2/iam/resourceGroup", grp, &grpOut)
113+
if err != nil {
114+
return diag.FromErr(err)
115+
}
116+
117+
d.SetId(grpOut.ID)
118+
119+
return resourceIamResourceGroupRead(ctx, d, meta)
120+
}
121+
122+
func resourceIamResourceGroupUpdate(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics {
123+
config := meta.(*Config)
124+
id := d.Id()
125+
126+
var pol IamResourceGroup
127+
128+
pol.Name = d.Get("name").(string)
129+
urns := d.Get("resources").(*schema.Set)
130+
for _, r := range urns.List() {
131+
urn := r.(string)
132+
pol.Resources = append(pol.Resources, IamResourceDetails{URN: urn})
133+
}
134+
135+
err := config.OVHClient.PutWithContext(ctx, "/v2/iam/resourceGroup/"+url.PathEscape(id), &pol, nil)
136+
if err != nil {
137+
return diag.FromErr(err)
138+
}
139+
140+
return resourceIamResourceGroupRead(ctx, d, meta)
141+
}
142+
143+
func resourceIamResourceGroupDelete(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics {
144+
config := meta.(*Config)
145+
id := d.Id()
146+
147+
err := config.OVHClient.DeleteWithContext(ctx, "/v2/iam/resourceGroup/"+url.PathEscape(id), nil)
148+
if err != nil {
149+
return diag.FromErr(err)
150+
}
151+
152+
return nil
153+
}

Diff for: ‎ovh/resource_iam_resource_group_test.go

+113
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
package ovh
2+
3+
import (
4+
"fmt"
5+
"log"
6+
"os"
7+
"strings"
8+
"testing"
9+
"time"
10+
11+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
12+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
13+
)
14+
15+
func init() {
16+
resource.AddTestSweepers("ovh_iam_resource_group", &resource.Sweeper{
17+
Name: "ovh_iam_resource_group",
18+
F: testSweepMeIdentityResourceGroup,
19+
})
20+
}
21+
22+
func testSweepMeIdentityResourceGroup(region string) error {
23+
client, err := sharedClientForRegion(region)
24+
if err != nil {
25+
return fmt.Errorf("error getting client: %s", err)
26+
}
27+
28+
var groups []IamResourceGroup
29+
if err := client.Get("/v2/iam/resourceGroup", &groups); err != nil {
30+
return fmt.Errorf("Error calling /v2/iam/resourceGroup:\n\t %q", err)
31+
}
32+
33+
if len(groups) == 0 {
34+
log.Print("[DEBUG] No identity users to sweep")
35+
return nil
36+
}
37+
for _, resGrp := range groups {
38+
if !strings.HasPrefix(resGrp.Name, test_prefix) {
39+
continue
40+
}
41+
42+
if resGrp.ReadOnly {
43+
continue
44+
}
45+
log.Printf("[DEBUG] IAM resource group found %s: %s", resGrp.Name, resGrp.ID)
46+
err = resource.Retry(5*time.Minute, func() *resource.RetryError {
47+
log.Printf("[INFO] Deleting IAM resource group %s: %s", resGrp.Name, resGrp.ID)
48+
if err := client.Delete(fmt.Sprintf("/v2/iam/resourceGroup/%s", resGrp.ID), nil); err != nil {
49+
return resource.RetryableError(err)
50+
}
51+
52+
// Successful delete
53+
return nil
54+
})
55+
56+
if err != nil {
57+
return err
58+
}
59+
60+
}
61+
return nil
62+
}
63+
64+
func TestAccIamResourceGroupResource_basic(t *testing.T) {
65+
resourceGroupName1 := acctest.RandomWithPrefix(test_prefix)
66+
resourceGroupName2 := acctest.RandomWithPrefix(test_prefix)
67+
68+
resource1 := "urn:v1:eu:resource:vrack:" + os.Getenv("OVH_VRACK_SERVICE_TEST")
69+
resource2 := "urn:v1:eu:resource:vps:" + os.Getenv("OVH_VPS")
70+
71+
config := fmt.Sprintf(
72+
testAccIamResourceGroupResourceConfig_preSetup,
73+
resourceGroupName1,
74+
resource1,
75+
resourceGroupName2,
76+
resource1,
77+
resource2,
78+
)
79+
80+
checks := append(
81+
checkIamResourceGroupResourceAttr("ovh_iam_resource_group.resource_group_1", resourceGroupName1, resource1),
82+
checkIamResourceGroupResourceAttr("ovh_iam_resource_group.resource_group_2", resourceGroupName2, resource1, resource2)...,
83+
)
84+
85+
resource.Test(t, resource.TestCase{
86+
PreCheck: func() {
87+
testAccPreCheckIamResourceGroup(t)
88+
},
89+
Providers: testAccProviders,
90+
Steps: []resource.TestStep{
91+
{
92+
Config: config,
93+
Check: resource.ComposeTestCheckFunc(checks...),
94+
}, {
95+
ResourceName: "ovh_iam_resource_group.resource_group_1",
96+
ImportState: true,
97+
ImportStateVerify: true,
98+
},
99+
},
100+
})
101+
}
102+
103+
const testAccIamResourceGroupResourceConfig_preSetup = `
104+
resource "ovh_iam_resource_group" "resource_group_1" {
105+
name = "%s"
106+
resources = ["%s"]
107+
}
108+
109+
resource "ovh_iam_resource_group" "resource_group_2" {
110+
name = "%s"
111+
resources = ["%s", "%s"]
112+
}
113+
`

Diff for: ‎ovh/types_iam.go

+31-14
Original file line numberDiff line numberDiff line change
@@ -66,24 +66,25 @@ func (p IamPolicy) ToMap() map[string]any {
6666
return out
6767
}
6868

69+
// IamResource represent a possible information returned when viewing a policy
6970
type IamResource struct {
70-
URN string `json:"urn,omitempty"`
71-
Group *IamPolicyResourceGroup `json:"group,omitempty"`
72-
Resource *IamResourceDetails `json:"resource,omitempty"`
73-
}
74-
75-
type IamPolicyResourceGroup struct {
76-
Id string `json:"id"`
77-
Name string `json:"name"`
78-
ReadOnly bool `json:"readOnly"`
71+
// URN is always returned and is the urn of the resource or resource group
72+
// can also be a globing urn, for example "urn:v1:eu:resource:*"
73+
URN string `json:"urn,omitempty"`
74+
// If the urn is a resourceGroup. the details are also present
75+
Group *IamResourceGroup `json:"group,omitempty"`
76+
// If the urn is an IAM resource, the details are also present
77+
Resource *IamResourceDetails `json:"resource,omitempty"`
7978
}
8079

8180
type IamResourceDetails struct {
82-
Id string `json:"id"`
83-
Name string `json:"name"`
84-
DisplayName string `json:"displayName"`
85-
Owner string `json:"owner"`
86-
Type string `json:"type"`
81+
Id string `json:"id,omitempty"`
82+
URN string `json:"urn,omitempty"`
83+
Name string `json:"name,omitempty"`
84+
DisplayName string `json:"displayName,omitempty"`
85+
Owner string `json:"owner,omitempty"`
86+
Type string `json:"type,omitempty"`
87+
Tags map[string]string `json:"tags,omitempty"`
8788
}
8889

8990
type IamPermissions struct {
@@ -108,3 +109,19 @@ func (p IamPermissions) ToLists() ([]string, []string) {
108109
type IamAction struct {
109110
Action string `json:"action"`
110111
}
112+
113+
type IamResourceGroup struct {
114+
ID string `json:"id,omitempty"`
115+
Name string `json:"name"`
116+
Resources []IamResourceDetails `json:"resources"`
117+
URN string `json:"urn,omitempty"`
118+
Owner string `json:"owner,omitempty"`
119+
CreatedAt string `json:"createdAt,omitempty"`
120+
UpdatedAt string `json:"updatedAt,omitempty"`
121+
ReadOnly bool `json:"readOnly,omitempty"`
122+
}
123+
124+
type IamResourceGroupCreate struct {
125+
Name string `json:"name"`
126+
Resources []IamResourceDetails `json:"resources"`
127+
}

Diff for: ‎website/docs/d/iam_resource_group.html.markdown

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
subcategory : "Account Management"
3+
---
4+
5+
# ovh_iam_resource_group (Data Source)
6+
7+
Use this data source get details about a resource group.
8+
9+
## Example Usage
10+
11+
```hcl
12+
data "ovh_iam_resource_group" "my_resource_group" {
13+
id = "my_resource_group_id"
14+
}
15+
```
16+
17+
## Argument Reference
18+
19+
* `id`- Id of the resource group
20+
21+
## Attributes Reference
22+
23+
* `name`- Name of the resource group
24+
* `resources`- Set of the URNs of the resources contained in the resource group
25+
* `owner`- Name of the account owning the resource group
26+
* `created_at`- Date of the creation of the resource group
27+
* `updated_at`- Date of the last modification of the resource group
28+
* `read_only`- Marks that the resource group is not editable. Usually means that this is a default resource group created by OVHcloud
29+
* `urn`- URN of the resource group, used when writing policies

Diff for: ‎website/docs/d/iam_resource_groups.html.markdown

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
subcategory : "Account Management"
3+
---
4+
5+
# ovh_iam_resource_groups (Data Source)
6+
7+
Use this data source to list the existing IAM policies of an account.
8+
9+
## Example Usage
10+
11+
```hcl
12+
data "ovh_iam_resource_groups" "my_groups" {
13+
}
14+
```
15+
16+
## Argument Reference
17+
18+
## Attributes Reference
19+
20+
* `id` - Hash of the list of the resource groups IDs.
21+
* `resource_groups` - List of the resource groups IDs.

Diff for: ‎website/docs/r/iam_resource_group.html.markdown

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
---
2+
subcategory : "Account Management"
3+
---
4+
5+
# ovh_iam_resource_group (Resource)
6+
7+
Provides an OVHcloud IAM resource group.
8+
9+
## Example Usage
10+
11+
```hcl
12+
resource "ovh_iam_resource_group" "my_resource_group" {
13+
name = "my_resource_group"
14+
resources = [
15+
"urn:v1:eu:resource:service1:service1-id",
16+
"urn:v1:eu:resource:service2:service2-id",
17+
]
18+
}
19+
```
20+
21+
## Argument Reference
22+
23+
* `name`- Name of the resource group
24+
* `resources`- Set of the URNs of the resources contained in the resource group. All urns must be ones of valid resources
25+
26+
## Attributes Reference
27+
28+
* `id`- Id of the resource group
29+
* `owner`- Name of the account owning the resource group
30+
* `created_at`- Date of the creation of the resource group
31+
* `updated_at`- Date of the last modification of the resource group
32+
* `read_only`- Marks that the resource group is not editable. Usually means that this is a default resource group created by OVHcloud
33+
* `urn`- URN of the resource group, used when writing policies
34+
35+
## Import
36+
37+
38+
Resource groups can be imported by using their id.
39+
40+
```bash
41+
$ terraform import ovh_iam_resource_group.my_resource_group resource_group_id
42+
```
43+
44+
-> Read only resource groups cannot be imported

0 commit comments

Comments
 (0)
Please sign in to comment.