@@ -7,15 +7,17 @@ import (
7
7
"context"
8
8
"log"
9
9
10
- "github.com/aws/aws-sdk-go/aws"
11
- "github.com/aws/aws-sdk-go/service/chimesdkvoice"
12
- "github.com/hashicorp /aws-sdk-go-base/ v2/awsv1shim/v2/tfawserr "
10
+ "github.com/aws/aws-sdk-go-v2 /aws"
11
+ "github.com/aws/aws-sdk-go-v2 /service/chimesdkvoice"
12
+ awstypes "github.com/aws /aws-sdk-go-v2/service/chimesdkvoice/types "
13
13
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
14
14
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff"
15
15
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry"
16
16
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
17
17
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
18
18
"github.com/hashicorp/terraform-provider-aws/internal/conns"
19
+ "github.com/hashicorp/terraform-provider-aws/internal/enum"
20
+ "github.com/hashicorp/terraform-provider-aws/internal/errs"
19
21
"github.com/hashicorp/terraform-provider-aws/internal/errs/sdkdiag"
20
22
tftags "github.com/hashicorp/terraform-provider-aws/internal/tags"
21
23
"github.com/hashicorp/terraform-provider-aws/internal/tfresource"
@@ -42,11 +44,11 @@ func ResourceVoiceConnector() *schema.Resource {
42
44
Computed : true ,
43
45
},
44
46
"aws_region" : {
45
- Type : schema .TypeString ,
46
- ForceNew : true ,
47
- Optional : true ,
48
- Computed : true ,
49
- ValidateFunc : validation . StringInSlice ( chimesdkvoice . VoiceConnectorAwsRegion_Values (), false ),
47
+ Type : schema .TypeString ,
48
+ ForceNew : true ,
49
+ Optional : true ,
50
+ Computed : true ,
51
+ ValidateDiagFunc : enum . Validate [awstypes. VoiceConnectorAwsRegion ]( ),
50
52
},
51
53
"name" : {
52
54
Type : schema .TypeString ,
@@ -84,7 +86,7 @@ func resourceVoiceConnectorDefaultRegion(ctx context.Context, diff *schema.Resou
84
86
85
87
func resourceVoiceConnectorCreate (ctx context.Context , d * schema.ResourceData , meta interface {}) diag.Diagnostics {
86
88
var diags diag.Diagnostics
87
- conn := meta .(* conns.AWSClient ).ChimeSDKVoiceConn (ctx )
89
+ conn := meta .(* conns.AWSClient ).ChimeSDKVoiceClient (ctx )
88
90
89
91
createInput := & chimesdkvoice.CreateVoiceConnectorInput {
90
92
Name : aws .String (d .Get ("name" ).(string )),
@@ -93,24 +95,24 @@ func resourceVoiceConnectorCreate(ctx context.Context, d *schema.ResourceData, m
93
95
}
94
96
95
97
if v , ok := d .GetOk ("aws_region" ); ok {
96
- createInput .AwsRegion = aws . String (v .(string ))
98
+ createInput .AwsRegion = awstypes . VoiceConnectorAwsRegion (v .(string ))
97
99
}
98
100
99
- resp , err := conn .CreateVoiceConnectorWithContext (ctx , createInput )
101
+ resp , err := conn .CreateVoiceConnector (ctx , createInput )
100
102
if err != nil || resp .VoiceConnector == nil {
101
103
return sdkdiag .AppendErrorf (diags , "creating Chime Voice connector: %s" , err )
102
104
}
103
105
104
- d .SetId (aws .StringValue (resp .VoiceConnector .VoiceConnectorId ))
106
+ d .SetId (aws .ToString (resp .VoiceConnector .VoiceConnectorId ))
105
107
106
108
return append (diags , resourceVoiceConnectorRead (ctx , d , meta )... )
107
109
}
108
110
109
111
func resourceVoiceConnectorRead (ctx context.Context , d * schema.ResourceData , meta interface {}) diag.Diagnostics {
110
112
var diags diag.Diagnostics
111
- conn := meta .(* conns.AWSClient ).ChimeSDKVoiceConn (ctx )
113
+ conn := meta .(* conns.AWSClient ).ChimeSDKVoiceClient (ctx )
112
114
113
- resp , err := FindVoiceConnectorResourceWithRetry (ctx , d .IsNewResource (), func () (* chimesdkvoice .VoiceConnector , error ) {
115
+ resp , err := FindVoiceConnectorResourceWithRetry (ctx , d .IsNewResource (), func () (* awstypes .VoiceConnector , error ) {
114
116
return findVoiceConnectorByID (ctx , conn , d .Id ())
115
117
})
116
118
@@ -139,7 +141,7 @@ func resourceVoiceConnectorRead(ctx context.Context, d *schema.ResourceData, met
139
141
140
142
func resourceVoiceConnectorUpdate (ctx context.Context , d * schema.ResourceData , meta interface {}) diag.Diagnostics {
141
143
var diags diag.Diagnostics
142
- conn := meta .(* conns.AWSClient ).ChimeSDKVoiceConn (ctx )
144
+ conn := meta .(* conns.AWSClient ).ChimeSDKVoiceClient (ctx )
143
145
144
146
if d .HasChanges ("name" , "require_encryption" ) {
145
147
updateInput := & chimesdkvoice.UpdateVoiceConnectorInput {
@@ -148,7 +150,7 @@ func resourceVoiceConnectorUpdate(ctx context.Context, d *schema.ResourceData, m
148
150
RequireEncryption : aws .Bool (d .Get ("require_encryption" ).(bool )),
149
151
}
150
152
151
- if _ , err := conn .UpdateVoiceConnectorWithContext (ctx , updateInput ); err != nil {
153
+ if _ , err := conn .UpdateVoiceConnector (ctx , updateInput ); err != nil {
152
154
return sdkdiag .AppendErrorf (diags , "updating Voice connector (%s): %s" , d .Id (), err )
153
155
}
154
156
}
@@ -158,14 +160,14 @@ func resourceVoiceConnectorUpdate(ctx context.Context, d *schema.ResourceData, m
158
160
159
161
func resourceVoiceConnectorDelete (ctx context.Context , d * schema.ResourceData , meta interface {}) diag.Diagnostics {
160
162
var diags diag.Diagnostics
161
- conn := meta .(* conns.AWSClient ).ChimeSDKVoiceConn (ctx )
163
+ conn := meta .(* conns.AWSClient ).ChimeSDKVoiceClient (ctx )
162
164
163
165
input := & chimesdkvoice.DeleteVoiceConnectorInput {
164
166
VoiceConnectorId : aws .String (d .Id ()),
165
167
}
166
168
167
- if _ , err := conn .DeleteVoiceConnectorWithContext (ctx , input ); err != nil {
168
- if tfawserr . ErrCodeEquals (err , chimesdkvoice . ErrCodeNotFoundException ) {
169
+ if _ , err := conn .DeleteVoiceConnector (ctx , input ); err != nil {
170
+ if errs. IsA [ * awstypes. NotFoundException ] (err ) {
169
171
log .Printf ("[WARN] Chime Voice connector %s not found" , d .Id ())
170
172
return diags
171
173
}
@@ -175,14 +177,14 @@ func resourceVoiceConnectorDelete(ctx context.Context, d *schema.ResourceData, m
175
177
return diags
176
178
}
177
179
178
- func findVoiceConnectorByID (ctx context.Context , conn * chimesdkvoice.ChimeSDKVoice , id string ) (* chimesdkvoice .VoiceConnector , error ) {
180
+ func findVoiceConnectorByID (ctx context.Context , conn * chimesdkvoice.Client , id string ) (* awstypes .VoiceConnector , error ) {
179
181
in := & chimesdkvoice.GetVoiceConnectorInput {
180
182
VoiceConnectorId : aws .String (id ),
181
183
}
182
184
183
- resp , err := conn .GetVoiceConnectorWithContext (ctx , in )
185
+ resp , err := conn .GetVoiceConnector (ctx , in )
184
186
185
- if tfawserr . ErrCodeEquals (err , chimesdkvoice . ErrCodeNotFoundException ) {
187
+ if errs. IsA [ * awstypes. NotFoundException ] (err ) {
186
188
return nil , & retry.NotFoundError {
187
189
LastError : err ,
188
190
LastRequest : in ,
0 commit comments