@@ -2,9 +2,9 @@ import { Template } from '@aws-cdk/assertions';
2
2
import * as iam from '@aws-cdk/aws-iam' ;
3
3
import * as kms from '@aws-cdk/aws-kms' ;
4
4
import * as s3 from '@aws-cdk/aws-s3' ;
5
+ import { testFutureBehavior } from '@aws-cdk/cdk-build-tools/lib/feature-flag' ;
5
6
import * as cdk from '@aws-cdk/core' ;
6
7
import * as cxapi from '@aws-cdk/cx-api' ;
7
- import { testFutureBehavior } from '@aws-cdk/cdk-build-tools/lib/feature-flag' ;
8
8
import * as glue from '../lib' ;
9
9
import { CfnTable } from '../lib/glue.generated' ;
10
10
@@ -79,7 +79,6 @@ test('unpartitioned JSON table', () => {
79
79
TableType : 'EXTERNAL_TABLE' ,
80
80
} ,
81
81
} ) ;
82
-
83
82
} ) ;
84
83
85
84
test ( 'partitioned JSON table' , ( ) => {
@@ -157,7 +156,6 @@ test('partitioned JSON table', () => {
157
156
TableType : 'EXTERNAL_TABLE' ,
158
157
} ,
159
158
} ) ;
160
-
161
159
} ) ;
162
160
163
161
test ( 'compressed table' , ( ) => {
@@ -223,7 +221,6 @@ test('compressed table', () => {
223
221
TableType : 'EXTERNAL_TABLE' ,
224
222
} ,
225
223
} ) ;
226
-
227
224
} ) ;
228
225
229
226
test ( 'table.node.defaultChild' , ( ) => {
@@ -325,7 +322,6 @@ test('encrypted table: SSE-S3', () => {
325
322
] ,
326
323
} ,
327
324
} ) ;
328
-
329
325
} ) ;
330
326
331
327
test ( 'encrypted table: SSE-KMS (implicitly created key)' , ( ) => {
@@ -413,7 +409,6 @@ test('encrypted table: SSE-KMS (implicitly created key)', () => {
413
409
TableType : 'EXTERNAL_TABLE' ,
414
410
} ,
415
411
} ) ;
416
-
417
412
} ) ;
418
413
419
414
test ( 'encrypted table: SSE-KMS (explicitly created key)' , ( ) => {
@@ -506,7 +501,6 @@ test('encrypted table: SSE-KMS (explicitly created key)', () => {
506
501
TableType : 'EXTERNAL_TABLE' ,
507
502
} ,
508
503
} ) ;
509
-
510
504
} ) ;
511
505
512
506
test ( 'encrypted table: SSE-KMS_MANAGED' , ( ) => {
@@ -585,7 +579,6 @@ test('encrypted table: SSE-KMS_MANAGED', () => {
585
579
TableType : 'EXTERNAL_TABLE' ,
586
580
} ,
587
581
} ) ;
588
-
589
582
} ) ;
590
583
591
584
test ( 'encrypted table: CSE-KMS (implicitly created key)' , ( ) => {
@@ -654,7 +647,6 @@ test('encrypted table: CSE-KMS (implicitly created key)', () => {
654
647
TableType : 'EXTERNAL_TABLE' ,
655
648
} ,
656
649
} ) ;
657
-
658
650
} ) ;
659
651
660
652
test ( 'encrypted table: CSE-KMS (explicitly created key)' , ( ) => {
@@ -729,7 +721,6 @@ test('encrypted table: CSE-KMS (explicitly created key)', () => {
729
721
TableType : 'EXTERNAL_TABLE' ,
730
722
} ,
731
723
} ) ;
732
-
733
724
} ) ;
734
725
735
726
test ( 'encrypted table: CSE-KMS (explicitly passed bucket and key)' , ( ) => {
@@ -806,7 +797,6 @@ test('encrypted table: CSE-KMS (explicitly passed bucket and key)', () => {
806
797
TableType : 'EXTERNAL_TABLE' ,
807
798
} ,
808
799
} ) ;
809
-
810
800
} ) ;
811
801
812
802
test ( 'explicit s3 bucket and prefix' , ( ) => {
@@ -874,7 +864,6 @@ test('explicit s3 bucket and prefix', () => {
874
864
TableType : 'EXTERNAL_TABLE' ,
875
865
} ,
876
866
} ) ;
877
-
878
867
} ) ;
879
868
880
869
test ( 'explicit s3 bucket and with empty prefix' , ( ) => {
@@ -942,7 +931,72 @@ test('explicit s3 bucket and with empty prefix', () => {
942
931
TableType : 'EXTERNAL_TABLE' ,
943
932
} ,
944
933
} ) ;
934
+ } ) ;
935
+
936
+ test ( 'grants: custom' , ( ) => {
937
+ const stack = new cdk . Stack ( ) ;
938
+ const user = new iam . User ( stack , 'User' ) ;
939
+ const database = new glue . Database ( stack , 'Database' , {
940
+ databaseName : 'database' ,
941
+ } ) ;
945
942
943
+ const table = new glue . Table ( stack , 'Table' , {
944
+ database,
945
+ tableName : 'table' ,
946
+ columns : [ {
947
+ name : 'col' ,
948
+ type : glue . Schema . STRING ,
949
+ } ] ,
950
+ compressed : true ,
951
+ dataFormat : glue . DataFormat . JSON ,
952
+ } ) ;
953
+
954
+ table . grant ( user , [ 'glue:UpdateTable' ] ) ;
955
+
956
+ Template . fromStack ( stack ) . hasResourceProperties ( 'AWS::IAM::Policy' , {
957
+ PolicyDocument : {
958
+ Statement : [
959
+ {
960
+ Action : 'glue:UpdateTable' ,
961
+ Effect : 'Allow' ,
962
+ Resource : {
963
+ 'Fn::Join' : [
964
+ '' ,
965
+ [
966
+ 'arn:' ,
967
+ {
968
+ Ref : 'AWS::Partition' ,
969
+ } ,
970
+ ':glue:' ,
971
+ {
972
+ Ref : 'AWS::Region' ,
973
+ } ,
974
+ ':' ,
975
+ {
976
+ Ref : 'AWS::AccountId' ,
977
+ } ,
978
+ ':table/' ,
979
+ {
980
+ Ref : 'DatabaseB269D8BB' ,
981
+ } ,
982
+ '/' ,
983
+ {
984
+ Ref : 'Table4C2D914F' ,
985
+ } ,
986
+ ] ,
987
+ ] ,
988
+ } ,
989
+ } ,
990
+ ] ,
991
+ Version : '2012-10-17' ,
992
+ } ,
993
+ PolicyName : 'UserDefaultPolicy1F97781E' ,
994
+ Users : [
995
+ {
996
+ Ref : 'User00B015A1' ,
997
+ } ,
998
+ ] ,
999
+ } ) ;
946
1000
} ) ;
947
1001
948
1002
test ( 'grants: read only' , ( ) => {
@@ -970,7 +1024,6 @@ test('grants: read only', () => {
970
1024
Statement : [
971
1025
{
972
1026
Action : [
973
- 'glue:BatchDeletePartition' ,
974
1027
'glue:BatchGetPartition' ,
975
1028
'glue:GetPartition' ,
976
1029
'glue:GetPartitions' ,
@@ -1048,7 +1101,6 @@ test('grants: read only', () => {
1048
1101
} ,
1049
1102
] ,
1050
1103
} ) ;
1051
-
1052
1104
} ) ;
1053
1105
1054
1106
testFutureBehavior ( 'grants: write only' , s3GrantWriteCtx , cdk . App , ( app ) => {
@@ -1151,7 +1203,6 @@ testFutureBehavior('grants: write only', s3GrantWriteCtx, cdk.App, (app) => {
1151
1203
} ,
1152
1204
] ,
1153
1205
} ) ;
1154
-
1155
1206
} ) ;
1156
1207
1157
1208
testFutureBehavior ( 'grants: read and write' , s3GrantWriteCtx , cdk . App , ( app ) => {
@@ -1179,7 +1230,6 @@ testFutureBehavior('grants: read and write', s3GrantWriteCtx, cdk.App, (app) =>
1179
1230
Statement : [
1180
1231
{
1181
1232
Action : [
1182
- 'glue:BatchDeletePartition' ,
1183
1233
'glue:BatchGetPartition' ,
1184
1234
'glue:GetPartition' ,
1185
1235
'glue:GetPartitions' ,
@@ -1188,6 +1238,7 @@ testFutureBehavior('grants: read and write', s3GrantWriteCtx, cdk.App, (app) =>
1188
1238
'glue:GetTableVersion' ,
1189
1239
'glue:GetTableVersions' ,
1190
1240
'glue:BatchCreatePartition' ,
1241
+ 'glue:BatchDeletePartition' ,
1191
1242
'glue:CreatePartition' ,
1192
1243
'glue:DeletePartition' ,
1193
1244
'glue:UpdatePartition' ,
@@ -1264,7 +1315,6 @@ testFutureBehavior('grants: read and write', s3GrantWriteCtx, cdk.App, (app) =>
1264
1315
} ,
1265
1316
] ,
1266
1317
} ) ;
1267
-
1268
1318
} ) ;
1269
1319
1270
1320
test ( 'validate: at least one column' , ( ) => {
0 commit comments