fix(kms): normalize alias targetKeyId to plain key ID on createAlias (#1648)

Closes #1647
This commit is contained in:
Mikel Amuchastegui authored and GitHub committed 2026-07-02 23:58:00 -05:00
1 parent ed81f2b124
commit d8c09754d5
2 files changed
+12 -3

No files matched your search

@@ -576,12 +576,12 @@ public class KmsService {
if (!aliasName.startsWith("alias/")) {
throw new AwsException("InvalidAliasNameException", "Alias name must begin with 'alias/'", 400);
}
resolveKey(targetKeyId, region); // Validate key exists
KmsKey key = resolveKey(targetKeyId, region); // Validate key exists and normalize to plain key ID
String aliasArn = regionResolver.buildArn("kms", region, aliasName);
KmsAlias alias = new KmsAlias(aliasName, aliasArn, targetKeyId);
KmsAlias alias = new KmsAlias(aliasName, aliasArn, key.getKeyId());
aliasStore.put(region + "::" + aliasName, alias);
LOG.infov("Created KMS alias: {0} -> {1}", aliasName, targetKeyId);
LOG.infov("Created KMS alias: {0} -> {1}", aliasName, key.getKeyId());
}
public void deleteAlias(String aliasName, String region) {