fix(ssm): include saved key ids in parameter history (#6575)

This commit is contained in:
Jimmy Liu Jia authored and GitHub committed 2026-10-25 23:17:41 -04:00
1 parent 383315194a
commit 0e955cf07b
3 files changed
+125 -7

No files matched your search

@@ -301,6 +301,9 @@ public class SsmJsonHandler {
node.put("Version", h.getVersion());
node.put("Value", h.getValue());
node.put("Type", h.getType());
if (h.getKeyId() != null) {
node.put("KeyId", h.getKeyId());
}
node.put("LastModifiedDate", h.getLastModifiedDate().toEpochMilli() / 1000.0);
if (h.getDescription() != null) {
node.put("Description", h.getDescription());
@@ -394,8 +397,9 @@ public class SsmJsonHandler {
node.put("Description", p.getDescription());
}
node.put("DataType", p.getDataType());
if (SsmService.keyIdOf(p) != null) {
node.put("KeyId", SsmService.keyIdOf(p));
String keyId = SsmService.keyIdOf(p);
if (keyId != null) {
node.put("KeyId", keyId);
}
if (p.getAllowedPattern() != null) {
node.put("AllowedPattern", p.getAllowedPattern());
@@ -303,9 +303,7 @@ public class SsmService implements ResourceProvider {
Parameter parameter = new Parameter(name, value, type != null ? type : "String");
parameter.setVersion(version);
parameter.setDescription(description);
if ("SecureString".equals(parameter.getType())) {
parameter.setKeyId(keyId);
}
parameter.setKeyId(keyIdOf(parameter.getType(), keyId));
parameter.setAllowedPattern(allowedPattern);
// AWS keeps existing policies until new ones, or an empty list, are sent.
if (policies == null) {
@@ -764,10 +762,14 @@ public class SsmService implements ResourceProvider {
/** A SecureString put without a KeyId is encrypted with the AWS managed key. */
static String keyIdOf(Parameter parameter) {
if (!"SecureString".equals(parameter.getType())) {
return keyIdOf(parameter.getType(), parameter.getKeyId());
}
static String keyIdOf(String type, String keyId) {
if (!"SecureString".equals(type)) {
return null;
}
return parameter.getKeyId() != null ? parameter.getKeyId() : DEFAULT_SSM_KEY_ID;
return keyId != null ? keyId : DEFAULT_SSM_KEY_ID;
}
private static boolean matchesAny(String actual, ParameterStringFilter filter) {