@@ -7,11 +7,10 @@ import (
7
7
"net/http"
8
8
"strings"
9
9
10
- "go.mongodb.org/atlas-sdk/v20230201006/admin"
11
- matlas "go.mongodb.org/atlas/mongodbatlas"
12
-
13
10
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
14
11
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
12
+ "go.mongodb.org/atlas-sdk/v20230201006/admin"
13
+ matlas "go.mongodb.org/atlas/mongodbatlas"
15
14
)
16
15
17
16
func resourceMongoDBAtlasProjectAPIKey () * schema.Resource {
@@ -45,15 +44,6 @@ func resourceMongoDBAtlasProjectAPIKey() *schema.Resource {
45
44
Computed : true ,
46
45
Sensitive : true ,
47
46
},
48
- "role_names" : {
49
- Type : schema .TypeSet ,
50
- Optional : true ,
51
- Elem : & schema.Schema {
52
- Type : schema .TypeString ,
53
- },
54
- ConflictsWith : []string {"project_assignment" },
55
- Deprecated : fmt .Sprintf (DeprecationMessageParameterToResource , "v1.12.0" , "project_assignment" ),
56
- },
57
47
"project_assignment" : {
58
48
Type : schema .TypeSet ,
59
49
Optional : true ,
@@ -72,7 +62,6 @@ func resourceMongoDBAtlasProjectAPIKey() *schema.Resource {
72
62
},
73
63
},
74
64
},
75
- ConflictsWith : []string {"role_names" },
76
65
},
77
66
},
78
67
}
@@ -122,18 +111,6 @@ func resourceMongoDBAtlasProjectAPIKeyCreate(ctx context.Context, d *schema.Reso
122
111
}
123
112
}
124
113
}
125
- } else {
126
- createRequest .Roles = expandStringList (d .Get ("role_names" ).(* schema.Set ).List ())
127
-
128
- apiKey , resp , err = conn .ProjectAPIKeys .Create (ctx , projectID , createRequest )
129
- if err != nil {
130
- if resp != nil && resp .StatusCode == http .StatusNotFound {
131
- d .SetId ("" )
132
- return nil
133
- }
134
-
135
- return diag .FromErr (fmt .Errorf ("error create API key: %s" , err ))
136
- }
137
114
}
138
115
139
116
if err := d .Set ("public_key" , apiKey .PublicKey ); err != nil {
@@ -182,19 +159,9 @@ func resourceMongoDBAtlasProjectAPIKeyRead(ctx context.Context, d *schema.Resour
182
159
return diag .FromErr (fmt .Errorf ("error setting `public_key`: %s" , err ))
183
160
}
184
161
185
- _ , roleOk := d .GetOk ("role_names" )
186
- if ! roleOk {
187
- if err := d .Set ("role_names" , nil ); err != nil {
188
- return diag .FromErr (fmt .Errorf ("error setting `roles`: %s" , err ))
189
- }
190
- if projectAssignments , err := newProjectAssignment (ctx , conn , apiKeyID ); err == nil {
191
- if err := d .Set ("project_assignment" , projectAssignments ); err != nil {
192
- return diag .Errorf (errorProjectSetting , `created` , projectID , err )
193
- }
194
- }
195
- } else {
196
- if err := d .Set ("role_names" , flattenProjectAPIKeyRoles (projectID , val .Roles )); err != nil {
197
- return diag .FromErr (fmt .Errorf ("error setting `roles`: %s" , err ))
162
+ if projectAssignments , err := newProjectAssignment (ctx , conn , apiKeyID ); err == nil {
163
+ if err := d .Set ("project_assignment" , projectAssignments ); err != nil {
164
+ return diag .Errorf (errorProjectSetting , `created` , projectID , err )
198
165
}
199
166
}
200
167
}
0 commit comments