@friggframework/devtools 2.0.0--canary.428.6b04c24.0 → 2.0.0--canary.428.5364e8f.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.
@@ -592,37 +592,99 @@ class AWSDiscovery {
592
592
  */
593
593
  async findDefaultKmsKey() {
594
594
  try {
595
+ // Log AWS account and region info for verification
596
+ console.log(`[KMS Discovery] Running in region: ${this.region}`);
597
+ try {
598
+ const accountId = await this.getAccountId();
599
+ console.log(`[KMS Discovery] AWS Account ID: ${accountId}`);
600
+ } catch (error) {
601
+ console.warn('[KMS Discovery] Could not retrieve account ID:', error.message);
602
+ }
603
+
595
604
  const command = new ListKeysCommand({});
596
605
  const response = await this.kmsClient.send(command);
597
-
606
+
598
607
  if (!response.Keys || response.Keys.length === 0) {
599
- console.log('No KMS keys found in account');
608
+ console.log('[KMS Discovery] No KMS keys found in account');
600
609
  return null;
601
610
  }
602
611
 
612
+ console.log(`[KMS Discovery] Found ${response.Keys.length} total keys in account`);
613
+ let keysExamined = 0;
614
+ let customerManagedKeys = 0;
615
+ let enabledKeys = 0;
616
+ let pendingDeletionKeys = 0;
617
+
603
618
  // Look for customer managed keys first
604
619
  for (const key of response.Keys) {
605
620
  try {
606
621
  const describeCommand = new DescribeKeyCommand({ KeyId: key.KeyId });
607
622
  const keyDetails = await this.kmsClient.send(describeCommand);
608
-
609
- if (keyDetails.KeyMetadata &&
610
- keyDetails.KeyMetadata.KeyManager === 'CUSTOMER' &&
611
- keyDetails.KeyMetadata.KeyState === 'Enabled') {
612
- console.log(`Found customer managed KMS key: ${keyDetails.KeyMetadata.Arn}`);
613
- return keyDetails.KeyMetadata.Arn;
623
+ keysExamined++;
624
+
625
+ if (keyDetails.KeyMetadata) {
626
+ const metadata = keyDetails.KeyMetadata;
627
+
628
+ // Log detailed key information
629
+ console.log(`[KMS Discovery] Key ${key.KeyId}:`, {
630
+ KeyManager: metadata.KeyManager,
631
+ KeyState: metadata.KeyState,
632
+ Enabled: metadata.Enabled,
633
+ DeletionDate: metadata.DeletionDate || 'Not scheduled for deletion',
634
+ Arn: metadata.Arn
635
+ });
636
+
637
+ if (metadata.KeyManager === 'CUSTOMER') {
638
+ customerManagedKeys++;
639
+
640
+ if (metadata.KeyState === 'Enabled') {
641
+ enabledKeys++;
642
+ } else if (metadata.KeyState === 'PendingDeletion') {
643
+ pendingDeletionKeys++;
644
+ console.warn(`[KMS Discovery] Skipping key ${key.KeyId} - State: PendingDeletion, DeletionDate: ${metadata.DeletionDate}`);
645
+ }
646
+
647
+ // Explicitly check for enabled state AND absence of deletion
648
+ if (metadata.KeyManager === 'CUSTOMER' &&
649
+ metadata.KeyState === 'Enabled' &&
650
+ !metadata.DeletionDate) {
651
+ console.log(`[KMS Discovery] Found eligible customer managed KMS key: ${metadata.Arn}`);
652
+ return metadata.Arn;
653
+ } else if (metadata.KeyManager === 'CUSTOMER' &&
654
+ metadata.KeyState === 'Enabled' &&
655
+ metadata.DeletionDate) {
656
+ // This shouldn't happen according to AWS docs, but log it if it does
657
+ console.error(`[KMS Discovery] WARNING: Key ${key.KeyId} has KeyState='Enabled' but DeletionDate is set: ${metadata.DeletionDate}`);
658
+ }
659
+ }
614
660
  }
615
661
  } catch (error) {
616
662
  // Continue to next key if we can't describe this one
617
- console.warn(`Could not describe key ${key.KeyId}:`, error.message);
663
+ console.warn(`[KMS Discovery] Could not describe key ${key.KeyId}:`, error.message);
618
664
  continue;
619
665
  }
620
666
  }
621
667
 
622
- console.log('No customer managed KMS keys found');
668
+ // Summary logging
669
+ console.log('[KMS Discovery] Summary:', {
670
+ totalKeys: response.Keys.length,
671
+ keysExamined: keysExamined,
672
+ customerManagedKeys: customerManagedKeys,
673
+ enabledKeys: enabledKeys,
674
+ pendingDeletionKeys: pendingDeletionKeys
675
+ });
676
+
677
+ if (customerManagedKeys === 0) {
678
+ console.log('[KMS Discovery] No customer managed KMS keys found in account');
679
+ } else if (enabledKeys === 0) {
680
+ console.warn('[KMS Discovery] Found customer managed keys but none are in Enabled state');
681
+ } else {
682
+ console.warn('[KMS Discovery] Found enabled customer managed keys but none met all criteria');
683
+ }
684
+
623
685
  return null;
624
686
  } catch (error) {
625
- console.error('Error finding default KMS key:', error);
687
+ console.error('[KMS Discovery] Error finding default KMS key:', error);
626
688
  return null;
627
689
  }
628
690
  }
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.6b04c24.0",
4
+ "version": "2.0.0--canary.428.5364e8f.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.6b04c24.0",
13
- "@friggframework/test": "2.0.0--canary.428.6b04c24.0",
12
+ "@friggframework/schemas": "2.0.0--canary.428.5364e8f.0",
13
+ "@friggframework/test": "2.0.0--canary.428.5364e8f.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.6b04c24.0",
36
- "@friggframework/prettier-config": "2.0.0--canary.428.6b04c24.0",
35
+ "@friggframework/eslint-config": "2.0.0--canary.428.5364e8f.0",
36
+ "@friggframework/prettier-config": "2.0.0--canary.428.5364e8f.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": "6b04c24df1e253fd23afd6acb39ec9b5ad61456f"
71
+ "gitHead": "5364e8f51732aa43ffbb4431fdcea2bfa69fb632"
72
72
  }