@@ -87,6 +87,36 @@ func testAccAWSLakeFormationPermissionsDataSource_database(t *testing.T) {
87
87
})
88
88
}
89
89
90
+ func testAccAWSLakeFormationPermissionsDataSource_policy_tag (t * testing.T ) {
91
+ rName := acctest .RandomWithPrefix ("tf-acc-test" )
92
+ resourceName := "aws_lakeformation_permissions.test"
93
+ dataSourceName := "data.aws_lakeformation_permissions.test"
94
+
95
+ resource .Test (t , resource.TestCase {
96
+ PreCheck : func () { testAccPreCheck (t ); testAccPartitionHasServicePreCheck (lakeformation .EndpointsID , t ) },
97
+ ErrorCheck : testAccErrorCheck (t , lakeformation .EndpointsID ),
98
+ Providers : testAccProviders ,
99
+ CheckDestroy : testAccCheckAWSLakeFormationPermissionsDestroy ,
100
+ Steps : []resource.TestStep {
101
+ {
102
+ Config : testAccAWSLakeFormationPermissionsDataSourceConfig_policy_tag (rName ),
103
+ Check : resource .ComposeTestCheckFunc (
104
+ resource .TestCheckResourceAttrPair (resourceName , "principal" , dataSourceName , "principal" ),
105
+ resource .TestCheckResourceAttrPair (resourceName , "policy_tag.#" , dataSourceName , "policy_tag.#" ),
106
+ resource .TestCheckResourceAttrPair (resourceName , "policy_tag.0.key" , dataSourceName , "policy_tag.0.key" ),
107
+ resource .TestCheckResourceAttrPair (resourceName , "policy_tag.0.values" , dataSourceName , "policy_tag.0.values" ),
108
+ resource .TestCheckResourceAttrPair (resourceName , "permissions.#" , dataSourceName , "permissions.#" ),
109
+ resource .TestCheckResourceAttrPair (resourceName , "permissions.0" , dataSourceName , "permissions.0" ),
110
+ resource .TestCheckResourceAttrPair (resourceName , "permissions.1" , dataSourceName , "permissions.1" ),
111
+ resource .TestCheckResourceAttrPair (resourceName , "permissions_with_grant_option.#" , dataSourceName , "permissions_with_grant_option.#" ),
112
+ resource .TestCheckResourceAttrPair (resourceName , "permissions_with_grant_option.0" , dataSourceName , "permissions_with_grant_option.0" ),
113
+ resource .TestCheckResourceAttrPair (resourceName , "permissions_with_grant_option.1" , dataSourceName , "permissions_with_grant_option.1" ),
114
+ ),
115
+ },
116
+ },
117
+ })
118
+ }
119
+
90
120
func testAccAWSLakeFormationPermissionsDataSource_table (t * testing.T ) {
91
121
rName := acctest .RandomWithPrefix ("tf-acc-test" )
92
122
resourceName := "aws_lakeformation_permissions.test"
@@ -313,6 +343,70 @@ data "aws_lakeformation_permissions" "test" {
313
343
` , rName )
314
344
}
315
345
346
+ func testAccAWSLakeFormationPermissionsDataSourceConfig_policy_tag (rName string ) string {
347
+ return fmt .Sprintf (`
348
+ data "aws_partition" "current" {}
349
+
350
+ resource "aws_iam_role" "test" {
351
+ name = %[1]q
352
+ path = "/"
353
+
354
+ assume_role_policy = <<EOF
355
+ {
356
+ "Version": "2012-10-17",
357
+ "Statement": [
358
+ {
359
+ "Action": "sts:AssumeRole",
360
+ "Principal": {
361
+ "Service": "glue.${data.aws_partition.current.dns_suffix}"
362
+ },
363
+ "Effect": "Allow",
364
+ "Sid": ""
365
+ }
366
+ ]
367
+ }
368
+ EOF
369
+ }
370
+
371
+ data "aws_caller_identity" "current" {}
372
+
373
+ resource "aws_lakeformation_data_lake_settings" "test" {
374
+ admins = [data.aws_caller_identity.current.arn]
375
+ }
376
+
377
+ resource "aws_lakeformation_policy_tag" "test" {
378
+ key = %[1]q
379
+ values = ["value1", "value2"]
380
+
381
+ # for consistency, ensure that admins are setup before testing
382
+ depends_on = [aws_lakeformation_data_lake_settings.test]
383
+ }
384
+
385
+ resource "aws_lakeformation_permissions" "test" {
386
+ permissions = ["ASSOCIATE", "DESCRIBE"]
387
+ permissions_with_grant_option = ["ASSOCIATE", "DESCRIBE"]
388
+ principal = aws_iam_role.test.arn
389
+
390
+ policy_tag {
391
+ key = aws_lakeformation_policy_tag.test.key
392
+ values = aws_lakeformation_policy_tag.test.values
393
+ }
394
+
395
+ # for consistency, ensure that admins are setup before testing
396
+ depends_on = [aws_lakeformation_data_lake_settings.test]
397
+ }
398
+
399
+ data "aws_lakeformation_permissions" "test" {
400
+ principal = aws_lakeformation_permissions.test.principal
401
+
402
+ policy_tag {
403
+ key = aws_lakeformation_policy_tag.test.key
404
+ values = aws_lakeformation_policy_tag.test.values
405
+ }
406
+ }
407
+ ` , rName )
408
+ }
409
+
316
410
func testAccAWSLakeFormationPermissionsDataSourceConfig_table (rName string ) string {
317
411
return fmt .Sprintf (`
318
412
data "aws_partition" "current" {}
0 commit comments