@@ -176,6 +176,42 @@ func TestAccPinpointSMSVoiceV2PhoneNumber_twoWayChannelRole(t *testing.T) {
176
176
},
177
177
})
178
178
}
179
+
180
+ func TestAccPinpointSMSVoiceV2PhoneNumber_twoWayChannelConnect (t * testing.T ) {
181
+ ctx := acctest .Context (t )
182
+
183
+ iamRoleName := sdkacctest .RandomWithPrefix (acctest .ResourcePrefix )
184
+ resourceName := "aws_pinpointsmsvoicev2_phone_number.test"
185
+
186
+ resource .ParallelTest (t , resource.TestCase {
187
+ PreCheck : func () {
188
+ acctest .PreCheck (ctx , t )
189
+ testAccPreCheckPhoneNumber (ctx , t )
190
+ },
191
+ ErrorCheck : acctest .ErrorCheck (t , names .PinpointSMSVoiceV2ServiceID ),
192
+ ProtoV5ProviderFactories : acctest .ProtoV5ProviderFactories ,
193
+ CheckDestroy : testAccCheckPhoneNumberDestroy (ctx ),
194
+ Steps : []resource.TestStep {
195
+ {
196
+ Config : testAccPhoneNumberConfig_two_way_channel_connect (iamRoleName ),
197
+ ConfigStateChecks : []statecheck.StateCheck {
198
+ statecheck .ExpectKnownValue (resourceName , tfjsonpath .New ("iso_country_code" ), knownvalue .StringExact ("US" )),
199
+ statecheck .ExpectKnownValue (resourceName , tfjsonpath .New ("message_type" ), knownvalue .StringExact ("TRANSACTIONAL" )),
200
+ statecheck .ExpectKnownValue (resourceName , tfjsonpath .New ("number_type" ), knownvalue .StringExact ("SIMULATOR" )),
201
+ statecheck .ExpectKnownValue (resourceName , tfjsonpath .New ("two_way_channel_enabled" ), knownvalue .Bool (true )),
202
+ statecheck .ExpectKnownValue (resourceName , tfjsonpath .New ("two_way_channel_arn" ), knownvalue .StringRegexp (regexache .MustCompile (`^connect\.[a-z0-9-]+\.amazonaws\.com` ))),
203
+ statecheck .ExpectKnownValue (resourceName , tfjsonpath .New ("two_way_channel_role" ), tfknownvalue .GlobalARNRegexp ("iam" , regexache .MustCompile (fmt .Sprintf (`role/%s` , iamRoleName )))),
204
+ },
205
+ },
206
+ {
207
+ ResourceName : resourceName ,
208
+ ImportState : true ,
209
+ ImportStateVerify : true ,
210
+ },
211
+ },
212
+ })
213
+ }
214
+
179
215
func TestAccPinpointSMSVoiceV2PhoneNumber_disappears (t * testing.T ) {
180
216
ctx := acctest .Context (t )
181
217
var phoneNumber awstypes.PhoneNumberInformation
@@ -441,6 +477,64 @@ resource "aws_pinpointsmsvoicev2_phone_number" "test" {
441
477
` , snsTopicName , iamRoleName )
442
478
}
443
479
480
+ func testAccPhoneNumberConfig_two_way_channel_connect (iamRoleName string ) string {
481
+ return fmt .Sprintf (`
482
+ data "aws_caller_identity" "current" {}
483
+ data "aws_region" "current" {}
484
+
485
+ resource "aws_iam_role" "test" {
486
+ name = %[1]q
487
+ assume_role_policy = jsonencode({
488
+ Version = "2012-10-17",
489
+ Statement = [
490
+ {
491
+ Action = "sts:AssumeRole",
492
+ Effect = "Allow",
493
+ Principal = {
494
+ Service = "sms-voice.amazonaws.com"
495
+ }
496
+ Condition = {
497
+ StringEquals = {
498
+ "aws:SourceAccount" = data.aws_caller_identity.current.account_id
499
+ }
500
+ }
501
+ }
502
+ ]
503
+ })
504
+ }
505
+
506
+ resource "aws_iam_role_policy" "test" {
507
+ name = "pinpointsmsvoicev2-sns-policy"
508
+ role = aws_iam_role.test.id
509
+ policy = jsonencode({
510
+ Version = "2012-10-17",
511
+ Statement = [
512
+ {
513
+ Effect = "Allow",
514
+ Action = [
515
+ "connect:SendChatIntegrationEvent",
516
+ ],
517
+ Resource = ["*"]
518
+ }
519
+ ]
520
+ })
521
+ }
522
+
523
+ resource "aws_pinpointsmsvoicev2_phone_number" "test" {
524
+ iso_country_code = "US"
525
+ message_type = "TRANSACTIONAL"
526
+ number_type = "SIMULATOR"
527
+ two_way_channel_arn = "connect.${data.aws_region.current.region}.amazonaws.com"
528
+ two_way_channel_role = aws_iam_role.test.arn
529
+ two_way_channel_enabled = true
530
+ number_capabilities = [
531
+ "SMS",
532
+ "VOICE",
533
+ ]
534
+ }
535
+ ` , iamRoleName )
536
+ }
537
+
444
538
func testAccPhoneNumberConfig_tags1 (tagKey1 , tagValue1 string ) string {
445
539
return fmt .Sprintf (`
446
540
resource "aws_pinpointsmsvoicev2_phone_number" "test" {
0 commit comments