@@ -101,11 +101,13 @@ func resourcePortfolioShare() *schema.Resource {
101
101
}
102
102
}
103
103
104
+ const portfolioShareMutexKey = "aws_servicecatalog_portfolio_share"
105
+
104
106
func resourcePortfolioShareCreate (ctx context.Context , d * schema.ResourceData , meta any ) diag.Diagnostics {
105
107
var diags diag.Diagnostics
106
108
conn := meta .(* conns.AWSClient ).ServiceCatalogClient (ctx )
107
109
108
- input := & servicecatalog.CreatePortfolioShareInput {
110
+ input := servicecatalog.CreatePortfolioShareInput {
109
111
PortfolioId : aws .String (d .Get ("portfolio_id" ).(string )),
110
112
SharePrincipals : d .Get ("share_principals" ).(bool ),
111
113
AcceptLanguage : aws .String (d .Get ("accept_language" ).(string )),
@@ -131,11 +133,14 @@ func resourcePortfolioShareCreate(ctx context.Context, d *schema.ResourceData, m
131
133
input .ShareTagOptions = v .(bool )
132
134
}
133
135
136
+ conns .GlobalMutexKV .Lock (portfolioShareMutexKey )
137
+ defer conns .GlobalMutexKV .Unlock (portfolioShareMutexKey )
138
+
134
139
var output * servicecatalog.CreatePortfolioShareOutput
135
140
err := tfresource .Retry (ctx , d .Timeout (schema .TimeoutCreate ), func (ctx context.Context ) * tfresource.RetryError {
136
141
var err error
137
142
138
- output , err = conn .CreatePortfolioShare (ctx , input )
143
+ output , err = conn .CreatePortfolioShare (ctx , & input )
139
144
140
145
if errs .IsAErrorMessageContains [* awstypes.InvalidParametersException ](err , "profile does not exist" ) {
141
146
return tfresource .RetryableError (err )
@@ -219,7 +224,7 @@ func resourcePortfolioShareUpdate(ctx context.Context, d *schema.ResourceData, m
219
224
var diags diag.Diagnostics
220
225
conn := meta .(* conns.AWSClient ).ServiceCatalogClient (ctx )
221
226
222
- input := & servicecatalog.UpdatePortfolioShareInput {
227
+ input := servicecatalog.UpdatePortfolioShareInput {
223
228
PortfolioId : aws .String (d .Get ("portfolio_id" ).(string )),
224
229
AcceptLanguage : aws .String (d .Get ("accept_language" ).(string )),
225
230
}
@@ -249,7 +254,7 @@ func resourcePortfolioShareUpdate(ctx context.Context, d *schema.ResourceData, m
249
254
}
250
255
251
256
err := tfresource .Retry (ctx , d .Timeout (schema .TimeoutUpdate ), func (ctx context.Context ) * tfresource.RetryError {
252
- _ , err := conn .UpdatePortfolioShare (ctx , input )
257
+ _ , err := conn .UpdatePortfolioShare (ctx , & input )
253
258
254
259
if errs .IsAErrorMessageContains [* awstypes.InvalidParametersException ](err , "profile does not exist" ) {
255
260
return tfresource .RetryableError (err )
@@ -273,7 +278,7 @@ func resourcePortfolioShareDelete(ctx context.Context, d *schema.ResourceData, m
273
278
var diags diag.Diagnostics
274
279
conn := meta .(* conns.AWSClient ).ServiceCatalogClient (ctx )
275
280
276
- input := & servicecatalog.DeletePortfolioShareInput {
281
+ input := servicecatalog.DeletePortfolioShareInput {
277
282
PortfolioId : aws .String (d .Get ("portfolio_id" ).(string )),
278
283
}
279
284
@@ -297,7 +302,10 @@ func resourcePortfolioShareDelete(ctx context.Context, d *schema.ResourceData, m
297
302
input .OrganizationNode = orgNode
298
303
}
299
304
300
- output , err := conn .DeletePortfolioShare (ctx , input )
305
+ conns .GlobalMutexKV .Lock (portfolioShareMutexKey )
306
+ defer conns .GlobalMutexKV .Unlock (portfolioShareMutexKey )
307
+
308
+ output , err := conn .DeletePortfolioShare (ctx , & input )
301
309
302
310
if errs.IsA [* awstypes.ResourceNotFoundException ](err ) {
303
311
return diags
0 commit comments