@@ -3,13 +3,13 @@ package mq
3
3
import (
4
4
"context"
5
5
"encoding/base64"
6
- "fmt"
7
6
"log"
8
7
"strconv"
9
8
10
9
"github.com/aws/aws-sdk-go/aws"
11
10
"github.com/aws/aws-sdk-go/service/mq"
12
11
"github.com/hashicorp/aws-sdk-go-base/v2/awsv1shim/v2/tfawserr"
12
+ "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
13
13
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff"
14
14
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
15
15
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
@@ -22,9 +22,9 @@ import (
22
22
23
23
func ResourceConfiguration () * schema.Resource {
24
24
return & schema.Resource {
25
- Create : resourceConfigurationCreate ,
26
- Read : resourceConfigurationRead ,
27
- Update : resourceConfigurationUpdate ,
25
+ CreateWithoutTimeout : resourceConfigurationCreate ,
26
+ ReadWithoutTimeout : resourceConfigurationRead ,
27
+ UpdateWithoutTimeout : resourceConfigurationUpdate ,
28
28
DeleteWithoutTimeout : schema .NoopContext , // Delete is not available in the API
29
29
30
30
Importer : & schema.ResourceImporter {
@@ -95,7 +95,7 @@ func ResourceConfiguration() *schema.Resource {
95
95
}
96
96
}
97
97
98
- func resourceConfigurationCreate (d * schema.ResourceData , meta interface {}) error {
98
+ func resourceConfigurationCreate (ctx context. Context , d * schema.ResourceData , meta interface {}) diag. Diagnostics {
99
99
conn := meta .(* conns.AWSClient ).MQConn
100
100
defaultTagsConfig := meta .(* conns.AWSClient ).DefaultTagsConfig
101
101
tags := defaultTagsConfig .MergeTags (tftags .New (d .Get ("tags" ).(map [string ]interface {})))
@@ -115,10 +115,10 @@ func resourceConfigurationCreate(d *schema.ResourceData, meta interface{}) error
115
115
input .Tags = Tags (tags .IgnoreAWS ())
116
116
}
117
117
118
- output , err := conn .CreateConfiguration ( input )
118
+ output , err := conn .CreateConfigurationWithContext ( ctx , input )
119
119
120
120
if err != nil {
121
- return fmt .Errorf ("creating MQ Configuration (%s): %w " , name , err )
121
+ return diag .Errorf ("creating MQ Configuration (%s): %s " , name , err )
122
122
}
123
123
124
124
d .SetId (aws .StringValue (output .Id ))
@@ -133,22 +133,22 @@ func resourceConfigurationCreate(d *schema.ResourceData, meta interface{}) error
133
133
input .Description = aws .String (v .(string ))
134
134
}
135
135
136
- _ , err := conn .UpdateConfiguration ( input )
136
+ _ , err := conn .UpdateConfigurationWithContext ( ctx , input )
137
137
138
138
if err != nil {
139
- return fmt .Errorf ("updating MQ Configuration (%s): %w " , d .Id (), err )
139
+ return diag .Errorf ("updating MQ Configuration (%s): %s " , d .Id (), err )
140
140
}
141
141
}
142
142
143
- return resourceConfigurationRead (d , meta )
143
+ return resourceConfigurationRead (ctx , d , meta )
144
144
}
145
145
146
- func resourceConfigurationRead (d * schema.ResourceData , meta interface {}) error {
146
+ func resourceConfigurationRead (ctx context. Context , d * schema.ResourceData , meta interface {}) diag. Diagnostics {
147
147
conn := meta .(* conns.AWSClient ).MQConn
148
148
defaultTagsConfig := meta .(* conns.AWSClient ).DefaultTagsConfig
149
149
ignoreTagsConfig := meta .(* conns.AWSClient ).IgnoreTagsConfig
150
150
151
- configuration , err := FindConfigurationByID (conn , d .Id ())
151
+ configuration , err := FindConfigurationByID (ctx , conn , d .Id ())
152
152
153
153
if ! d .IsNewResource () && tfresource .NotFound (err ) {
154
154
log .Printf ("[WARN] MQ Configuration (%s) not found, removing from state" , d .Id ())
@@ -157,7 +157,7 @@ func resourceConfigurationRead(d *schema.ResourceData, meta interface{}) error {
157
157
}
158
158
159
159
if err != nil {
160
- return fmt .Errorf ("reading MQ Configuration (%s): %w " , d .Id (), err )
160
+ return diag .Errorf ("reading MQ Configuration (%s): %s " , d .Id (), err )
161
161
}
162
162
163
163
d .Set ("arn" , configuration .Arn )
@@ -169,19 +169,19 @@ func resourceConfigurationRead(d *schema.ResourceData, meta interface{}) error {
169
169
d .Set ("name" , configuration .Name )
170
170
171
171
revision := strconv .FormatInt (aws .Int64Value (configuration .LatestRevision .Revision ), 10 )
172
- configurationRevision , err := conn .DescribeConfigurationRevision ( & mq.DescribeConfigurationRevisionInput {
172
+ configurationRevision , err := conn .DescribeConfigurationRevisionWithContext ( ctx , & mq.DescribeConfigurationRevisionInput {
173
173
ConfigurationId : aws .String (d .Id ()),
174
174
ConfigurationRevision : aws .String (revision ),
175
175
})
176
176
177
177
if err != nil {
178
- return fmt .Errorf ("reading MQ Configuration (%s) revision (%s): %w " , d .Id (), revision , err )
178
+ return diag .Errorf ("reading MQ Configuration (%s) revision (%s): %s " , d .Id (), revision , err )
179
179
}
180
180
181
181
data , err := base64 .StdEncoding .DecodeString (aws .StringValue (configurationRevision .Data ))
182
182
183
183
if err != nil {
184
- return fmt .Errorf ("base64 decoding: %w " , err )
184
+ return diag .Errorf ("base64 decoding: %s " , err )
185
185
}
186
186
187
187
d .Set ("data" , string (data ))
@@ -190,17 +190,17 @@ func resourceConfigurationRead(d *schema.ResourceData, meta interface{}) error {
190
190
191
191
//lintignore:AWSR002
192
192
if err := d .Set ("tags" , tags .RemoveDefaultConfig (defaultTagsConfig ).Map ()); err != nil {
193
- return fmt .Errorf ("setting tags: %w " , err )
193
+ return diag .Errorf ("setting tags: %s " , err )
194
194
}
195
195
196
196
if err := d .Set ("tags_all" , tags .Map ()); err != nil {
197
- return fmt .Errorf ("setting tags_all: %w " , err )
197
+ return diag .Errorf ("setting tags_all: %s " , err )
198
198
}
199
199
200
200
return nil
201
201
}
202
202
203
- func resourceConfigurationUpdate (d * schema.ResourceData , meta interface {}) error {
203
+ func resourceConfigurationUpdate (ctx context. Context , d * schema.ResourceData , meta interface {}) diag. Diagnostics {
204
204
conn := meta .(* conns.AWSClient ).MQConn
205
205
206
206
if d .HasChanges ("data" , "description" ) {
@@ -213,30 +213,30 @@ func resourceConfigurationUpdate(d *schema.ResourceData, meta interface{}) error
213
213
input .Description = aws .String (v .(string ))
214
214
}
215
215
216
- _ , err := conn .UpdateConfiguration ( input )
216
+ _ , err := conn .UpdateConfigurationWithContext ( ctx , input )
217
217
218
218
if err != nil {
219
- return fmt .Errorf ("updating MQ Configuration (%s): %w " , d .Id (), err )
219
+ return diag .Errorf ("updating MQ Configuration (%s): %s " , d .Id (), err )
220
220
}
221
221
}
222
222
223
223
if d .HasChange ("tags_all" ) {
224
224
o , n := d .GetChange ("tags_all" )
225
225
226
- if err := UpdateTags ( conn , d .Get ("arn" ).(string ), o , n ); err != nil {
227
- return fmt .Errorf ("updating MQ Configuration (%s) tags: %w " , d .Get ("arn" ).(string ), err )
226
+ if err := UpdateTagsWithContext ( ctx , conn , d .Get ("arn" ).(string ), o , n ); err != nil {
227
+ return diag .Errorf ("updating MQ Configuration (%s) tags: %s " , d .Get ("arn" ).(string ), err )
228
228
}
229
229
}
230
230
231
- return resourceConfigurationRead (d , meta )
231
+ return resourceConfigurationRead (ctx , d , meta )
232
232
}
233
233
234
- func FindConfigurationByID (conn * mq.MQ , id string ) (* mq.DescribeConfigurationOutput , error ) {
234
+ func FindConfigurationByID (ctx context. Context , conn * mq.MQ , id string ) (* mq.DescribeConfigurationOutput , error ) {
235
235
input := & mq.DescribeConfigurationInput {
236
236
ConfigurationId : aws .String (id ),
237
237
}
238
238
239
- output , err := conn .DescribeConfiguration ( input )
239
+ output , err := conn .DescribeConfigurationWithContext ( ctx , input )
240
240
241
241
if tfawserr .ErrCodeEquals (err , mq .ErrCodeNotFoundException ) {
242
242
return nil , & resource.NotFoundError {
0 commit comments