@@ -3,6 +3,7 @@ package iam
3
3
import (
4
4
"context"
5
5
"fmt"
6
+ "github.com/scaleway/terraform-provider-scaleway/v2/internal/types"
6
7
7
8
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
8
9
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
@@ -30,6 +31,14 @@ func DataSourceUser() *schema.Resource {
30
31
ValidateDiagFunc : verify .IsEmail (),
31
32
ConflictsWith : []string {"user_id" },
32
33
},
34
+ "tags" : {
35
+ Type : schema .TypeList ,
36
+ Elem : & schema.Schema {
37
+ Type : schema .TypeString ,
38
+ },
39
+ Optional : true ,
40
+ Description : "The tags associated with the user" ,
41
+ },
33
42
"organization_id" : {
34
43
Type : schema .TypeString ,
35
44
Description : "The organization_id you want to attach the resource to" ,
@@ -44,6 +53,7 @@ func DataSourceIamUserRead(ctx context.Context, d *schema.ResourceData, m interf
44
53
iamAPI := NewAPI (m )
45
54
46
55
var email , organizationID string
56
+ var tags []string
47
57
userID , ok := d .GetOk ("user_id" )
48
58
if ok {
49
59
userID = d .Get ("user_id" )
@@ -55,6 +65,7 @@ func DataSourceIamUserRead(ctx context.Context, d *schema.ResourceData, m interf
55
65
}
56
66
email = res .Email
57
67
organizationID = res .OrganizationID
68
+ tags = res .Tags
58
69
} else {
59
70
res , err := iamAPI .ListUsers (& iam.ListUsersRequest {
60
71
OrganizationID : account .GetOrganizationID (m , d ),
@@ -70,7 +81,7 @@ func DataSourceIamUserRead(ctx context.Context, d *schema.ResourceData, m interf
70
81
if userID != "" {
71
82
return diag .Errorf ("more than 1 user found with the same email %s" , d .Get ("email" ))
72
83
}
73
- userID , email = user .ID , user .Email
84
+ userID , email , tags = user .ID , user .Email , user . Tags
74
85
}
75
86
}
76
87
if userID == "" {
@@ -86,6 +97,7 @@ func DataSourceIamUserRead(ctx context.Context, d *schema.ResourceData, m interf
86
97
87
98
_ = d .Set ("user_id" , userID )
88
99
_ = d .Set ("email" , email )
100
+ _ = d .Set ("tags" , types .FlattenSliceString (tags ))
89
101
_ = d .Set ("organization_id" , organizationID )
90
102
91
103
return nil
0 commit comments