Skip to content

Commit

Permalink
Adding initial files
Browse files Browse the repository at this point in the history
  • Loading branch information
Steven Ayers authored and danielcmessias committed Jun 21, 2022
1 parent 9623efd commit 25fe426
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .changelog/24315.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
```release-note:note:enhancement
resource/aws_lakeformation_permissions: Add LF-tag support
datasource/aws_lakeformation_permissions: Add LF-tag support
```
40 changes: 40 additions & 0 deletions internal/service/lakeformation/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ func FilterPermissions(input *lakeformation.ListPermissionsInput, tableType stri
return FilterDatabasePermissions(input.Principal.DataLakePrincipalIdentifier, allPermissions)
}

if input.Resource.LFTag != nil {
return FilterLFTagPermissions(input.Principal.DataLakePrincipalIdentifier, allPermissions)
}

if input.Resource.LFTagPolicy != nil {
return FilterLFTagPolicyPermissions(input.Principal.DataLakePrincipalIdentifier, allPermissions)
}

if tableType == TableTypeTableWithColumns {
return FilterTableWithColumnsPermissions(input.Principal.DataLakePrincipalIdentifier, input.Resource.Table, columnNames, excludedColumnNames, columnWildcard, allPermissions)
}
Expand Down Expand Up @@ -176,3 +184,35 @@ func FilterDatabasePermissions(principal *string, allPermissions []*lakeformatio

return cleanPermissions
}

func FilterLFTagPermissions(principal *string, allPermissions []*lakeformation.PrincipalResourcePermissions) []*lakeformation.PrincipalResourcePermissions {
var cleanPermissions []*lakeformation.PrincipalResourcePermissions

for _, perm := range allPermissions {
if aws.StringValue(principal) != aws.StringValue(perm.Principal.DataLakePrincipalIdentifier) {
continue
}

if perm.Resource.LFTag != nil {
cleanPermissions = append(cleanPermissions, perm)
}
}

return cleanPermissions
}

func FilterLFTagPolicyPermissions(principal *string, allPermissions []*lakeformation.PrincipalResourcePermissions) []*lakeformation.PrincipalResourcePermissions {
var cleanPermissions []*lakeformation.PrincipalResourcePermissions

for _, perm := range allPermissions {
if aws.StringValue(principal) != aws.StringValue(perm.Principal.DataLakePrincipalIdentifier) {
continue
}

if perm.Resource.LFTagPolicy != nil {
cleanPermissions = append(cleanPermissions, perm)
}
}

return cleanPermissions
}
4 changes: 4 additions & 0 deletions internal/service/lakeformation/lakeformation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,15 @@ func TestAccLakeFormation_serial(t *testing.T) {
"databaseMultiple": testAccPermissions_databaseMultiple,
"dataLocation": testAccPermissions_dataLocation,
"disappears": testAccPermissions_disappears,
"lfTag": testAccAWSLakeFormationPermissions_lf_tag,
"lfTagPolicy": testAccAWSLakeFormationPermissions_lf_tag_policy,
},
"PermissionsDataSource": {
"basic": testAccPermissionsDataSource_basic,
"database": testAccPermissionsDataSource_database,
"dataLocation": testAccPermissionsDataSource_dataLocation,
"lfTag": testAccPermissionsDataSource_lf_tag,
"lfTagPolicy": testAccPermissionsDataSource_lf_tag_policy,
"table": testAccPermissionsDataSource_table,
"tableWithColumns": testAccPermissionsDataSource_tableWithColumns,
},
Expand Down

0 comments on commit 25fe426

Please sign in to comment.