in aws-ssmincidents-replicationset/src/main/java/software/amazon/ssmincidents/replicationset/BaseHandlerStd.java [226:256]
private ResourceModel redactModel(ResourceModel model) {
if ((model == null) || (model.getRegions() == null)) {
return model;
}
boolean kmsKeysPresent = model.getRegions().stream()
.anyMatch(replicationRegion ->
Optional.ofNullable(replicationRegion)
.map(ReplicationRegion::getRegionConfiguration)
.map(RegionConfiguration::getSseKmsKeyId).isPresent()
);
if (!kmsKeysPresent) {
// nothing to redact
return model;
}
// replace all KMS Key values with a placeholder
Set<ReplicationRegion> redactedRegions = model.getRegions().stream()
.map(x ->
new ReplicationRegion(
x.getRegionName(),
Optional.ofNullable(x.getRegionConfiguration())
.map(y ->
new RegionConfiguration(y.getSseKmsKeyId() != null ? KMS_KEY_REDACTED_PLACEHOLDER : null)
)
.orElse(null)))
.collect(Collectors.toSet());
return ResourceModel.builder()
.arn(model.getArn())
.deletionProtected(model.getDeletionProtected())
.regions(ImmutableSet.copyOf(redactedRegions))
.build();
}