@@ -257,6 +257,43 @@ func TestAccEKSAccessEntry_username(t *testing.T) {
257
257
})
258
258
}
259
259
260
+ func TestAccEKSAccessEntry_eventualConsistency (t * testing.T ) {
261
+ ctx := acctest .Context (t )
262
+ if testing .Short () {
263
+ t .Skip ("skipping long-running test in short mode" )
264
+ }
265
+
266
+ var accessentry types.AccessEntry
267
+ rName := sdkacctest .RandomWithPrefix (acctest .ResourcePrefix )
268
+ resourceName := "aws_eks_access_entry.test"
269
+
270
+ resource .ParallelTest (t , resource.TestCase {
271
+ PreCheck : func () {
272
+ acctest .PreCheck (ctx , t )
273
+ testAccPreCheck (ctx , t )
274
+ },
275
+ ErrorCheck : acctest .ErrorCheck (t , names .EKSEndpointID ),
276
+ ProtoV5ProviderFactories : acctest .ProtoV5ProviderFactories ,
277
+ CheckDestroy : testAccCheckAccessEntryDestroy (ctx ),
278
+ Steps : []resource.TestStep {
279
+ {
280
+ Config : testAccAccessEntryConfig_eventualConsistency (rName ),
281
+ Check : resource .ComposeTestCheckFunc (
282
+ testAccCheckAccessEntryExists (ctx , resourceName , & accessentry ),
283
+ acctest .CheckResourceAttrGreaterThanOrEqualValue (resourceName , "kubernetes_groups.#" , 1 ),
284
+ resource .TestCheckResourceAttr (resourceName , "type" , "EC2_LINUX" ),
285
+ resource .TestCheckResourceAttrSet (resourceName , "user_name" ),
286
+ ),
287
+ },
288
+ {
289
+ ResourceName : resourceName ,
290
+ ImportState : true ,
291
+ ImportStateVerify : true ,
292
+ },
293
+ },
294
+ })
295
+ }
296
+
260
297
func testAccCheckAccessEntryDestroy (ctx context.Context ) resource.TestCheckFunc {
261
298
return func (s * terraform.State ) error {
262
299
conn := acctest .Provider .Meta ().(* conns.AWSClient ).EKSClient (ctx )
@@ -449,6 +486,36 @@ resource "aws_eks_access_entry" "test" {
449
486
` , rName ))
450
487
}
451
488
489
+ func testAccAccessEntryConfig_eventualConsistency (rName string ) string {
490
+ return acctest .ConfigCompose (testAccAccessEntryConfig_base (rName ), `
491
+ resource "aws_iam_role" "test2" {
492
+ name = "${aws_eks_cluster.test.name}-2"
493
+
494
+ assume_role_policy = <<POLICY
495
+ {
496
+ "Version": "2012-10-17",
497
+ "Statement": [
498
+ {
499
+ "Effect": "Allow",
500
+ "Principal": {
501
+ "Service": "eks.${data.aws_partition.current.dns_suffix}"
502
+ },
503
+ "Action": "sts:AssumeRole"
504
+ }
505
+ ]
506
+ }
507
+ POLICY
508
+ }
509
+
510
+ resource "aws_eks_access_entry" "test" {
511
+ cluster_name = aws_eks_cluster.test.name
512
+ principal_arn = aws_iam_role.test2.arn
513
+
514
+ type = "EC2_LINUX"
515
+ }
516
+ ` )
517
+ }
518
+
452
519
func testAccAccessEntryConfig_username (rName , username string ) string {
453
520
return acctest .ConfigCompose (testAccAccessEntryConfig_base (rName ), fmt .Sprintf (`
454
521
resource "aws_iam_user" "test" {
0 commit comments