|
| 1 | +/** |
| 2 | + * List of AWS KMS errors that are specific to KMS and where the error |
| 3 | + * can be returned to the user as is with a specific status code. |
| 4 | + * |
| 5 | + * Avoid any error that might leak sensitive information such as hostnames |
| 6 | + * or IP addresses from network related errors. |
| 7 | + * KeyId is not considered sensitive. |
| 8 | + * |
| 9 | + * Reference: https://docs.aws.amazon.com/kms/latest/APIReference/CommonErrors.html |
| 10 | + * See specific actions like CreateKey, Encrypt, Decrypt, etc. for more details. |
| 11 | + * |
| 12 | + * Other errors not listed will return only the same error code but HTTP status 500, |
| 13 | + * and message will be generic and details will be in logs only. |
| 14 | + */ |
| 15 | +export const allowedKmsErrors = { |
| 16 | + AccessDeniedException: { |
| 17 | + code: 400, |
| 18 | + description: 'You do not have sufficient access to perform this action.', |
| 19 | + }, |
| 20 | + AlreadyExistsException: { |
| 21 | + code: 400, |
| 22 | + description: 'The request was rejected because it attempted to create a resource that already exists.', |
| 23 | + }, |
| 24 | + DisabledException: { |
| 25 | + code: 400, |
| 26 | + description: 'The request was rejected because the specified KMS key is not enabled.', |
| 27 | + }, |
| 28 | + IncorrectKeyException: { |
| 29 | + code: 400, |
| 30 | + description: 'The request was rejected because the specified KMS key cannot decrypt the data', |
| 31 | + }, |
| 32 | + InvalidAliasNameException: { |
| 33 | + code: 400, |
| 34 | + description: 'The request was rejected because the specified alias name is not valid.', |
| 35 | + }, |
| 36 | + InvalidArnException: { |
| 37 | + code: 400, |
| 38 | + description: 'The request was rejected because a specified ARN, or an ARN in a key policy, is not valid.', |
| 39 | + }, |
| 40 | + InvalidCiphertextException: { |
| 41 | + code: 400, |
| 42 | + description: 'The request was rejected because the specified ciphertext, or additional authenticated data, ' + |
| 43 | + 'is corrupted, missing, or otherwise invalid.', |
| 44 | + }, |
| 45 | + InvalidGrantTokenException: { |
| 46 | + code: 400, |
| 47 | + description: 'The request was rejected because the specified grant token is not valid.', |
| 48 | + }, |
| 49 | + InvalidKeyUsageException: { |
| 50 | + code: 400, |
| 51 | + description: 'The KeyUsage or algorithm is incompatible with the API operation.', |
| 52 | + }, |
| 53 | + KMSInternalException: { |
| 54 | + code: 500, |
| 55 | + description: 'The request was rejected because an internal exception occurred. The request can be retried.', |
| 56 | + }, |
| 57 | + KMSInvalidStateException: { |
| 58 | + code: 400, |
| 59 | + description: |
| 60 | + 'The request was rejected because the state of the specified resource is not valid for this request.', |
| 61 | + }, |
| 62 | + KeyUnavailableException: { |
| 63 | + code: 500, |
| 64 | + description: 'The request was rejected because the specified KMS key was not available. ' + |
| 65 | + 'You can retry the request.', |
| 66 | + }, |
| 67 | + LimitExceededException: { |
| 68 | + code: 400, |
| 69 | + description: 'The request was rejected because a length constraint or quota was exceeded.', |
| 70 | + }, |
| 71 | + MalformedPolicyDocumentException: { |
| 72 | + code: 400, |
| 73 | + description: |
| 74 | + 'The request was rejected because the specified policy is not syntactically or semantically correct.', |
| 75 | + }, |
| 76 | + /** Not 404 because it's the KMS (Encrypt/Decrypt) that fails, not the object API */ |
| 77 | + NotFoundException: { |
| 78 | + code: 400, |
| 79 | + description: 'The request was rejected because the specified entity or resource could not be found.', |
| 80 | + }, |
| 81 | + TagException: { |
| 82 | + code: 400, |
| 83 | + description: 'The request was rejected because one or more tags are not valid.', |
| 84 | + }, |
| 85 | + UnsupportedOperationException: { |
| 86 | + code: 400, |
| 87 | + description: 'The request was rejected because a specified parameter is not supported or a specified ' + |
| 88 | + 'resource is not valid for this operation.', |
| 89 | + }, |
| 90 | +} as const; |
0 commit comments