@friggframework/devtools 2.0.0--canary.428.5c4220d.0 → 2.0.0--canary.428.1c210bc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1050,6 +1050,17 @@ const composeServerlessDefinition = async (AppDefinition) => {
|
|
|
1050
1050
|
`Using existing KMS key: ${discoveredResources.defaultKmsKeyId}`
|
|
1051
1051
|
);
|
|
1052
1052
|
|
|
1053
|
+
// Create a CloudFormation-managed alias to track the discovered key
|
|
1054
|
+
// This ensures CloudFormation always has a resource to manage, preventing deletion
|
|
1055
|
+
definition.resources.Resources.FriggKMSKeyAlias = {
|
|
1056
|
+
Type: 'AWS::KMS::Alias',
|
|
1057
|
+
DeletionPolicy: 'Retain',
|
|
1058
|
+
Properties: {
|
|
1059
|
+
AliasName: 'alias/${self:service}-${self:provider.stage}-frigg-kms',
|
|
1060
|
+
TargetKeyId: discoveredResources.defaultKmsKeyId
|
|
1061
|
+
}
|
|
1062
|
+
};
|
|
1063
|
+
|
|
1053
1064
|
definition.provider.iamRoleStatements.push({
|
|
1054
1065
|
Effect: 'Allow',
|
|
1055
1066
|
Action: ['kms:GenerateDataKey', 'kms:Decrypt'],
|
|
@@ -1065,6 +1076,8 @@ const composeServerlessDefinition = async (AppDefinition) => {
|
|
|
1065
1076
|
|
|
1066
1077
|
definition.resources.Resources.FriggKMSKey = {
|
|
1067
1078
|
Type: 'AWS::KMS::Key',
|
|
1079
|
+
DeletionPolicy: 'Retain',
|
|
1080
|
+
UpdateReplacePolicy: 'Retain',
|
|
1068
1081
|
Properties: {
|
|
1069
1082
|
EnableKeyRotation: true,
|
|
1070
1083
|
Description: 'Frigg KMS key for field-level encryption',
|
|
@@ -1110,6 +1123,10 @@ const composeServerlessDefinition = async (AppDefinition) => {
|
|
|
1110
1123
|
Key: 'Name',
|
|
1111
1124
|
Value: '${self:service}-${self:provider.stage}-frigg-kms-key',
|
|
1112
1125
|
},
|
|
1126
|
+
{
|
|
1127
|
+
Key: 'ManagedBy',
|
|
1128
|
+
Value: 'Frigg',
|
|
1129
|
+
},
|
|
1113
1130
|
{
|
|
1114
1131
|
Key: 'Purpose',
|
|
1115
1132
|
Value: 'Field-level encryption for Frigg application',
|
|
@@ -1118,6 +1135,16 @@ const composeServerlessDefinition = async (AppDefinition) => {
|
|
|
1118
1135
|
},
|
|
1119
1136
|
};
|
|
1120
1137
|
|
|
1138
|
+
// Create an alias for the new KMS key for consistent discovery
|
|
1139
|
+
definition.resources.Resources.FriggKMSKeyAlias = {
|
|
1140
|
+
Type: 'AWS::KMS::Alias',
|
|
1141
|
+
DeletionPolicy: 'Retain',
|
|
1142
|
+
Properties: {
|
|
1143
|
+
AliasName: 'alias/${self:service}-${self:provider.stage}-frigg-kms',
|
|
1144
|
+
TargetKeyId: { 'Fn::GetAtt': ['FriggKMSKey', 'Arn'] }
|
|
1145
|
+
}
|
|
1146
|
+
};
|
|
1147
|
+
|
|
1121
1148
|
definition.provider.iamRoleStatements.push({
|
|
1122
1149
|
Effect: 'Allow',
|
|
1123
1150
|
Action: ['kms:GenerateDataKey', 'kms:Decrypt'],
|
|
@@ -398,6 +398,17 @@ describe('composeServerlessDefinition', () => {
|
|
|
398
398
|
expect(result.custom.kmsGrants).toEqual({
|
|
399
399
|
kmsKeyId: 'arn:aws:kms:us-east-1:123456789012:key/12345678-1234-1234-1234-123456789012'
|
|
400
400
|
});
|
|
401
|
+
|
|
402
|
+
// Check KMS Alias resource is created for discovered key
|
|
403
|
+
expect(result.resources.Resources.FriggKMSKeyAlias).toBeDefined();
|
|
404
|
+
expect(result.resources.Resources.FriggKMSKeyAlias).toEqual({
|
|
405
|
+
Type: 'AWS::KMS::Alias',
|
|
406
|
+
DeletionPolicy: 'Retain',
|
|
407
|
+
Properties: {
|
|
408
|
+
AliasName: 'alias/${self:service}-${self:provider.stage}-frigg-kms',
|
|
409
|
+
TargetKeyId: 'arn:aws:kms:us-east-1:123456789012:key/12345678-1234-1234-1234-123456789012'
|
|
410
|
+
}
|
|
411
|
+
});
|
|
401
412
|
});
|
|
402
413
|
|
|
403
414
|
it('should create new KMS key when encryption is enabled, no key found, and createResourceIfNoneFound is true', async () => {
|
|
@@ -426,9 +437,11 @@ describe('composeServerlessDefinition', () => {
|
|
|
426
437
|
|
|
427
438
|
const result = await composeServerlessDefinition(appDefinition);
|
|
428
439
|
|
|
429
|
-
// Check that KMS key resource was created
|
|
440
|
+
// Check that KMS key resource was created with DeletionPolicy
|
|
430
441
|
expect(result.resources.Resources.FriggKMSKey).toEqual({
|
|
431
442
|
Type: 'AWS::KMS::Key',
|
|
443
|
+
DeletionPolicy: 'Retain',
|
|
444
|
+
UpdateReplacePolicy: 'Retain',
|
|
432
445
|
Properties: {
|
|
433
446
|
EnableKeyRotation: true,
|
|
434
447
|
Description: 'Frigg KMS key for field-level encryption',
|
|
@@ -479,6 +492,17 @@ describe('composeServerlessDefinition', () => {
|
|
|
479
492
|
}
|
|
480
493
|
});
|
|
481
494
|
|
|
495
|
+
// Check KMS Alias resource is created for the new key
|
|
496
|
+
expect(result.resources.Resources.FriggKMSKeyAlias).toBeDefined();
|
|
497
|
+
expect(result.resources.Resources.FriggKMSKeyAlias).toEqual({
|
|
498
|
+
Type: 'AWS::KMS::Alias',
|
|
499
|
+
DeletionPolicy: 'Retain',
|
|
500
|
+
Properties: {
|
|
501
|
+
AliasName: 'alias/${self:service}-${self:provider.stage}-frigg-kms',
|
|
502
|
+
TargetKeyId: { 'Fn::GetAtt': ['FriggKMSKey', 'Arn'] }
|
|
503
|
+
}
|
|
504
|
+
});
|
|
505
|
+
|
|
482
506
|
// Check IAM permissions for the new key
|
|
483
507
|
const kmsPermission = result.provider.iamRoleStatements.find(
|
|
484
508
|
statement => statement.Action.includes('kms:GenerateDataKey')
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@friggframework/devtools",
|
|
3
3
|
"prettier": "@friggframework/prettier-config",
|
|
4
|
-
"version": "2.0.0--canary.428.
|
|
4
|
+
"version": "2.0.0--canary.428.1c210bc.0",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@aws-sdk/client-ec2": "^3.835.0",
|
|
7
7
|
"@aws-sdk/client-kms": "^3.835.0",
|
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
"@babel/eslint-parser": "^7.18.9",
|
|
10
10
|
"@babel/parser": "^7.25.3",
|
|
11
11
|
"@babel/traverse": "^7.25.3",
|
|
12
|
-
"@friggframework/schemas": "2.0.0--canary.428.
|
|
13
|
-
"@friggframework/test": "2.0.0--canary.428.
|
|
12
|
+
"@friggframework/schemas": "2.0.0--canary.428.1c210bc.0",
|
|
13
|
+
"@friggframework/test": "2.0.0--canary.428.1c210bc.0",
|
|
14
14
|
"@hapi/boom": "^10.0.1",
|
|
15
15
|
"@inquirer/prompts": "^5.3.8",
|
|
16
16
|
"axios": "^1.7.2",
|
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
"serverless-http": "^2.7.0"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@friggframework/eslint-config": "2.0.0--canary.428.
|
|
36
|
-
"@friggframework/prettier-config": "2.0.0--canary.428.
|
|
35
|
+
"@friggframework/eslint-config": "2.0.0--canary.428.1c210bc.0",
|
|
36
|
+
"@friggframework/prettier-config": "2.0.0--canary.428.1c210bc.0",
|
|
37
37
|
"aws-sdk-client-mock": "^4.1.0",
|
|
38
38
|
"aws-sdk-client-mock-jest": "^4.1.0",
|
|
39
39
|
"jest": "^30.1.3",
|
|
@@ -68,5 +68,5 @@
|
|
|
68
68
|
"publishConfig": {
|
|
69
69
|
"access": "public"
|
|
70
70
|
},
|
|
71
|
-
"gitHead": "
|
|
71
|
+
"gitHead": "1c210bc49b0013c033077c703eaa7e388927d4bf"
|
|
72
72
|
}
|