@@ -108,11 +108,9 @@ func testAccClientVPNEndpoint_basic(t *testing.T) {
108
108
testAccCheckClientVPNEndpointExists (ctx , resourceName , & v ),
109
109
acctest .MatchResourceAttrRegionalARN (resourceName , "arn" , "ec2" , regexp .MustCompile (`client-vpn-endpoint/cvpn-endpoint-.+` )),
110
110
resource .TestCheckResourceAttr (resourceName , "authentication_options.#" , "1" ),
111
- resource .TestCheckResourceAttr (resourceName , "authentication_options.0.type" , "certificate-authentication" ),
112
- resource .TestCheckResourceAttr (resourceName , "authentication_options.0.active_directory_id" , "" ),
113
- resource .TestCheckResourceAttrSet (resourceName , "authentication_options.0.root_certificate_chain_arn" ),
114
- resource .TestCheckResourceAttr (resourceName , "authentication_options.0.saml_provider_arn" , "" ),
115
- resource .TestCheckResourceAttr (resourceName , "authentication_options.0.self_service_saml_provider_arn" , "" ),
111
+ resource .TestCheckTypeSetElemNestedAttrs (resourceName , "authentication_options.*" , map [string ]string {
112
+ "type" : "certificate-authentication" ,
113
+ }),
116
114
resource .TestCheckResourceAttr (resourceName , "client_cidr_block" , "10.0.0.0/16" ),
117
115
resource .TestCheckResourceAttr (resourceName , "client_connect_options.#" , "1" ),
118
116
resource .TestCheckResourceAttr (resourceName , "client_connect_options.0.enabled" , "false" ),
@@ -132,7 +130,8 @@ func testAccClientVPNEndpoint_basic(t *testing.T) {
132
130
resource .TestCheckResourceAttr (resourceName , "session_timeout_hours" , "24" ),
133
131
resource .TestCheckResourceAttr (resourceName , "split_tunnel" , "false" ),
134
132
resource .TestCheckResourceAttr (resourceName , "status" , ec2 .ClientVpnEndpointStatusCodePendingAssociate ),
135
- resource .TestCheckResourceAttr (resourceName , "tags.%" , "0" ),
133
+ resource .TestCheckResourceAttr (resourceName , "tags.%" , "1" ),
134
+ resource .TestCheckResourceAttr (resourceName , "tags.Name" , rName ),
136
135
resource .TestCheckResourceAttr (resourceName , "transport_protocol" , "udp" ),
137
136
resource .TestCheckResourceAttr (resourceName , "vpc_id" , "" ),
138
137
resource .TestCheckResourceAttr (resourceName , "vpn_port" , "443" ),
@@ -221,7 +220,6 @@ func testAccClientVPNEndpoint_msADAuth(t *testing.T) {
221
220
var v ec2.ClientVpnEndpoint
222
221
rName := sdkacctest .RandomWithPrefix (acctest .ResourcePrefix )
223
222
resourceName := "aws_ec2_client_vpn_endpoint.test"
224
- dsDirectoryResourceName := "aws_directory_service_directory.test"
225
223
domainName := acctest .RandomDomainName ()
226
224
227
225
if testing .Short () {
@@ -239,8 +237,9 @@ func testAccClientVPNEndpoint_msADAuth(t *testing.T) {
239
237
Check : resource .ComposeTestCheckFunc (
240
238
testAccCheckClientVPNEndpointExists (ctx , resourceName , & v ),
241
239
resource .TestCheckResourceAttr (resourceName , "authentication_options.#" , "1" ),
242
- resource .TestCheckResourceAttr (resourceName , "authentication_options.0.type" , "directory-service-authentication" ),
243
- resource .TestCheckResourceAttrPair (resourceName , "authentication_options.0.active_directory_id" , dsDirectoryResourceName , "id" ),
240
+ resource .TestCheckTypeSetElemNestedAttrs (resourceName , "authentication_options.*" , map [string ]string {
241
+ "type" : "directory-service-authentication" ,
242
+ }),
244
243
),
245
244
},
246
245
{
@@ -257,8 +256,6 @@ func testAccClientVPNEndpoint_msADAuthAndMutualAuth(t *testing.T) {
257
256
var v ec2.ClientVpnEndpoint
258
257
rName := sdkacctest .RandomWithPrefix (acctest .ResourcePrefix )
259
258
resourceName := "aws_ec2_client_vpn_endpoint.test"
260
- dsDirectoryResourceName := "aws_directory_service_directory.test"
261
- serverCertificateResourceName := "aws_acm_certificate.test"
262
259
domainName := acctest .RandomDomainName ()
263
260
264
261
if testing .Short () {
@@ -276,10 +273,12 @@ func testAccClientVPNEndpoint_msADAuthAndMutualAuth(t *testing.T) {
276
273
Check : resource .ComposeTestCheckFunc (
277
274
testAccCheckClientVPNEndpointExists (ctx , resourceName , & v ),
278
275
resource .TestCheckResourceAttr (resourceName , "authentication_options.#" , "2" ),
279
- resource .TestCheckResourceAttr (resourceName , "authentication_options.0.type" , "directory-service-authentication" ),
280
- resource .TestCheckResourceAttrPair (resourceName , "authentication_options.0.active_directory_id" , dsDirectoryResourceName , "id" ),
281
- resource .TestCheckResourceAttr (resourceName , "authentication_options.1.type" , "certificate-authentication" ),
282
- resource .TestCheckResourceAttrPair (resourceName , "authentication_options.0.root_certificate_chain_arn" , serverCertificateResourceName , "arn" ),
276
+ resource .TestCheckTypeSetElemNestedAttrs (resourceName , "authentication_options.*" , map [string ]string {
277
+ "type" : "directory-service-authentication" ,
278
+ }),
279
+ resource .TestCheckTypeSetElemNestedAttrs (resourceName , "authentication_options.*" , map [string ]string {
280
+ "type" : "certificate-authentication" ,
281
+ }),
283
282
),
284
283
},
285
284
{
@@ -297,7 +296,6 @@ func testAccClientVPNEndpoint_federatedAuth(t *testing.T) {
297
296
rName := sdkacctest .RandomWithPrefix (acctest .ResourcePrefix )
298
297
idpEntityID := fmt .Sprintf ("https://%s" , acctest .RandomDomainName ())
299
298
resourceName := "aws_ec2_client_vpn_endpoint.test"
300
- samlProviderResourceName := "aws_iam_saml_provider.test"
301
299
302
300
resource .ParallelTest (t , resource.TestCase {
303
301
PreCheck : func () { acctest .PreCheck (t ); testAccPreCheckClientVPNSyncronize (t ) },
@@ -310,8 +308,9 @@ func testAccClientVPNEndpoint_federatedAuth(t *testing.T) {
310
308
Check : resource .ComposeTestCheckFunc (
311
309
testAccCheckClientVPNEndpointExists (ctx , resourceName , & v ),
312
310
resource .TestCheckResourceAttr (resourceName , "authentication_options.#" , "1" ),
313
- resource .TestCheckResourceAttr (resourceName , "authentication_options.0.type" , "federated-authentication" ),
314
- resource .TestCheckResourceAttrPair (resourceName , "authentication_options.0.saml_provider_arn" , samlProviderResourceName , "arn" ),
311
+ resource .TestCheckTypeSetElemNestedAttrs (resourceName , "authentication_options.*" , map [string ]string {
312
+ "type" : "federated-authentication" ,
313
+ }),
315
314
),
316
315
},
317
316
{
@@ -329,8 +328,6 @@ func testAccClientVPNEndpoint_federatedAuthWithSelfServiceProvider(t *testing.T)
329
328
rName := sdkacctest .RandomWithPrefix (acctest .ResourcePrefix )
330
329
idpEntityID := fmt .Sprintf ("https://%s" , acctest .RandomDomainName ())
331
330
resourceName := "aws_ec2_client_vpn_endpoint.test"
332
- samlProvider1ResourceName := "aws_iam_saml_provider.test1"
333
- samlProvider2ResourceName := "aws_iam_saml_provider.test2"
334
331
335
332
resource .ParallelTest (t , resource.TestCase {
336
333
PreCheck : func () { acctest .PreCheck (t ); testAccPreCheckClientVPNSyncronize (t ) },
@@ -343,9 +340,9 @@ func testAccClientVPNEndpoint_federatedAuthWithSelfServiceProvider(t *testing.T)
343
340
Check : resource .ComposeTestCheckFunc (
344
341
testAccCheckClientVPNEndpointExists (ctx , resourceName , & v ),
345
342
resource .TestCheckResourceAttr (resourceName , "authentication_options.#" , "1" ),
346
- resource .TestCheckResourceAttr (resourceName , "authentication_options.0.type " , "federated-authentication" ),
347
- resource . TestCheckResourceAttrPair ( resourceName , "authentication_options.0.saml_provider_arn" , samlProvider1ResourceName , "arn" ) ,
348
- resource . TestCheckResourceAttrPair ( resourceName , "authentication_options.0.self_service_saml_provider_arn" , samlProvider2ResourceName , "arn" ),
343
+ resource .TestCheckTypeSetElemNestedAttrs (resourceName , "authentication_options.* " , map [ string ] string {
344
+ "type" : "federated-authentication" ,
345
+ } ),
349
346
),
350
347
},
351
348
{
@@ -789,9 +786,7 @@ resource "aws_acm_certificate" %[1]q {
789
786
}
790
787
791
788
func testAccClientVPNEndpointConfig_msADBase (rName , domain string ) string {
792
- return acctest .ConfigCompose (
793
- acctest .ConfigAvailableAZsNoOptIn (),
794
- fmt .Sprintf (`
789
+ return acctest .ConfigCompose (acctest .ConfigVPCWithSubnets (rName , 2 ), fmt .Sprintf (`
795
790
resource "aws_directory_service_directory" "test" {
796
791
name = %[2]q
797
792
password = "SuperSecretPassw0rd"
@@ -802,25 +797,6 @@ resource "aws_directory_service_directory" "test" {
802
797
subnet_ids = aws_subnet.test[*].id
803
798
}
804
799
}
805
-
806
- resource "aws_vpc" "test" {
807
- cidr_block = "10.0.0.0/16"
808
-
809
- tags = {
810
- Name = %[1]q
811
- }
812
- }
813
-
814
- resource "aws_subnet" "test" {
815
- count = 2
816
- availability_zone = data.aws_availability_zones.available.names[count.index]
817
- cidr_block = cidrsubnet(aws_vpc.test.cidr_block, 8, count.index)
818
- vpc_id = aws_vpc.test.id
819
-
820
- tags = {
821
- Name = %[1]q
822
- }
823
- }
824
800
` , rName , domain ))
825
801
}
826
802
@@ -1048,7 +1024,7 @@ func testAccClientVPNEndpointConfig_microsoftAD(t *testing.T, rName, domain stri
1048
1024
fmt .Sprintf (`
1049
1025
resource "aws_ec2_client_vpn_endpoint" "test" {
1050
1026
server_certificate_arn = aws_acm_certificate.test.arn
1051
- client_cidr_block = "10.0 .0.0/16 "
1027
+ client_cidr_block = "10.1 .0.0/20 "
1052
1028
1053
1029
authentication_options {
1054
1030
type = "directory-service-authentication"
@@ -1073,7 +1049,7 @@ func testAccClientVPNEndpointConfig_mutualAuthAndMicrosoftAD(t *testing.T, rName
1073
1049
fmt .Sprintf (`
1074
1050
resource "aws_ec2_client_vpn_endpoint" "test" {
1075
1051
server_certificate_arn = aws_acm_certificate.test.arn
1076
- client_cidr_block = "10.0 .0.0/16 "
1052
+ client_cidr_block = "10.1 .0.0/20 "
1077
1053
1078
1054
authentication_options {
1079
1055
type = "directory-service-authentication"
@@ -1303,7 +1279,7 @@ locals {
1303
1279
1304
1280
resource "aws_ec2_client_vpn_endpoint" "test" {
1305
1281
server_certificate_arn = aws_acm_certificate.test.arn
1306
- client_cidr_block = "10.0 .0.0/16 "
1282
+ client_cidr_block = "10.1 .0.0/22 "
1307
1283
1308
1284
authentication_options {
1309
1285
type = "certificate-authentication"
0 commit comments