Skip to content
238 changes: 13 additions & 225 deletions packages/@aws-cdk/aws-glue/test/table.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -345,50 +345,6 @@ test('encrypted table: SSE-KMS (implicitly created key)', () => {
equal(table.encryptionKey, table.bucket.encryptionKey);

cdkExpect(stack).to(haveResource('AWS::KMS::Key', {
KeyPolicy: {
Statement: [
{
Action: [
'kms:Create*',
'kms:Describe*',
'kms:Enable*',
'kms:List*',
'kms:Put*',
'kms:Update*',
'kms:Revoke*',
'kms:Disable*',
'kms:Get*',
'kms:Delete*',
'kms:ScheduleKeyDeletion',
'kms:CancelKeyDeletion',
'kms:GenerateDataKey',
'kms:TagResource',
'kms:UntagResource',
],
Effect: 'Allow',
Principal: {
AWS: {
'Fn::Join': [
'',
[
'arn:',
{
Ref: 'AWS::Partition',
},
':iam::',
{
Ref: 'AWS::AccountId',
},
':root',
],
],
},
},
Resource: '*',
},
],
Version: '2012-10-17',
},
Description: 'Created by Default/Table/Bucket',
}));

Expand Down Expand Up @@ -462,7 +418,9 @@ test('encrypted table: SSE-KMS (explicitly created key)', () => {
const database = new glue.Database(stack, 'Database', {
databaseName: 'database',
});
const encryptionKey = new kms.Key(stack, 'MyKey');
const encryptionKey = new kms.Key(stack, 'MyKey', {
description: 'OurKey',
});

const table = new glue.Table(stack, 'Table', {
database,
Expand All @@ -480,50 +438,7 @@ test('encrypted table: SSE-KMS (explicitly created key)', () => {
notEqual(table.encryptionKey, undefined);

cdkExpect(stack).to(haveResource('AWS::KMS::Key', {
KeyPolicy: {
Statement: [
{
Action: [
'kms:Create*',
'kms:Describe*',
'kms:Enable*',
'kms:List*',
'kms:Put*',
'kms:Update*',
'kms:Revoke*',
'kms:Disable*',
'kms:Get*',
'kms:Delete*',
'kms:ScheduleKeyDeletion',
'kms:CancelKeyDeletion',
'kms:GenerateDataKey',
'kms:TagResource',
'kms:UntagResource',
],
Effect: 'Allow',
Principal: {
AWS: {
'Fn::Join': [
'',
[
'arn:',
{
Ref: 'AWS::Partition',
},
':iam::',
{
Ref: 'AWS::AccountId',
},
':root',
],
],
},
},
Resource: '*',
},
],
Version: '2012-10-17',
},
Description: 'OurKey',
}));

cdkExpect(stack).to(haveResource('AWS::S3::Bucket', {
Expand Down Expand Up @@ -690,52 +605,7 @@ test('encrypted table: CSE-KMS (implicitly created key)', () => {
notEqual(table.encryptionKey, undefined);
equal(table.bucket.encryptionKey, undefined);

cdkExpect(stack).to(haveResource('AWS::KMS::Key', {
KeyPolicy: {
Statement: [
{
Action: [
'kms:Create*',
'kms:Describe*',
'kms:Enable*',
'kms:List*',
'kms:Put*',
'kms:Update*',
'kms:Revoke*',
'kms:Disable*',
'kms:Get*',
'kms:Delete*',
'kms:ScheduleKeyDeletion',
'kms:CancelKeyDeletion',
'kms:GenerateDataKey',
'kms:TagResource',
'kms:UntagResource',
],
Effect: 'Allow',
Principal: {
AWS: {
'Fn::Join': [
'',
[
'arn:',
{
Ref: 'AWS::Partition',
},
':iam::',
{
Ref: 'AWS::AccountId',
},
':root',
],
],
},
},
Resource: '*',
},
],
Version: '2012-10-17',
},
}));
cdkExpect(stack).to(haveResource('AWS::KMS::Key'));

cdkExpect(stack).to(haveResource('AWS::Glue::Table', {
CatalogId: {
Expand Down Expand Up @@ -789,7 +659,9 @@ test('encrypted table: CSE-KMS (explicitly created key)', () => {
const database = new glue.Database(stack, 'Database', {
databaseName: 'database',
});
const encryptionKey = new kms.Key(stack, 'MyKey');
const encryptionKey = new kms.Key(stack, 'MyKey', {
description: 'MyKey',
});

const table = new glue.Table(stack, 'Table', {
database,
Expand All @@ -807,50 +679,7 @@ test('encrypted table: CSE-KMS (explicitly created key)', () => {
equal(table.bucket.encryptionKey, undefined);

cdkExpect(stack).to(haveResource('AWS::KMS::Key', {
KeyPolicy: {
Statement: [
{
Action: [
'kms:Create*',
'kms:Describe*',
'kms:Enable*',
'kms:List*',
'kms:Put*',
'kms:Update*',
'kms:Revoke*',
'kms:Disable*',
'kms:Get*',
'kms:Delete*',
'kms:ScheduleKeyDeletion',
'kms:CancelKeyDeletion',
'kms:GenerateDataKey',
'kms:TagResource',
'kms:UntagResource',
],
Effect: 'Allow',
Principal: {
AWS: {
'Fn::Join': [
'',
[
'arn:',
{
Ref: 'AWS::Partition',
},
':iam::',
{
Ref: 'AWS::AccountId',
},
':root',
],
],
},
},
Resource: '*',
},
],
Version: '2012-10-17',
},
Description: 'MyKey',
}));

cdkExpect(stack).to(haveResource('AWS::Glue::Table', {
Expand Down Expand Up @@ -906,7 +735,9 @@ test('encrypted table: CSE-KMS (explicitly passed bucket and key)', () => {
databaseName: 'database',
});
const bucket = new s3.Bucket(stack, 'Bucket');
const encryptionKey = new kms.Key(stack, 'MyKey');
const encryptionKey = new kms.Key(stack, 'MyKey', {
description: 'MyKey',
});

const table = new glue.Table(stack, 'Table', {
database,
Expand All @@ -925,50 +756,7 @@ test('encrypted table: CSE-KMS (explicitly passed bucket and key)', () => {
equal(table.bucket.encryptionKey, undefined);

cdkExpect(stack).to(haveResource('AWS::KMS::Key', {
KeyPolicy: {
Statement: [
{
Action: [
'kms:Create*',
'kms:Describe*',
'kms:Enable*',
'kms:List*',
'kms:Put*',
'kms:Update*',
'kms:Revoke*',
'kms:Disable*',
'kms:Get*',
'kms:Delete*',
'kms:ScheduleKeyDeletion',
'kms:CancelKeyDeletion',
'kms:GenerateDataKey',
'kms:TagResource',
'kms:UntagResource',
],
Effect: 'Allow',
Principal: {
AWS: {
'Fn::Join': [
'',
[
'arn:',
{
Ref: 'AWS::Partition',
},
':iam::',
{
Ref: 'AWS::AccountId',
},
':root',
],
],
},
},
Resource: '*',
},
],
Version: '2012-10-17',
},
Description: 'MyKey',
}));

cdkExpect(stack).to(haveResource('AWS::Glue::Table', {
Expand Down
Loading